Class: Pvectl::Commands::Get::Handlers::Capabilities

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

Overview

Handler for ‘pvectl get node-capabilities`.

Surfaces what features a node supports — primarily the available QEMU CPU models and machine types. When ‘–node` is provided the query is scoped to that node; otherwise the handler iterates all online nodes and aggregates the results, silently skipping unreachable nodes (matches the pattern used by the time handler).

Instance Method Summary collapse

Methods included from ResourceHandler

#selector_class

Constructor Details

#initialize(repository: nil, node_repository: nil) ⇒ Capabilities

Returns a new instance of Capabilities.

Parameters:



23
24
25
26
# File 'lib/pvectl/commands/get/handlers/capabilities.rb', line 23

def initialize(repository: nil, node_repository: nil)
  @repository = repository
  @node_repository = node_repository
end

Instance Method Details

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

Lists capabilities, optionally scoped to a node.

Parameters:

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

    when provided, only that node is queried

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

    unused, interface compatibility

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

    unused, interface compatibility

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

    unused, interface compatibility

Returns:

Raises:



36
37
38
39
40
41
42
43
44
# File 'lib/pvectl/commands/get/handlers/capabilities.rb', line 36

def list(node: nil, name: nil, args: [], storage: nil, **_options)
  return fetch_for(node) if node

  online_node_names.flat_map do |node_name|
    repository.list(node: node_name)
  rescue StandardError
    []
  end
end

#presenterPresenters::Capability

Returns the capability presenter.



49
50
51
# File 'lib/pvectl/commands/get/handlers/capabilities.rb', line 49

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