Class: Pvectl::Commands::MoveDiskVm
- Inherits:
-
Object
- Object
- Pvectl::Commands::MoveDiskVm
- Includes:
- MoveDiskCommand
- Defined in:
- lib/pvectl/commands/move_disk_vm.rb
Overview
Handler for the ‘pvectl move disk vm` command.
Moves a VM disk to a different storage on the same node. The Proxmox API call is asynchronous — the returned UPID is included in the OperationResult. Use –wait to block until the task completes.
Constant Summary collapse
- RESOURCE_TYPE =
:vm- SUPPORTED_RESOURCES =
%w[vm].freeze
Constants included from MoveDiskCommand
Pvectl::Commands::MoveDiskCommand::VALID_FORMATS
Class Method Summary collapse
-
.register(cli) ⇒ void
Registers the move command with the CLI.
Methods included from MoveDiskCommand
#execute, included, #initialize
Class Method Details
.register(cli) ⇒ void
This method returns an undefined value.
Registers the move command with the CLI.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pvectl/commands/move_disk_vm.rb', line 24 def self.register(cli) cli.desc "Move a VM disk or container volume to another storage" cli.long_desc <<~HELP Move a VM disk or container volume to a different storage on the same node. The source disk is kept as an unused entry by default; pass --delete-source to remove it after a successful copy. The operation is asynchronous: the returned task UPID can be tracked with `pvectl get tasks` or `pvectl logs task <upid>`. Pass --wait to block until the move completes (with --timeout). EXAMPLES Move VM disk to another storage: $ pvectl move disk vm 100 scsi0 --target storage2 Move VM disk and convert format: $ pvectl move disk vm 100 scsi0 --target storage2 --format qcow2 Move VM disk and delete source after copy: $ pvectl move disk vm 100 scsi0 --target storage2 --delete-source Move container rootfs to another storage: $ pvectl move disk ct 200 rootfs --target storage2 Move container mount point with bandwidth cap (KiB/s): $ pvectl move disk ct 200 mp0 --target storage2 --bandwidth 10240 Block until completion: $ pvectl move disk vm 100 scsi0 --target storage2 --wait NOTES --target is required and must be a valid storage on the source node. --format is only valid for VMs (raw, qcow2, vmdk). It is rejected for containers because the LXC API does not accept a format. --bandwidth is in KiB/s, matching the Proxmox API directly. The operation defaults to the datacenter/storage move limit when omitted. For VMs, allowed disk keys include ide0..ide3, scsi0..scsi30, virtio0..virtio15, sata0..sata5, efidisk0, tpmstate0, unused*. For containers, allowed volume keys include rootfs, mp0..mp255, unused*. SEE ALSO pvectl help migrate Move a VM/container to another node pvectl help clone Clone a VM or container pvectl help get storage List storages on the cluster HELP cli.arg_name "SUBJECT RESOURCE_TYPE ID DISK" cli.command :move do |c| c.desc "Target storage (required)" c.flag [:target, :t], arg_name: "STORAGE" c.desc "Target disk format (VM only): raw, qcow2, or vmdk" c.flag [:format, :f], arg_name: "FORMAT" c.desc "Delete source disk after successful copy" c.switch [:"delete-source"], negatable: false c.desc "Bandwidth limit in KiB/s" c.flag [:bandwidth, :b], type: Integer, arg_name: "KIBPS" c.desc "Wait for the task to complete (sync mode)" c.switch [:wait], negatable: false c.desc "Timeout in seconds for sync operations (default: 600)" c.flag [:timeout], type: Integer, arg_name: "SECONDS" c.desc "Skip confirmation prompt" c.switch [:yes, :y], negatable: false c.action do |, , args| subject = args.shift resource_type = args.shift exit_code = if subject != "disk" $stderr.puts "Error: Unknown subject: #{subject.inspect}" $stderr.puts "Valid subjects: disk" ExitCodes::USAGE_ERROR else case resource_type when "vm" Commands::MoveDiskVm.execute(args, , ) when "container", "ct" Commands::MoveDiskContainer.execute(args, , ) else $stderr.puts "Error: Unknown resource type: #{resource_type}" $stderr.puts "Valid types: vm, container, ct" ExitCodes::USAGE_ERROR end end exit exit_code if exit_code != 0 end end end |