Class: Pvectl::Commands::Stop
- Inherits:
-
Object
- Object
- Pvectl::Commands::Stop
- Includes:
- VmLifecycleCommand
- Defined in:
- lib/pvectl/commands/stop.rb
Overview
Handler for the ‘pvectl stop` command.
Stops one or more virtual machines (hard stop).
Constant Summary collapse
- OPERATION =
:stop
Class Method Summary collapse
-
.register(cli) ⇒ void
Registers the stop 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 stop 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 69 70 |
# File 'lib/pvectl/commands/stop.rb', line 22 def self.register(cli) cli.desc "Stop virtual machines or containers (hard stop)" cli.long_desc <<~HELP Immediately stop one or more virtual machines or containers. This is a hard stop (equivalent to pulling the power cord) — the guest OS is NOT shut down gracefully. For a clean shutdown, use 'pvectl shutdown' instead. EXAMPLES Hard stop a VM: $ pvectl stop vm 100 Stop multiple containers: $ pvectl stop ct 200 201 Stop all running VMs: $ pvectl stop vm --all -l status=running --yes Stop with sync wait: $ pvectl stop vm 100 --wait --timeout 30 NOTES Hard stop may cause data loss or filesystem corruption in the guest. Prefer 'shutdown' for production workloads. Batch operations (--all) require --yes or interactive confirmation. SEE ALSO pvectl help shutdown Graceful shutdown (recommended) pvectl help start Start resources HELP cli.arg_name "RESOURCE_TYPE [ID...]" cli.command :stop do |c| SharedFlags.lifecycle(c) c.action do |, , args| resource_type = args.shift resource_ids = args exit_code = case resource_type when "container", "ct" StopContainer.execute(resource_type, resource_ids, , ) else execute(resource_type, resource_ids, , ) end exit exit_code if exit_code != 0 end end end |