Class: Pvectl::Models::Volume
Overview
Represents a virtual disk (volume) attached to a VM or container.
Volumes can originate from two data sources:
-
VM/CT config (has name like “scsi0”, parsed from config values)
-
Storage content API (has volid, content type)
Instance Attribute Summary collapse
-
#backup ⇒ Integer?
readonly
Backup inclusion flag (1/0).
-
#cache ⇒ String?
readonly
Cache mode (e.g., “writeback”, “none”).
-
#content ⇒ String?
readonly
Storage content type (e.g., “images”, “rootdir”).
-
#discard ⇒ String?
readonly
Discard mode (e.g., “on”, “ignore”).
-
#format ⇒ String?
readonly
Disk format (e.g., “raw”, “qcow2”).
-
#iothread ⇒ Integer?
readonly
IO thread flag (1/0).
-
#mp ⇒ String?
readonly
Mount point path (containers only).
-
#name ⇒ String?
readonly
Disk name from config (e.g., “scsi0”, “rootfs”).
-
#node ⇒ String?
readonly
Proxmox node name.
-
#resource_id ⇒ Integer?
readonly
VMID or CTID.
-
#resource_type ⇒ String?
readonly
Resource type (“vm” or “ct”).
-
#size ⇒ String?
readonly
Volume size (e.g., “32G”).
-
#ssd ⇒ Integer?
readonly
SSD emulation flag (1/0).
-
#storage ⇒ String?
readonly
Storage name (e.g., “local-lvm”).
-
#volid ⇒ String?
readonly
Full volume identifier (e.g., “local-lvm:vm-100-disk-0”).
-
#volume_id ⇒ String?
readonly
Volume identifier within storage (e.g., “vm-100-disk-0”).
Instance Method Summary collapse
-
#container? ⇒ Boolean
Checks if volume belongs to a container.
-
#initialize(attrs = {}) ⇒ Volume
constructor
Creates a new Volume instance.
-
#vm? ⇒ Boolean
Checks if volume belongs to a VM.
Constructor Details
#initialize(attrs = {}) ⇒ Volume
Creates a new Volume instance.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/pvectl/models/volume.rb', line 87 def initialize(attrs = {}) super @name = attributes[:name] @storage = attributes[:storage] @volume_id = attributes[:volume_id] @volid = attributes[:volid] || construct_volid @size = attributes[:size] @format = attributes[:format] @resource_type = attributes[:resource_type] @resource_id = attributes[:resource_id] @node = attributes[:node] @content = attributes[:content] @cache = attributes[:cache] @discard = attributes[:discard] @ssd = attributes[:ssd] @iothread = attributes[:iothread] @backup = attributes[:backup] @mp = attributes[:mp] end |
Instance Attribute Details
#backup ⇒ Integer? (readonly)
Returns backup inclusion flag (1/0).
63 64 65 |
# File 'lib/pvectl/models/volume.rb', line 63 def backup @backup end |
#cache ⇒ String? (readonly)
Returns cache mode (e.g., “writeback”, “none”).
51 52 53 |
# File 'lib/pvectl/models/volume.rb', line 51 def cache @cache end |
#content ⇒ String? (readonly)
Returns storage content type (e.g., “images”, “rootdir”).
48 49 50 |
# File 'lib/pvectl/models/volume.rb', line 48 def content @content end |
#discard ⇒ String? (readonly)
Returns discard mode (e.g., “on”, “ignore”).
54 55 56 |
# File 'lib/pvectl/models/volume.rb', line 54 def discard @discard end |
#format ⇒ String? (readonly)
Returns disk format (e.g., “raw”, “qcow2”).
36 37 38 |
# File 'lib/pvectl/models/volume.rb', line 36 def format @format end |
#iothread ⇒ Integer? (readonly)
Returns IO thread flag (1/0).
60 61 62 |
# File 'lib/pvectl/models/volume.rb', line 60 def iothread @iothread end |
#mp ⇒ String? (readonly)
Returns mount point path (containers only).
66 67 68 |
# File 'lib/pvectl/models/volume.rb', line 66 def mp @mp end |
#name ⇒ String? (readonly)
Returns disk name from config (e.g., “scsi0”, “rootfs”).
21 22 23 |
# File 'lib/pvectl/models/volume.rb', line 21 def name @name end |
#node ⇒ String? (readonly)
Returns Proxmox node name.
45 46 47 |
# File 'lib/pvectl/models/volume.rb', line 45 def node @node end |
#resource_id ⇒ Integer? (readonly)
Returns VMID or CTID.
42 43 44 |
# File 'lib/pvectl/models/volume.rb', line 42 def resource_id @resource_id end |
#resource_type ⇒ String? (readonly)
Returns resource type (“vm” or “ct”).
39 40 41 |
# File 'lib/pvectl/models/volume.rb', line 39 def resource_type @resource_type end |
#size ⇒ String? (readonly)
Returns volume size (e.g., “32G”).
33 34 35 |
# File 'lib/pvectl/models/volume.rb', line 33 def size @size end |
#ssd ⇒ Integer? (readonly)
Returns SSD emulation flag (1/0).
57 58 59 |
# File 'lib/pvectl/models/volume.rb', line 57 def ssd @ssd end |
#storage ⇒ String? (readonly)
Returns storage name (e.g., “local-lvm”).
24 25 26 |
# File 'lib/pvectl/models/volume.rb', line 24 def storage @storage end |
#volid ⇒ String? (readonly)
Returns full volume identifier (e.g., “local-lvm:vm-100-disk-0”).
30 31 32 |
# File 'lib/pvectl/models/volume.rb', line 30 def volid @volid end |
#volume_id ⇒ String? (readonly)
Returns volume identifier within storage (e.g., “vm-100-disk-0”).
27 28 29 |
# File 'lib/pvectl/models/volume.rb', line 27 def volume_id @volume_id end |
Instance Method Details
#container? ⇒ Boolean
Checks if volume belongs to a container.
117 118 119 |
# File 'lib/pvectl/models/volume.rb', line 117 def container? resource_type == "ct" end |
#vm? ⇒ Boolean
Checks if volume belongs to a VM.
110 111 112 |
# File 'lib/pvectl/models/volume.rb', line 110 def vm? resource_type == "vm" end |