Class: Pvectl::Commands::Restart
- Inherits:
-
Object
- Object
- Pvectl::Commands::Restart
- Includes:
- VmLifecycleCommand
- Defined in:
- lib/pvectl/commands/restart.rb
Overview
Handler for the ‘pvectl restart` command.
Restarts one or more virtual machines (reboot).
Constant Summary collapse
- OPERATION =
:restart
Class Method Summary collapse
-
.register(cli) ⇒ void
Registers the restart command with the CLI.
Methods included from VmLifecycleCommand
Methods included from ResourceLifecycleCommand
#execute, included, #initialize
Class Method Details
.register(cli) ⇒ void
This method returns an undefined value.
Registers the restart command with the CLI.
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 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pvectl/commands/restart.rb', line 22 def self.register(cli) cli.desc "Restart virtual machines or containers (reboot)" cli.long_desc <<~HELP Reboot one or more virtual machines or containers. Sends a reboot signal to the guest OS for a clean restart. EXAMPLES Reboot a VM: $ pvectl restart vm 100 Reboot a container: $ pvectl restart ct 200 Reboot all VMs with a specific tag: $ pvectl restart vm --all -l tags=webserver --yes NOTES For VMs, this sends an ACPI reboot signal (requires guest agent or ACPI support). For containers, uses LXC reboot. For a hard reset (equivalent to pressing the reset button), use 'pvectl reset' instead (VMs only). SEE ALSO pvectl help reset Hard reset (VMs only) pvectl help shutdown Graceful shutdown without restart HELP cli.arg_name "RESOURCE_TYPE [ID...]" cli.command :restart do |c| SharedFlags.lifecycle(c) c.action do |, , args| resource_type = args.shift resource_ids = args exit_code = case resource_type when "container", "ct" RestartContainer.execute(resource_type, resource_ids, , ) else execute(resource_type, resource_ids, , ) end exit exit_code if exit_code != 0 end end end |