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.

51 lines
1.2 KiB

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