Class: Pvectl::Models::Node
Overview
Represents a node in the Proxmox cluster.
Immutable domain model containing node attributes and domain predicates. Display formatting is handled by Presenters::Node. Created by Repositories::Node from API data.
Instance Attribute Summary collapse
-
#boot_info ⇒ Hash?
readonly
Boot info (mode: efi/bios).
-
#cpu ⇒ Float?
readonly
CPU usage (0-1 scale).
-
#cpuinfo ⇒ Hash?
readonly
Extended attributes for describe command.
-
#disk ⇒ Integer?
readonly
Local disk used in bytes.
-
#dns ⇒ Hash?
readonly
DNS configuration (search, dns1, dns2, dns3).
-
#firewall ⇒ Hash?
readonly
Firewall configuration data.
-
#guests_cts ⇒ Integer
readonly
Number of containers on this node.
-
#guests_vms ⇒ Integer
readonly
Number of VMs on this node.
-
#ip ⇒ String?
readonly
Node IP address (from interface with gateway).
-
#kernel ⇒ String?
readonly
Kernel version (e.g., “6.8.12-1-pve”).
-
#level ⇒ String?
readonly
Subscription level (c=community, b=basic, etc.).
-
#loadavg ⇒ Array<Float>?
readonly
Load averages [1min, 5min, 15min].
-
#maxcpu ⇒ Integer?
readonly
Total CPU cores.
-
#maxdisk ⇒ Integer?
readonly
Total local disk in bytes.
-
#maxmem ⇒ Integer?
readonly
Total memory in bytes.
-
#mem ⇒ Integer?
readonly
Memory used in bytes.
-
#name ⇒ String
readonly
Node name.
-
#network_interfaces ⇒ Array<Hash>
readonly
Network interfaces.
-
#offline_note ⇒ String?
readonly
Offline note message.
-
#physical_disks ⇒ Array<Hash>
readonly
Physical disks.
-
#qemu_cpu_models ⇒ Array<Hash>
readonly
QEMU CPU models.
-
#qemu_machines ⇒ Array<Hash>
readonly
QEMU machine types.
-
#rootfs ⇒ Hash?
readonly
Root filesystem (used, total, free).
-
#services ⇒ Array<Hash>
readonly
System services.
-
#status ⇒ String
readonly
Node status (online/offline).
-
#storage_pools ⇒ Array<Models::Storage>
readonly
Storage pools.
-
#subscription ⇒ Hash?
readonly
Subscription info (status, level, productname).
-
#swap_total ⇒ Integer?
readonly
Total swap in bytes.
-
#swap_used ⇒ Integer?
readonly
Swap used in bytes.
-
#tasks ⇒ Array
readonly
Recent task history entries.
-
#time_info ⇒ Hash?
readonly
Time configuration (timezone, localtime, time).
-
#updates ⇒ Array<Hash>
readonly
Available updates.
-
#updates_available ⇒ Integer
readonly
Number of available updates.
-
#uptime ⇒ Integer?
readonly
Uptime in seconds.
-
#version ⇒ String?
readonly
Proxmox version (e.g., “8.3.2”).
Instance Method Summary collapse
-
#guests_total ⇒ Integer
Returns total guest count (VMs + containers).
-
#initialize(attrs = {}) ⇒ Node
constructor
Creates a new Node model from attributes.
-
#offline? ⇒ Boolean
Checks if the node is offline.
-
#online? ⇒ Boolean
Checks if the node is online.
Constructor Details
#initialize(attrs = {}) ⇒ Node
Creates a new Node model from attributes.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/pvectl/models/node.rb', line 133 def initialize(attrs = {}) super(attrs) @name = @attributes[:name] || @attributes[:node] @status = @attributes[:status] @cpu = @attributes[:cpu] @maxcpu = @attributes[:maxcpu] @mem = @attributes[:mem] @maxmem = @attributes[:maxmem] @disk = @attributes[:disk] @maxdisk = @attributes[:maxdisk] @uptime = @attributes[:uptime] @level = @attributes[:level] @version = @attributes[:version] @kernel = @attributes[:kernel] @loadavg = @attributes[:loadavg] @swap_used = @attributes[:swap_used] @swap_total = @attributes[:swap_total] @guests_vms = @attributes[:guests_vms] || 0 @guests_cts = @attributes[:guests_cts] || 0 @ip = @attributes[:ip] # Extended attributes for describe @cpuinfo = @attributes[:cpuinfo] @boot_info = @attributes[:boot_info] @rootfs = @attributes[:rootfs] @subscription = @attributes[:subscription] @dns = @attributes[:dns] @time_info = @attributes[:time_info] @network_interfaces = @attributes[:network_interfaces] || [] @services = @attributes[:services] || [] @storage_pools = @attributes[:storage_pools] || [] @physical_disks = @attributes[:physical_disks] || [] @qemu_cpu_models = @attributes[:qemu_cpu_models] || [] @qemu_machines = @attributes[:qemu_machines] || [] @updates_available = @attributes[:updates_available] || 0 @updates = @attributes[:updates] || [] @offline_note = @attributes[:offline_note] @firewall = @attributes[:firewall] @tasks = @attributes[:tasks] || [] end |
Instance Attribute Details
#boot_info ⇒ Hash? (readonly)
Returns boot info (mode: efi/bios).
83 84 85 |
# File 'lib/pvectl/models/node.rb', line 83 def boot_info @boot_info end |
#cpu ⇒ Float? (readonly)
Returns CPU usage (0-1 scale).
31 32 33 |
# File 'lib/pvectl/models/node.rb', line 31 def cpu @cpu end |
#cpuinfo ⇒ Hash? (readonly)
Extended attributes for describe command
80 81 82 |
# File 'lib/pvectl/models/node.rb', line 80 def cpuinfo @cpuinfo end |
#disk ⇒ Integer? (readonly)
Returns local disk used in bytes.
43 44 45 |
# File 'lib/pvectl/models/node.rb', line 43 def disk @disk end |
#dns ⇒ Hash? (readonly)
Returns DNS configuration (search, dns1, dns2, dns3).
92 93 94 |
# File 'lib/pvectl/models/node.rb', line 92 def dns @dns end |
#firewall ⇒ Hash? (readonly)
Returns firewall configuration data.
125 126 127 |
# File 'lib/pvectl/models/node.rb', line 125 def firewall @firewall end |
#guests_cts ⇒ Integer (readonly)
Returns number of containers on this node.
73 74 75 |
# File 'lib/pvectl/models/node.rb', line 73 def guests_cts @guests_cts end |
#guests_vms ⇒ Integer (readonly)
Returns number of VMs on this node.
70 71 72 |
# File 'lib/pvectl/models/node.rb', line 70 def guests_vms @guests_vms end |
#ip ⇒ String? (readonly)
Returns node IP address (from interface with gateway).
76 77 78 |
# File 'lib/pvectl/models/node.rb', line 76 def ip @ip end |
#kernel ⇒ String? (readonly)
Returns kernel version (e.g., “6.8.12-1-pve”).
58 59 60 |
# File 'lib/pvectl/models/node.rb', line 58 def kernel @kernel end |
#level ⇒ String? (readonly)
Returns subscription level (c=community, b=basic, etc.).
52 53 54 |
# File 'lib/pvectl/models/node.rb', line 52 def level @level end |
#loadavg ⇒ Array<Float>? (readonly)
Returns load averages [1min, 5min, 15min].
61 62 63 |
# File 'lib/pvectl/models/node.rb', line 61 def loadavg @loadavg end |
#maxcpu ⇒ Integer? (readonly)
Returns total CPU cores.
34 35 36 |
# File 'lib/pvectl/models/node.rb', line 34 def maxcpu @maxcpu end |
#maxdisk ⇒ Integer? (readonly)
Returns total local disk in bytes.
46 47 48 |
# File 'lib/pvectl/models/node.rb', line 46 def maxdisk @maxdisk end |
#maxmem ⇒ Integer? (readonly)
Returns total memory in bytes.
40 41 42 |
# File 'lib/pvectl/models/node.rb', line 40 def maxmem @maxmem end |
#mem ⇒ Integer? (readonly)
Returns memory used in bytes.
37 38 39 |
# File 'lib/pvectl/models/node.rb', line 37 def mem @mem end |
#name ⇒ String (readonly)
Returns node name.
25 26 27 |
# File 'lib/pvectl/models/node.rb', line 25 def name @name end |
#network_interfaces ⇒ Array<Hash> (readonly)
Returns network interfaces.
98 99 100 |
# File 'lib/pvectl/models/node.rb', line 98 def network_interfaces @network_interfaces end |
#offline_note ⇒ String? (readonly)
Returns offline note message.
122 123 124 |
# File 'lib/pvectl/models/node.rb', line 122 def offline_note @offline_note end |
#physical_disks ⇒ Array<Hash> (readonly)
Returns physical disks.
107 108 109 |
# File 'lib/pvectl/models/node.rb', line 107 def physical_disks @physical_disks end |
#qemu_cpu_models ⇒ Array<Hash> (readonly)
Returns QEMU CPU models.
110 111 112 |
# File 'lib/pvectl/models/node.rb', line 110 def qemu_cpu_models @qemu_cpu_models end |
#qemu_machines ⇒ Array<Hash> (readonly)
Returns QEMU machine types.
113 114 115 |
# File 'lib/pvectl/models/node.rb', line 113 def qemu_machines @qemu_machines end |
#rootfs ⇒ Hash? (readonly)
Returns root filesystem (used, total, free).
86 87 88 |
# File 'lib/pvectl/models/node.rb', line 86 def rootfs @rootfs end |
#services ⇒ Array<Hash> (readonly)
Returns system services.
101 102 103 |
# File 'lib/pvectl/models/node.rb', line 101 def services @services end |
#status ⇒ String (readonly)
Returns node status (online/offline).
28 29 30 |
# File 'lib/pvectl/models/node.rb', line 28 def status @status end |
#storage_pools ⇒ Array<Models::Storage> (readonly)
Returns storage pools.
104 105 106 |
# File 'lib/pvectl/models/node.rb', line 104 def storage_pools @storage_pools end |
#subscription ⇒ Hash? (readonly)
Returns subscription info (status, level, productname).
89 90 91 |
# File 'lib/pvectl/models/node.rb', line 89 def subscription @subscription end |
#swap_total ⇒ Integer? (readonly)
Returns total swap in bytes.
67 68 69 |
# File 'lib/pvectl/models/node.rb', line 67 def swap_total @swap_total end |
#swap_used ⇒ Integer? (readonly)
Returns swap used in bytes.
64 65 66 |
# File 'lib/pvectl/models/node.rb', line 64 def swap_used @swap_used end |
#tasks ⇒ Array (readonly)
Returns recent task history entries.
128 129 130 |
# File 'lib/pvectl/models/node.rb', line 128 def tasks @tasks end |
#time_info ⇒ Hash? (readonly)
Returns time configuration (timezone, localtime, time).
95 96 97 |
# File 'lib/pvectl/models/node.rb', line 95 def time_info @time_info end |
#updates ⇒ Array<Hash> (readonly)
Returns available updates.
119 120 121 |
# File 'lib/pvectl/models/node.rb', line 119 def updates @updates end |
#updates_available ⇒ Integer (readonly)
Returns number of available updates.
116 117 118 |
# File 'lib/pvectl/models/node.rb', line 116 def updates_available @updates_available end |
#uptime ⇒ Integer? (readonly)
Returns uptime in seconds.
49 50 51 |
# File 'lib/pvectl/models/node.rb', line 49 def uptime @uptime end |
#version ⇒ String? (readonly)
Returns Proxmox version (e.g., “8.3.2”).
55 56 57 |
# File 'lib/pvectl/models/node.rb', line 55 def version @version end |
Instance Method Details
#guests_total ⇒ Integer
Returns total guest count (VMs + containers).
190 191 192 |
# File 'lib/pvectl/models/node.rb', line 190 def guests_total guests_vms + guests_cts end |
#offline? ⇒ Boolean
Checks if the node is offline.
183 184 185 |
# File 'lib/pvectl/models/node.rb', line 183 def offline? !online? end |
#online? ⇒ Boolean
Checks if the node is online.
176 177 178 |
# File 'lib/pvectl/models/node.rb', line 176 def online? status == "online" end |