Class: Pvectl::Commands::Suspend

Inherits:
Object
  • Object
show all
Includes:
VmLifecycleCommand
Defined in:
lib/pvectl/commands/suspend.rb

Overview

Handler for the ‘pvectl suspend` command.

Suspends one or more virtual machines (hibernate).

Examples:

Suspend a single VM

pvectl suspend vm 100

Suspend with sync mode

pvectl suspend vm 100 --wait

Constant Summary collapse

OPERATION =
:suspend

Class Method Summary collapse

Methods included from VmLifecycleCommand

included

Methods included from ResourceLifecycleCommand

#execute, included, #initialize

Class Method Details

.register(cli) ⇒ void

This method returns an undefined value.

Registers the suspend command with the CLI.

Parameters:

  • cli (GLI::App)

    the CLI application object



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
# File 'lib/pvectl/commands/suspend.rb', line 22

def self.register(cli)
  cli.desc "Suspend virtual machines (hibernate)"
  cli.long_desc <<~HELP
    Suspend (hibernate) one or more virtual machines. Saves the VM's
    memory state to disk and stops it. The VM can be resumed later
    with 'pvectl resume'.

    Only available for VMs. Containers do not support suspend.

    EXAMPLES
      Suspend a VM:
        $ pvectl suspend vm 100

      Suspend all running VMs on a node:
        $ pvectl suspend vm --all --node pve1 -l status=running --yes

    NOTES
      Suspend saves the full memory state to disk, which may take time
      for VMs with large memory allocations.

      Not available for containers.

    SEE ALSO
      pvectl help resume          Resume suspended VMs
      pvectl help shutdown        Graceful shutdown (no state saved)
  HELP
  cli.arg_name "RESOURCE_TYPE [ID...]"
  cli.command :suspend do |c|
    SharedFlags.lifecycle(c)

    c.action do |global_options, options, args|
      resource_type = args.shift
      resource_ids = args
      exit_code = execute(resource_type, resource_ids, options, global_options)
      exit exit_code if exit_code != 0
    end
  end
end