Class: Pvectl::Presenters::Disk
- Defined in:
- lib/pvectl/presenters/disk.rb
Overview
Presenter for physical disks on Proxmox nodes.
Defines column layout and formatting for table output. Standard columns show device, model, size, type, health, and usage. Wide columns add serial, vendor, WWN, GPT, and mount status.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
-
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
-
#to_description(model) ⇒ Hash{String => Object}
Returns detailed description for describe command output.
-
#to_hash(model) ⇒ Hash
Converts PhysicalDisk model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts PhysicalDisk model to table row values.
Methods inherited from Base
#tags_array, #tags_display, #template_display, #to_wide_row, #uptime_human, #wide_columns
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for standard table output.
23 24 25 |
# File 'lib/pvectl/presenters/disk.rb', line 23 def columns %w[NODE DEVICE MODEL SIZE TYPE HEALTH USED] end |
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
30 31 32 |
# File 'lib/pvectl/presenters/disk.rb', line 30 def extra_columns %w[SERIAL VENDOR WWN GPT MOUNTED] end |
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pvectl/presenters/disk.rb', line 57 def extra_values(model, **_context) @disk = model [ disk.serial || "-", disk.vendor || "-", disk.wwn || "-", format_boolean(disk.gpt), format_boolean(disk.mounted) ] end |
#to_description(model) ⇒ Hash{String => Object}
Returns detailed description for describe command output.
95 96 97 98 99 100 |
# File 'lib/pvectl/presenters/disk.rb', line 95 def to_description(model) @disk = model result = { "Device Info" => device_info_section } result["SMART Attributes"] = smart_attributes_section if disk.smart_type result end |
#to_hash(model) ⇒ Hash
Converts PhysicalDisk model to hash for JSON/YAML output.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pvectl/presenters/disk.rb', line 72 def to_hash(model) @disk = model { "node" => disk.node, "device" => disk.devpath, "model" => disk.model, "size_bytes" => disk.size, "size_gb" => disk.size_gb, "type" => disk.type, "health" => disk.health, "used" => disk.used, "serial" => disk.serial, "vendor" => disk.vendor, "wwn" => disk.wwn, "gpt" => disk.gpt? || false, "mounted" => disk.mounted? || false } end |
#to_row(model, **_context) ⇒ Array<String>
Converts PhysicalDisk model to table row values.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pvectl/presenters/disk.rb', line 39 def to_row(model, **_context) @disk = model [ disk.node || "-", disk.devpath || "-", disk.model || "-", format_size, disk.type || "-", disk.health || "-", disk.used || "-" ] end |