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.

55 lines
1.2 KiB

3 months ago
  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) HasTag(CommandTag) bool {
  23. return false
  24. }
  25. func (c *commandVolumeDelete) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
  26. volDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
  27. volumeIdInt := volDeleteCommand.Int("volumeId", 0, "the volume id")
  28. nodeStr := volDeleteCommand.String("node", "", "the volume server <host>:<port>")
  29. if err = volDeleteCommand.Parse(args); err != nil {
  30. return nil
  31. }
  32. if err = commandEnv.confirmIsLocked(args); err != nil {
  33. return
  34. }
  35. sourceVolumeServer := pb.ServerAddress(*nodeStr)
  36. volumeId := needle.VolumeId(*volumeIdInt)
  37. return deleteVolume(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer, false)
  38. }