Class: Pvectl::Presenters::Volume
- Defined in:
- lib/pvectl/presenters/volume.rb
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 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.
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/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 |