Class: Pvectl::Models::Capability

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/models/capability.rb

Overview

Represents a single node capability entry — either a supported QEMU CPU model or a supported QEMU machine type.

The two kinds share a flat structure with different optional fields populated. A small, kind-aware model keeps the presenter simple while still allowing JSON/YAML output to expose all relevant attributes.

Examples:

QEMU CPU capability

cap = Capability.new(node_name: "pve1", kind: :cpu, name: "host", vendor: "Intel")

QEMU machine type capability

cap = Capability.new(node_name: "pve1", kind: :machine, name: "pc-q35-8.1", machine_type: "q35", version: "8.1")

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Capability

Creates a new Capability.

Parameters:

  • attributes (Hash) (defaults to: {})

    attribute hash



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pvectl/models/capability.rb', line 49

def initialize(attributes = {})
  super
  @node_name = @attributes[:node_name]
  @kind = @attributes[:kind]
  @name = @attributes[:name]
  @vendor = @attributes[:vendor]
  @custom = @attributes[:custom] || false
  @machine_type = @attributes[:machine_type]
  @version = @attributes[:version]
  @changes = @attributes[:changes]
end

Instance Attribute Details

#changesString? (readonly)

Returns notable changes for the version (only :machine).

Returns:

  • (String, nil)

    notable changes for the version (only :machine)



44
45
46
# File 'lib/pvectl/models/capability.rb', line 44

def changes
  @changes
end

#customBoolean (readonly)

Returns true when this is a custom CPU model (only :cpu).

Returns:

  • (Boolean)

    true when this is a custom CPU model (only :cpu)



35
36
37
# File 'lib/pvectl/models/capability.rb', line 35

def custom
  @custom
end

#kindSymbol (readonly)

Returns capability kind: :cpu or :machine.

Returns:

  • (Symbol)

    capability kind: :cpu or :machine



26
27
28
# File 'lib/pvectl/models/capability.rb', line 26

def kind
  @kind
end

#machine_typeString? (readonly)

Returns machine type — q35 or i440fx (only :machine).

Returns:

  • (String, nil)

    machine type — q35 or i440fx (only :machine)



38
39
40
# File 'lib/pvectl/models/capability.rb', line 38

def machine_type
  @machine_type
end

#nameString? (readonly)

Returns identifying name (CPU model or machine id).

Returns:

  • (String, nil)

    identifying name (CPU model or machine id)



29
30
31
# File 'lib/pvectl/models/capability.rb', line 29

def name
  @name
end

#node_nameString? (readonly)

Returns node the capability belongs to.

Returns:

  • (String, nil)

    node the capability belongs to



23
24
25
# File 'lib/pvectl/models/capability.rb', line 23

def node_name
  @node_name
end

#vendorString? (readonly)

Returns CPU vendor (only for :cpu kind).

Returns:

  • (String, nil)

    CPU vendor (only for :cpu kind)



32
33
34
# File 'lib/pvectl/models/capability.rb', line 32

def vendor
  @vendor
end

#versionString? (readonly)

Returns machine version (only :machine).

Returns:

  • (String, nil)

    machine version (only :machine)



41
42
43
# File 'lib/pvectl/models/capability.rb', line 41

def version
  @version
end