Class: Pvectl::Presenters::Volume
- Defined in:
- lib/pvectl/presenters/volume.rb,
sig/pvectl/presenters/volume.rbs
Overview
Presenter for virtual disks (volumes) attached to VMs and containers.
Defines column layout and formatting for table output. Standard columns show node, resource type, ID, name, storage, size, and format. Wide columns add volume ID, cache, discard, SSD, iothread, and backup flags.
Instance Attribute Summary collapse
-
#volume ⇒ Models::Volume
readonly
The current volume being presented.
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 => Hash{String, String}}
Returns detailed description for describe command output.
-
#to_hash(model) ⇒ Hash{String => untyped}
Converts Volume model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts Volume model to table row values.
-
#volume_info_section ⇒ Hash{String => String}
Builds the Volume Info section hash.
Methods inherited from Base
#format_bytes, #format_firewall, #format_firewall_rules, #format_task_history, #resource, #tags_array, #tags_display, #template_display, #to_wide_row, #uptime_human, #wide_columns
Instance Attribute Details
#volume ⇒ Models::Volume (readonly)
Returns the current volume being presented.
107 108 109 |
# File 'lib/pvectl/presenters/volume.rb', line 107 def volume @volume end |
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for standard table output.
23 24 25 |
# File 'lib/pvectl/presenters/volume.rb', line 23 def columns %w[NODE RESOURCE ID NAME STORAGE SIZE FORMAT] end |
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
30 31 32 |
# File 'lib/pvectl/presenters/volume.rb', line 30 def extra_columns %w[VOLUME-ID CACHE DISCARD SSD IOTHREAD BACKUP] end |
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pvectl/presenters/volume.rb', line 57 def extra_values(model, **_context) @volume = model [ volume.volume_id || "-", volume.cache || "-", volume.discard || "-", volume.ssd&.to_s || "-", volume.iothread&.to_s || "-", volume.backup&.to_s || "-" ] end |
#to_description(model) ⇒ Hash{String => Hash{String, String}}
Returns detailed description for describe command output.
99 100 101 102 |
# File 'lib/pvectl/presenters/volume.rb', line 99 def to_description(model) @volume = model { "Volume Info" => volume_info_section } end |
#to_hash(model) ⇒ Hash{String => untyped}
Converts Volume model to hash for JSON/YAML output.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pvectl/presenters/volume.rb', line 73 def to_hash(model) @volume = model { "name" => volume.name, "storage" => volume.storage, "volume_id" => volume.volume_id, "volid" => volume.volid, "size" => volume.size, "format" => volume.format, "resource_type" => volume.resource_type, "resource_id" => volume.resource_id, "node" => volume.node, "content" => volume.content, "cache" => volume.cache, "discard" => volume.discard, "ssd" => volume.ssd, "iothread" => volume.iothread, "backup" => volume.backup, "mp" => volume.mp } end |
#to_row(model, **_context) ⇒ Array<String>
Converts Volume model to table row values.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pvectl/presenters/volume.rb', line 39 def to_row(model, **_context) @volume = model [ volume.node || "-", volume.resource_type || "-", volume.resource_id&.to_s || "-", volume.name || "-", volume.storage || "-", volume.size || "-", volume.format || "-" ] end |
#volume_info_section ⇒ Hash{String => String}
Builds the Volume Info section hash. Optional fields are only included when they have values.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/pvectl/presenters/volume.rb', line 113 def volume_info_section info = { "Name" => volume.name || "-", "Storage" => volume.storage || "-", "Volume ID" => volume.volume_id || "-", "Full Volume ID" => volume.volid || "-", "Size" => volume.size || "-", "Format" => volume.format || "-", "Resource Type" => volume.resource_type || "-", "Resource ID" => volume.resource_id&.to_s || "-", "Node" => volume.node || "-" } info["Content"] = volume.content if volume.content info["Cache"] = volume.cache if volume.cache info["Discard"] = volume.discard if volume.discard info["SSD"] = volume.ssd if volume.ssd info["IO Thread"] = volume.iothread if volume.iothread info["Backup"] = volume.backup if volume.backup info["Mount Point"] = volume.mp if volume.mp info end |