Class: Fog::Proxmox::Compute::Volume

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/proxmox/compute/models/volume.rb

Overview

class Volume model: pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/node/storage/storage/content/volume size is in bytes

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Volume

Returns a new instance of Volume.



45
46
47
48
49
50
51
52
# File 'lib/fog/proxmox/compute/models/volume.rb', line 45

def initialize(new_attributes = {})
  prepare_service_value(new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('storage_id', attributes, new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('volid', attributes, new_attributes)
  requires :node_id, :storage_id, :volid
  super(new_attributes)
end

Instance Method Details

#destroyObject



54
55
56
# File 'lib/fog/proxmox/compute/models/volume.rb', line 54

def destroy
  service.delete_volume(node_id, storage_id, volid)
end

#restore(vmid, options = {}) ⇒ Object



58
59
60
# File 'lib/fog/proxmox/compute/models/volume.rb', line 58

def restore(vmid, options = {})
  service.create_server(node_id, options.merge(archive: volid, storage: storage_id, vmid: vmid))
end

#template?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/fog/proxmox/compute/models/volume.rb', line 62

def template?
  Fog::Proxmox::DiskHelper.template?(volid)
end