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/chrislusf/seaweedfs/weed/pb"
  5. "io"
  6. "github.com/chrislusf/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. if err = commandEnv.confirmIsLocked(); err != nil {
  24. return
  25. }
  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. sourceVolumeServer := pb.ServerAddress(*nodeStr)
  33. volumeId := needle.VolumeId(*volumeIdInt)
  34. return deleteVolume(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer)
  35. }