Class: Pvectl::Commands::Shutdown
- Inherits:
-
Object
- Object
- Pvectl::Commands::Shutdown
- Includes:
- VmLifecycleCommand
- Defined in:
- lib/pvectl/commands/shutdown.rb,
sig/pvectl/commands/shutdown.rbs
Overview
Handler for the pvectl shutdown command.
Shuts down one or more virtual machines gracefully (ACPI).
Constant Summary collapse
- OPERATION =
:shutdown
Class Method Summary collapse
-
.register(cli) ⇒ void
Registers the shutdown command with the CLI.
Methods included from VmLifecycleCommand
#build_presenter, #build_repository, #build_selector, #build_service, included, #resource_id_label, #resource_label, #supported_resources
Methods included from ResourceLifecycleCommand
#apply_selectors, #build_presenter, #build_repository, #build_selector, #build_service, #confirm_operation, #determine_exit_code, #execute, included, #initialize, #load_config, #no_resources_found, #operation_name, #output_results, #perform_operation, #resolve_resources, #resource_id_label, #resource_label, #selector_strings, #service_options, #supported_resources, #usage_error
Class Method Details
.register(cli) ⇒ void
This method returns an undefined value.
Registers the shutdown 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 66 67 68 |
# File 'lib/pvectl/commands/shutdown.rb', line 22 def self.register(cli) cli.desc "Shutdown virtual machines or containers gracefully" cli.long_desc " Gracefully shut down one or more virtual machines or containers.\n Sends an ACPI shutdown signal to VMs or a clean shutdown to containers,\n allowing the guest OS to shut down properly.\n\n This is the recommended way to stop production workloads. For\n immediate termination, use 'pvectl stop' instead.\n\n EXAMPLES\n Graceful shutdown of a VM:\n $ pvectl shutdown vm 100\n\n Shutdown with wait and timeout:\n $ pvectl shutdown vm 100 --wait --timeout 120\n\n Shutdown all running VMs on a node:\n $ pvectl shutdown vm --all --node pve1 -l status=running --yes\n\n NOTES\n Requires QEMU Guest Agent or ACPI support in the VM for graceful\n shutdown. If the guest doesn't respond, the shutdown may time out.\n\n Use --timeout with --wait to set a maximum wait time.\n\n SEE ALSO\n pvectl help stop Hard stop (immediate, may cause data loss)\n pvectl help restart Reboot resources\n HELP\n cli.arg_name \"RESOURCE_TYPE [ID...]\"\n cli.command :shutdown do |c|\n SharedFlags.lifecycle(c)\n\n c.action do |global_options, options, args|\n resource_type = args.shift\n resource_ids = args\n exit_code = case resource_type\n when \"container\", \"ct\"\n ShutdownContainer.execute(resource_type, resource_ids, options, global_options)\n else\n execute(resource_type, resource_ids, options, global_options)\n end\n exit exit_code if exit_code != 0\n end\n end\nend\n" |