diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2020-10-28 12:13:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-28 12:13:08 -0700 |
| commit | 6364d59f9227637c887dfc1636b725740f57ad4e (patch) | |
| tree | bf6e8d1701498c9004602db058465a1a27925a17 | |
| parent | 2a10904d038da11d13b35f0058e595e99856b4d8 (diff) | |
| parent | fab01f9d8d7f191c8830423611544eebfeb5213c (diff) | |
| download | seaweedfs-6364d59f9227637c887dfc1636b725740f57ad4e.tar.xz seaweedfs-6364d59f9227637c887dfc1636b725740f57ad4e.zip | |
Merge pull request #1575 from kmlebedev/shell_mark_writable
add readonly
| -rw-r--r-- | weed/shell/command_volume_mark.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/weed/shell/command_volume_mark.go b/weed/shell/command_volume_mark.go index cb3e5c0bc..19b614310 100644 --- a/weed/shell/command_volume_mark.go +++ b/weed/shell/command_volume_mark.go @@ -2,6 +2,7 @@ package shell import ( "flag" + "fmt" "io" "github.com/chrislusf/seaweedfs/weed/storage/needle" @@ -19,9 +20,9 @@ func (c *commandVolumeMark) Name() string { } func (c *commandVolumeMark) Help() string { - return `Mark volume readonly from one volume server + return `Mark volume writable or readonly from one volume server - volume.mark -node <volume server host:port> -volumeId <volume id> -readonly true + volume.mark -node <volume server host:port> -volumeId <volume id> -writable or -readonly ` } @@ -34,14 +35,21 @@ func (c *commandVolumeMark) Do(args []string, commandEnv *CommandEnv, writer io. 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") + writable := volMarkCommand.Bool("writable", false, "volume mark writable") + readonly := volMarkCommand.Bool("readonly", false, "volume mark readonly") if err = volMarkCommand.Parse(args); err != nil { return nil } + markWritable := false + if (*writable && *readonly) || (!*writable && !*readonly) { + return fmt.Errorf("use -readonly or -writable") + } else if *writable { + markWritable = true + } sourceVolumeServer := *nodeStr volumeId := needle.VolumeId(*volumeIdInt) - return markVolumeWritable(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, *writable) + return markVolumeWritable(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, markWritable) } |
