Class: Virt::Volume
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) allocated_size
readonly
Returns the value of attribute allocated_size.
-
- (Object) key
readonly
Returns the value of attribute key.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) pool
readonly
Returns the value of attribute pool.
-
- (Object) size
readonly
Returns the value of attribute size.
-
- (Object) template_path
readonly
Returns the value of attribute template_path.
-
- (Object) type
readonly
Returns the value of attribute type.
-
- (Object) xml_desc
readonly
Returns the value of attribute xml_desc.
Instance Method Summary (collapse)
- - (Object) destroy
-
- (Volume) initialize(options = {})
constructor
A new instance of Volume.
- - (Boolean) new?
- - (Object) path
- - (Object) save
Methods included from Util
Constructor Details
- (Volume) initialize(options = {})
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
- (Object) allocated_size (readonly)
Returns the value of attribute allocated_size
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def allocated_size @allocated_size end |
- (Object) key (readonly)
Returns the value of attribute key
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def key @key end |
- (Object) name
Returns the value of attribute name
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def name @name end |
- (Object) pool (readonly)
Returns the value of attribute pool
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def pool @pool end |
- (Object) size (readonly)
Returns the value of attribute size
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def size @size end |
- (Object) template_path (readonly)
Returns the value of attribute template_path
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def template_path @template_path end |
- (Object) type (readonly)
Returns the value of attribute type
4 5 6 |
# File 'lib/virt/volume.rb', line 4 def type @type end |
- (Object) xml_desc (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
- (Object) destroy
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 |
- (Boolean) new?
18 19 20 |
# File 'lib/virt/volume.rb', line 18 def new? @vol.nil? end |
- (Object) path
37 |
# File 'lib/virt/volume.rb', line 37 def path; end |
- (Object) save
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 |