Class: Pvectl::Commands::Reset

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

Overview

Handler for the ‘pvectl reset` command.

Resets one or more virtual machines (hard reset).

Examples:

Reset a single VM

pvectl reset vm 100

Reset with JSON output

pvectl reset vm 100 -o json

Constant Summary collapse

OPERATION =
:reset

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 reset 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/reset.rb', line 22

def self.register(cli)
  cli.desc "Reset virtual machines (hard reset)"
  cli.long_desc <<~HELP
    Hard reset one or more virtual machines. Equivalent to pressing the
    physical reset button — the VM is immediately restarted without
    graceful OS shutdown.

    Only available for VMs. Containers do not support hard reset.

    EXAMPLES
      Hard reset a VM:
        $ pvectl reset vm 100

      Reset multiple VMs:
        $ pvectl reset vm 100 101 102

    NOTES
      May cause data loss or filesystem corruption. Use 'pvectl restart'
      for a graceful reboot instead.

      Not available for containers — use 'pvectl restart ct' instead.

    SEE ALSO
      pvectl help restart         Graceful reboot (VMs and containers)
      pvectl help stop            Hard stop without restart
  HELP
  cli.arg_name "RESOURCE_TYPE [ID...]"
  cli.command :reset 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