Class: Fog::Compute::Libvirt::Volume
- Includes:
- Fog::Compute::LibvirtUtil
- Defined in:
- lib/fog/libvirt/models/compute/volume.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Attributes inherited from Model
Instance Method Summary collapse
-
#clone(name) ⇒ Object
Clones this volume to the name provided.
-
#destroy ⇒ Object
Destroy a volume.
-
#initialize(attributes = { }) ⇒ Volume
constructor
Can be created by passing in :xml => “<xml to create volume>” A volume always belongs to a pool, :pool_name => “<name of pool>”.
-
#save ⇒ Object
Takes a pool and either :xml or other settings.
-
#wipe ⇒ Object
Wipes a volume , zeroes disk.
Methods included from Fog::Compute::LibvirtUtil
#randomized_name, #to_xml, #xml_element, #xml_elements
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = { }) ⇒ Volume
Can be created by passing in :xml => “<xml to create volume>” A volume always belongs to a pool, :pool_name => “<name of pool>”
26 27 28 29 30 31 32 33 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 26 def initialize(attributes={ }) @xml = attributes.delete(:xml) super(defaults.merge(attributes)) # We need a connection to calculate the pool_name # This is why we do this after super self.pool_name ||= default_pool_name end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
10 11 12 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 10 def xml @xml end |
Instance Method Details
#clone(name) ⇒ Object
Clones this volume to the name provided
55 56 57 58 59 60 61 62 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 55 def clone(name) new_volume = self.dup new_volume.key = nil new_volume.name = name new_volume.save new_volume.reload end |
#destroy ⇒ Object
Destroy a volume
45 46 47 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 45 def destroy connection.volume_action key, :delete end |
#save ⇒ Object
Takes a pool and either :xml or other settings
36 37 38 39 40 41 42 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 36 def save requires :pool_name raise Fog::Errors::Error.new('Reserving an existing volume may create a duplicate') if key @xml ||= to_xml self.path = connection.create_volume(pool_name, xml).path end |
#wipe ⇒ Object
Wipes a volume , zeroes disk
50 51 52 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 50 def wipe connection.volume_action key, :wipe end |