Class: Pvectl::Commands::Get::Handlers::Snapshots

Inherits:
Object
  • Object
show all
Includes:
ResourceHandler
Defined in:
lib/pvectl/commands/get/handlers/snapshots.rb

Overview

Handler for listing and describing snapshots.

Uses –vmid flag (repeatable) for VM/CT filtering and –node for node filtering. Without –vmid, operates cluster-wide.

Examples:

List snapshots for specific VMs

handler.list(args: [], vmid: ["100", "101"])

List all snapshots cluster-wide

handler.list(args: [])

Instance Method Summary collapse

Methods included from ResourceHandler

#selector_class

Constructor Details

#initialize(service: nil) ⇒ Snapshots

Returns a new instance of Snapshots.



21
22
23
# File 'lib/pvectl/commands/get/handlers/snapshots.rb', line 21

def initialize(service: nil)
  @service = service
end

Instance Method Details

#describe(name:, node: nil, args: [], vmid: nil, **_options) ⇒ Models::SnapshotDescription

Describes a snapshot by name.

Parameters:

  • name (String)

    snapshot name to find

  • vmid (Array<String>, nil) (defaults to: nil)

    VM/CT IDs from –vmid flag

  • node (String, nil) (defaults to: nil)

    node name from –node flag

  • args (Array<String>) (defaults to: [])

    unused positional args

Returns:



43
44
45
46
# File 'lib/pvectl/commands/get/handlers/snapshots.rb', line 43

def describe(name:, node: nil, args: [], vmid: nil, **_options)
  parsed_vmids = parse_vmids(vmid)
  service.describe(parsed_vmids, name, node: node)
end

#list(node: nil, name: nil, args: [], storage: nil, vmid: nil, **_options) ⇒ Array<Models::Snapshot>

Lists snapshots, optionally filtered by VMIDs and/or node.

Parameters:

  • vmid (Array<String>, nil) (defaults to: nil)

    VM/CT IDs from –vmid flag

  • node (String, nil) (defaults to: nil)

    node name from –node flag

  • args (Array<String>) (defaults to: [])

    unused positional args

Returns:



31
32
33
34
# File 'lib/pvectl/commands/get/handlers/snapshots.rb', line 31

def list(node: nil, name: nil, args: [], storage: nil, vmid: nil, **_options)
  parsed_vmids = parse_vmids(vmid)
  service.list(parsed_vmids, node: node)
end

#presenterPresenters::Snapshot

Returns presenter for snapshots.

Returns:



51
52
53
# File 'lib/pvectl/commands/get/handlers/snapshots.rb', line 51

def presenter
  Pvectl::Presenters::Snapshot.new
end