You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

  1. package shell
  2. import (
  3. "flag"
  4. "io"
  5. "github.com/chrislusf/seaweedfs/weed/storage/needle"
  6. )
  7. func init() {
  8. Commands = append(Commands, &commandVolumeMark{})
  9. }
  10. type commandVolumeMark struct {
  11. }
  12. func (c *commandVolumeMark) Name() string {
  13. return "volume.mark"
  14. }
  15. func (c *commandVolumeMark) Help() string {
  16. return `Mark volume readonly from one volume server
  17. volume.mark -node <volume server host:port> -volumeId <volume id> -readonly true
  18. `
  19. }
  20. func (c *commandVolumeMark) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
  21. if err = commandEnv.confirmIsLocked(); err != nil {
  22. return
  23. }
  24. volMarkCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
  25. volumeIdInt := volMarkCommand.Int("volumeId", 0, "the volume id")
  26. nodeStr := volMarkCommand.String("node", "", "the volume server <host>:<port>")
  27. writable := volMarkCommand.Bool("writable", true, "volume mark writable/readonly")
  28. if err = volMarkCommand.Parse(args); err != nil {
  29. return nil
  30. }
  31. sourceVolumeServer := *nodeStr
  32. volumeId := needle.VolumeId(*volumeIdInt)
  33. return markVolumeWritable(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, *writable)
  34. }