Class: Pvectl::Models::Snapshot
- Defined in:
- lib/pvectl/models/snapshot.rb
Overview
Represents a VM/container snapshot in Proxmox.
A snapshot captures the state of a VM or container at a specific point in time, including optionally the VM memory state (vmstate).
Instance Attribute Summary collapse
-
#description ⇒ String?
readonly
Optional description of the snapshot.
-
#name ⇒ String
readonly
Snapshot name/identifier.
-
#node ⇒ String?
readonly
Node name where the VM/container resides.
-
#parent ⇒ String?
readonly
Parent snapshot name for snapshot trees.
-
#resource_type ⇒ Symbol?
readonly
Resource type (:qemu for VM, :lxc for container).
-
#snaptime ⇒ Integer?
readonly
Unix timestamp when snapshot was created.
-
#vmid ⇒ Integer?
readonly
VM/container ID this snapshot belongs to.
-
#vmstate ⇒ Integer?
readonly
1 if VM memory state was saved, 0 or nil otherwise.
Instance Method Summary collapse
-
#container? ⇒ Boolean
Checks if the snapshot belongs to a container (LXC).
-
#created_at ⇒ Time?
Returns the snapshot creation time as a Time object.
-
#has_vmstate? ⇒ Boolean
Checks if the snapshot includes VM memory state.
-
#initialize(attrs = {}) ⇒ Snapshot
constructor
Creates a new Snapshot instance.
-
#vm? ⇒ Boolean
Checks if the snapshot belongs to a VM (QEMU).
Constructor Details
#initialize(attrs = {}) ⇒ Snapshot
Creates a new Snapshot instance.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pvectl/models/snapshot.rb', line 58 def initialize(attrs = {}) super @name = attributes[:name] @snaptime = attributes[:snaptime] @description = attributes[:description] @vmstate = attributes[:vmstate] @parent = attributes[:parent] @vmid = attributes[:vmid] @node = attributes[:node] @resource_type = attributes[:resource_type] end |
Instance Attribute Details
#description ⇒ String? (readonly)
Returns optional description of the snapshot.
30 31 32 |
# File 'lib/pvectl/models/snapshot.rb', line 30 def description @description end |
#name ⇒ String (readonly)
Returns snapshot name/identifier.
24 25 26 |
# File 'lib/pvectl/models/snapshot.rb', line 24 def name @name end |
#node ⇒ String? (readonly)
Returns node name where the VM/container resides.
42 43 44 |
# File 'lib/pvectl/models/snapshot.rb', line 42 def node @node end |
#parent ⇒ String? (readonly)
Returns parent snapshot name for snapshot trees.
36 37 38 |
# File 'lib/pvectl/models/snapshot.rb', line 36 def parent @parent end |
#resource_type ⇒ Symbol? (readonly)
Returns resource type (:qemu for VM, :lxc for container).
45 46 47 |
# File 'lib/pvectl/models/snapshot.rb', line 45 def resource_type @resource_type end |
#snaptime ⇒ Integer? (readonly)
Returns Unix timestamp when snapshot was created.
27 28 29 |
# File 'lib/pvectl/models/snapshot.rb', line 27 def snaptime @snaptime end |
#vmid ⇒ Integer? (readonly)
Returns VM/container ID this snapshot belongs to.
39 40 41 |
# File 'lib/pvectl/models/snapshot.rb', line 39 def vmid @vmid end |
#vmstate ⇒ Integer? (readonly)
Returns 1 if VM memory state was saved, 0 or nil otherwise.
33 34 35 |
# File 'lib/pvectl/models/snapshot.rb', line 33 def vmstate @vmstate end |
Instance Method Details
#container? ⇒ Boolean
Checks if the snapshot belongs to a container (LXC).
96 97 98 |
# File 'lib/pvectl/models/snapshot.rb', line 96 def container? resource_type == :lxc end |
#created_at ⇒ Time?
Returns the snapshot creation time as a Time object.
80 81 82 83 84 |
# File 'lib/pvectl/models/snapshot.rb', line 80 def created_at return nil if snaptime.nil? Time.at(snaptime) end |
#has_vmstate? ⇒ Boolean
Checks if the snapshot includes VM memory state.
73 74 75 |
# File 'lib/pvectl/models/snapshot.rb', line 73 def has_vmstate? vmstate == 1 end |
#vm? ⇒ Boolean
Checks if the snapshot belongs to a VM (QEMU).
89 90 91 |
# File 'lib/pvectl/models/snapshot.rb', line 89 def vm? resource_type == :qemu end |