Class: Pvectl::Commands::Cloudinit::Regenerate
- Inherits:
-
Object
- Object
- Pvectl::Commands::Cloudinit::Regenerate
- Defined in:
- lib/pvectl/commands/cloudinit/regenerate.rb
Overview
Handler for the ‘pvectl cloudinit regenerate vm <id>` subcommand.
Triggers Proxmox to rebuild the cloud-init ISO from the current VM configuration. The operation is synchronous on the Proxmox side and returns null on success.
Class Method Summary collapse
-
.execute(args, options, global_options) ⇒ Integer
Executes the regenerate subcommand.
-
.register_subcommand(parent) ⇒ void
Registers the regenerate subcommand under the cloudinit parent.
Class Method Details
.execute(args, options, global_options) ⇒ Integer
Executes the regenerate subcommand.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pvectl/commands/cloudinit/regenerate.rb', line 63 def self.execute(args, , ) resource_type = args[0] vmid_arg = args[1] return Cloudinit.usage_error("Resource type required (vm)") unless resource_type return Cloudinit.usage_error("VMID is required") unless vmid_arg return Cloudinit.unknown_resource_type(resource_type) unless resource_type == "vm" Cloudinit.with_service() do |service| result = service.regenerate(vmid_arg.to_i, node: [:node]) $stdout.puts "Cloud-init ISO regenerated for VM #{result[:vmid]} on #{result[:node]}." end end |
.register_subcommand(parent) ⇒ void
This method returns an undefined value.
Registers the regenerate subcommand under the cloudinit parent.
21 22 23 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 |
# File 'lib/pvectl/commands/cloudinit/regenerate.rb', line 21 def self.register_subcommand(parent) parent.desc "Regenerate the cloud-init ISO for a VM" parent.long_desc <<~HELP DESCRIPTION Rebuild the cloud-init configuration drive (ISO) for a VM from the current Proxmox configuration. This is required after editing cloud-init-related options (user, ipconfig, sshkeys, etc.) for the changes to take effect inside the guest on next boot. EXAMPLES Regenerate cloud-init for VM 100: $ pvectl cloudinit regenerate vm 100 Skip VMID lookup by passing the node explicitly: $ pvectl cloudinit regenerate vm 100 --node pve2 NOTES Cloud-init is a VM-only feature — LXC containers do not expose cloud-init endpoints. The VM does NOT need to be running. The regenerated ISO will be picked up at the next guest reboot. SEE ALSO pvectl help cloudinit pending Show pending cloud-init changes pvectl help cloudinit dump Inspect generated cloud-init YAML HELP parent.arg_name "RESOURCE_TYPE ID" parent.command :regenerate do |c| c.action do |, , args| exit_code = execute(args, , ) exit exit_code if exit_code != 0 end end end |