Class: Pvectl::Models::PhysicalDisk
- Defined in:
- lib/pvectl/models/physical_disk.rb
Overview
Represents a physical disk (block device) on a Proxmox node.
PhysicalDisk instances are created from the Proxmox API responses and provide domain methods for disk analysis.
Instance Attribute Summary collapse
-
#devpath ⇒ String?
readonly
Device path (e.g., “/dev/sda”).
-
#gpt ⇒ Integer?
readonly
Whether disk has a GPT partition table (1 = yes, 0 = no).
-
#health ⇒ String?
readonly
SMART health status (e.g., “PASSED”, “FAILED”).
-
#model ⇒ String?
readonly
Disk model name.
-
#mounted ⇒ Integer?
readonly
Whether disk is mounted (1 = yes, 0 = no).
-
#node ⇒ String?
readonly
Proxmox node name this disk belongs to.
-
#osdid ⇒ Integer?
readonly
Ceph OSD ID (-1 if not an OSD).
-
#parent ⇒ String?
readonly
Parent device path (e.g., “/dev/sda” for partition “/dev/sda1”).
-
#serial ⇒ String?
readonly
Disk serial number.
-
#size ⇒ Integer?
readonly
Disk size in bytes.
-
#smart_attributes ⇒ Array<Hash>?
readonly
ATA SMART attributes array.
-
#smart_text ⇒ String?
readonly
Raw SMART text (NVMe/SAS).
-
#smart_type ⇒ String?
readonly
SMART type (“ata” or “text”).
-
#type ⇒ String?
readonly
Disk type (“ssd”, “hdd”, etc.).
-
#used ⇒ String?
readonly
How the disk is used (e.g., “LVM”, “ZFS”, “ext4”).
-
#vendor ⇒ String?
readonly
Disk vendor.
-
#wearout ⇒ Integer?
readonly
Disk wearout percentage.
-
#wwn ⇒ String?
readonly
World Wide Name identifier.
Instance Method Summary collapse
-
#gpt? ⇒ Boolean
Checks if disk has a GPT partition table.
-
#healthy? ⇒ Boolean
Checks if disk SMART health status is PASSED.
-
#initialize(attrs = {}) ⇒ PhysicalDisk
constructor
Creates a new PhysicalDisk instance.
-
#merge_smart(smart_data) ⇒ void
Merges SMART data into the model.
-
#mounted? ⇒ Boolean
Checks if disk is currently mounted.
-
#osd? ⇒ Boolean
Checks if disk is a Ceph OSD.
-
#size_gb ⇒ Float?
Returns disk size in gigabytes.
-
#ssd? ⇒ Boolean
Checks if disk is an SSD.
Constructor Details
#initialize(attrs = {}) ⇒ PhysicalDisk
Creates a new PhysicalDisk instance.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/pvectl/models/physical_disk.rb', line 107 def initialize(attrs = {}) super @devpath = attributes[:devpath] @model = attributes[:model] @size = attributes[:size] @type = attributes[:type] @health = attributes[:health] @serial = attributes[:serial] @vendor = attributes[:vendor] @node = attributes[:node] @gpt = attributes[:gpt] @mounted = attributes[:mounted] @used = attributes[:used] @wwn = attributes[:wwn] @osdid = attributes[:osdid] @parent = attributes[:parent] @smart_type = attributes[:smart_type] @smart_attributes = attributes[:smart_attributes] @smart_text = attributes[:smart_text] @wearout = attributes[:wearout] end |
Instance Attribute Details
#devpath ⇒ String? (readonly)
Returns device path (e.g., “/dev/sda”).
33 34 35 |
# File 'lib/pvectl/models/physical_disk.rb', line 33 def devpath @devpath end |
#gpt ⇒ Integer? (readonly)
Returns whether disk has a GPT partition table (1 = yes, 0 = no).
57 58 59 |
# File 'lib/pvectl/models/physical_disk.rb', line 57 def gpt @gpt end |
#health ⇒ String? (readonly)
Returns SMART health status (e.g., “PASSED”, “FAILED”).
45 46 47 |
# File 'lib/pvectl/models/physical_disk.rb', line 45 def health @health end |
#model ⇒ String? (readonly)
Returns disk model name.
36 37 38 |
# File 'lib/pvectl/models/physical_disk.rb', line 36 def model @model end |
#mounted ⇒ Integer? (readonly)
Returns whether disk is mounted (1 = yes, 0 = no).
60 61 62 |
# File 'lib/pvectl/models/physical_disk.rb', line 60 def mounted @mounted end |
#node ⇒ String? (readonly)
Returns Proxmox node name this disk belongs to.
54 55 56 |
# File 'lib/pvectl/models/physical_disk.rb', line 54 def node @node end |
#osdid ⇒ Integer? (readonly)
Returns Ceph OSD ID (-1 if not an OSD).
69 70 71 |
# File 'lib/pvectl/models/physical_disk.rb', line 69 def osdid @osdid end |
#parent ⇒ String? (readonly)
Returns parent device path (e.g., “/dev/sda” for partition “/dev/sda1”).
72 73 74 |
# File 'lib/pvectl/models/physical_disk.rb', line 72 def parent @parent end |
#serial ⇒ String? (readonly)
Returns disk serial number.
48 49 50 |
# File 'lib/pvectl/models/physical_disk.rb', line 48 def serial @serial end |
#size ⇒ Integer? (readonly)
Returns disk size in bytes.
39 40 41 |
# File 'lib/pvectl/models/physical_disk.rb', line 39 def size @size end |
#smart_attributes ⇒ Array<Hash>? (readonly)
Returns ATA SMART attributes array.
78 79 80 |
# File 'lib/pvectl/models/physical_disk.rb', line 78 def smart_attributes @smart_attributes end |
#smart_text ⇒ String? (readonly)
Returns raw SMART text (NVMe/SAS).
81 82 83 |
# File 'lib/pvectl/models/physical_disk.rb', line 81 def smart_text @smart_text end |
#smart_type ⇒ String? (readonly)
Returns SMART type (“ata” or “text”).
75 76 77 |
# File 'lib/pvectl/models/physical_disk.rb', line 75 def smart_type @smart_type end |
#type ⇒ String? (readonly)
Returns disk type (“ssd”, “hdd”, etc.).
42 43 44 |
# File 'lib/pvectl/models/physical_disk.rb', line 42 def type @type end |
#used ⇒ String? (readonly)
Returns how the disk is used (e.g., “LVM”, “ZFS”, “ext4”).
63 64 65 |
# File 'lib/pvectl/models/physical_disk.rb', line 63 def used @used end |
#vendor ⇒ String? (readonly)
Returns disk vendor.
51 52 53 |
# File 'lib/pvectl/models/physical_disk.rb', line 51 def vendor @vendor end |
#wearout ⇒ Integer? (readonly)
Returns disk wearout percentage.
84 85 86 |
# File 'lib/pvectl/models/physical_disk.rb', line 84 def wearout @wearout end |
#wwn ⇒ String? (readonly)
Returns World Wide Name identifier.
66 67 68 |
# File 'lib/pvectl/models/physical_disk.rb', line 66 def wwn @wwn end |
Instance Method Details
#gpt? ⇒ Boolean
Checks if disk has a GPT partition table.
159 160 161 |
# File 'lib/pvectl/models/physical_disk.rb', line 159 def gpt? gpt == 1 end |
#healthy? ⇒ Boolean
Checks if disk SMART health status is PASSED.
145 146 147 |
# File 'lib/pvectl/models/physical_disk.rb', line 145 def healthy? health == "PASSED" end |
#merge_smart(smart_data) ⇒ void
This method returns an undefined value.
Merges SMART data into the model.
Called after initial construction when SMART data is fetched separately from the disk list endpoint.
184 185 186 187 188 189 190 |
# File 'lib/pvectl/models/physical_disk.rb', line 184 def merge_smart(smart_data) @smart_type = smart_data[:type] @smart_attributes = smart_data[:attributes] @smart_text = smart_data[:text] @wearout = smart_data[:wearout] @health = smart_data[:health] if smart_data[:health] end |
#mounted? ⇒ Boolean
Checks if disk is currently mounted.
166 167 168 |
# File 'lib/pvectl/models/physical_disk.rb', line 166 def mounted? mounted == 1 end |
#osd? ⇒ Boolean
Checks if disk is a Ceph OSD.
173 174 175 |
# File 'lib/pvectl/models/physical_disk.rb', line 173 def osd? !osdid.nil? && osdid >= 0 end |
#size_gb ⇒ Float?
Returns disk size in gigabytes.
136 137 138 139 140 |
# File 'lib/pvectl/models/physical_disk.rb', line 136 def size_gb return nil if size.nil? (size.to_f / 1024 / 1024 / 1024).round(1) end |
#ssd? ⇒ Boolean
Checks if disk is an SSD.
152 153 154 |
# File 'lib/pvectl/models/physical_disk.rb', line 152 def ssd? type == "ssd" end |