aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_delete.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/shell/command_volume_delete.go')
-rw-r--r--weed/shell/command_volume_delete.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/weed/shell/command_volume_delete.go b/weed/shell/command_volume_delete.go
index 17d27ea3a..187caa1a4 100644
--- a/weed/shell/command_volume_delete.go
+++ b/weed/shell/command_volume_delete.go
@@ -1,8 +1,7 @@
package shell
import (
- "context"
- "fmt"
+ "flag"
"io"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
@@ -22,7 +21,7 @@ func (c *commandVolumeDelete) Name() string {
func (c *commandVolumeDelete) Help() string {
return `delete a live volume from one volume server
- volume.delete <volume server host:port> <volume id>
+ volume.delete -node <volume server host:port> -volumeId <volume id>
This command deletes a volume from one volume server.
@@ -31,18 +30,21 @@ func (c *commandVolumeDelete) Help() string {
func (c *commandVolumeDelete) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
- if len(args) != 2 {
- fmt.Fprintf(writer, "received args: %+v\n", args)
- return fmt.Errorf("need 2 args of <volume server host:port> <volume id>")
+ if err = commandEnv.confirmIsLocked(); err != nil {
+ return
}
- sourceVolumeServer, volumeIdString := args[0], args[1]
- volumeId, err := needle.NewVolumeId(volumeIdString)
- if err != nil {
- return fmt.Errorf("wrong volume id format %s: %v", volumeId, err)
+ volDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ volumeIdInt := volDeleteCommand.Int("volumeId", 0, "the volume id")
+ nodeStr := volDeleteCommand.String("node", "", "the volume server <host>:<port>")
+ if err = volDeleteCommand.Parse(args); err != nil {
+ return nil
}
- ctx := context.Background()
- return deleteVolume(ctx, commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer)
+ sourceVolumeServer := *nodeStr
+
+ volumeId := needle.VolumeId(*volumeIdInt)
+
+ return deleteVolume(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer)
}