Class: Pvectl::Commands::SetVm
- Inherits:
-
Object
- Object
- Pvectl::Commands::SetVm
- Includes:
- SetResourceCommand
- Defined in:
- lib/pvectl/commands/set_vm.rb
Overview
Handler for the ‘pvectl set vm` command.
Includes SetResourceCommand for shared workflow and overrides template methods with VM-specific behavior.
Also registers the top-level ‘set` command with all resource types.
Class Method Summary collapse
-
.register(cli) ⇒ void
Registers the set command with the CLI.
Methods included from SetResourceCommand
#execute, included, #initialize
Class Method Details
.register(cli) ⇒ void
This method returns an undefined value.
Registers the set command with the CLI.
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 |
# File 'lib/pvectl/commands/set_vm.rb', line 25 def self.register(cli) cli.desc "Set a resource property (non-interactive)" cli.long_desc <<~HELP Set configuration properties on a resource without opening an editor. Accepts key=value pairs as arguments. This is the non-interactive counterpart to the edit command. EXAMPLES Set VM memory and CPU: $ pvectl set vm 100 memory=4096 cores=2 Set container hostname: $ pvectl set container 200 hostname=web01 Resize a volume: $ pvectl set volume vm 100 scsi0 size=+10G Set volume cache mode: $ pvectl set volume vm 100 scsi0 cache=writeback Set node description: $ pvectl set node pve1 description="Production node" Change node timezone: $ pvectl set node pve1 timezone=Europe/Warsaw Preview changes without applying: $ pvectl set vm 100 memory=8192 --dry-run NOTES Volume resize (size=) is irreversible. A confirmation prompt is shown unless --yes is specified. Keys are passed directly to the Proxmox API. Use Proxmox documentation to find valid configuration keys for each resource type. SEE ALSO pvectl help edit Interactive configuration editor pvectl help describe View current configuration HELP cli.arg_name "RESOURCE_TYPE RESOURCE_ID [SUB_ID] KEY=VALUE [KEY=VALUE ...]" cli.command :set do |c| c.desc "Skip confirmation prompt" c.switch [:yes, :y], negatable: false c.desc "Target node name" c.flag [:node, :n], arg_name: "NODE" c.desc "Show diff without applying changes" c.switch [:"dry-run"], negatable: false c.action do |, , args| resource_type = args.shift exit_code = case resource_type when "vm" Commands::SetVm.execute(args, , ) when "container", "ct" Commands::SetContainer.execute(args, , ) when "volume", "vol" Commands::SetVolume.execute(args, , ) when "node" Commands::SetNode.execute(args, , ) when nil $stderr.puts "Error: Resource type required (vm, container, volume, node)" ExitCodes::USAGE_ERROR else $stderr.puts "Error: Unknown resource type: #{resource_type}" $stderr.puts "Valid types: vm, container, volume, node" ExitCodes::USAGE_ERROR end exit exit_code if exit_code != 0 end end end |