diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-10-28 22:47:09 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-10-28 22:47:09 +0500 |
| commit | 884db215a14258d73e5744ae32fdb97e6f3cb09b (patch) | |
| tree | ddb6a6400c61b92cc48d507a940e575b3b8fbd28 /weed/shell/command_volume_mark.go | |
| parent | c321378976b22bdb7224629747c2ecc57c67d3f6 (diff) | |
| download | seaweedfs-884db215a14258d73e5744ae32fdb97e6f3cb09b.tar.xz seaweedfs-884db215a14258d73e5744ae32fdb97e6f3cb09b.zip | |
add shell command volume mark writable
Diffstat (limited to 'weed/shell/command_volume_mark.go')
| -rw-r--r-- | weed/shell/command_volume_mark.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/weed/shell/command_volume_mark.go b/weed/shell/command_volume_mark.go new file mode 100644 index 000000000..cb3e5c0bc --- /dev/null +++ b/weed/shell/command_volume_mark.go @@ -0,0 +1,47 @@ +package shell + +import ( + "flag" + "io" + + "github.com/chrislusf/seaweedfs/weed/storage/needle" +) + +func init() { + Commands = append(Commands, &commandVolumeMark{}) +} + +type commandVolumeMark struct { +} + +func (c *commandVolumeMark) Name() string { + return "volume.mark" +} + +func (c *commandVolumeMark) Help() string { + return `Mark volume readonly from one volume server + + volume.mark -node <volume server host:port> -volumeId <volume id> -readonly true +` +} + +func (c *commandVolumeMark) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { + + if err = commandEnv.confirmIsLocked(); err != nil { + return + } + + volMarkCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) + volumeIdInt := volMarkCommand.Int("volumeId", 0, "the volume id") + nodeStr := volMarkCommand.String("node", "", "the volume server <host>:<port>") + writable := volMarkCommand.Bool("writable", true, "volume mark writable/readonly") + if err = volMarkCommand.Parse(args); err != nil { + return nil + } + + sourceVolumeServer := *nodeStr + + volumeId := needle.VolumeId(*volumeIdInt) + + return markVolumeWritable(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, *writable) +} |
