Class: Virt::Volume
Direct Known Subclasses
Instance Attribute Summary collapse
-
#allocated_size ⇒ Object
readonly
Returns the value of attribute allocated_size.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#xml_desc ⇒ Object
readonly
Returns the value of attribute xml_desc.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(options = {}) ⇒ Volume
constructor
A new instance of Volume.
- #new? ⇒ Boolean
- #path ⇒ Object
- #save ⇒ Object
Methods included from Util
Constructor Details
#initialize(options = {}) ⇒ Volume
Returns a new instance of Volume.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/virt/volume.rb', line 6 def initialize = {} @connection = Virt.connection self.name = [:name] || raise("Volume requires a name") # If our volume already exists, we ignore the provided options and defaults @pool = [:pool].nil? ? default_pool : @connection.host.storage_pool([:pool]) fetch_volume @type ||= [:type] || default_type @allocated_size ||= [:allocated_size] || default_allocated_size @template_path ||= [:template_path] || default_template_path @size ||= [:size] || default_size end |
Instance Attribute Details
#allocated_size ⇒ Object (readonly)
Returns the value of attribute allocated_size.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def allocated_size @allocated_size end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def key @key end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def name @name end |
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def pool @pool end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def size @size end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def template_path @template_path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def type @type end |
#xml_desc ⇒ Object (readonly)
Returns the value of attribute xml_desc.
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def xml_desc @xml_desc end |
Instance Method Details
#destroy ⇒ Object
30 31 32 33 34 35 |
# File 'lib/virt/volume.rb', line 30 def destroy return true if new? @vol.delete fetch_volume new? end |
#new? ⇒ Boolean
18 19 20 |
# File 'lib/virt/volume.rb', line 18 def new? @vol.nil? end |
#path ⇒ Object
37 |
# File 'lib/virt/volume.rb', line 37 def path; end |
#save ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/virt/volume.rb', line 22 def save raise "volume already exists, can't save" unless new? #validations #update? @vol=pool.create_vol(self) !new? end |