Class: OVIRT::Volume
- Inherits:
-
BaseObject
- Object
- BaseObject
- OVIRT::Volume
- Defined in:
- lib/ovirt/volume.rb
Instance Attribute Summary collapse
-
#bootable ⇒ Object
readonly
Returns the value of attribute bootable.
-
#disk_type ⇒ Object
readonly
Returns the value of attribute disk_type.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#quota ⇒ Object
readonly
Returns the value of attribute quota.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#sparse ⇒ Object
readonly
Returns the value of attribute sparse.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#storage_domain ⇒ Object
readonly
Returns the value of attribute storage_domain.
-
#vm ⇒ Object
readonly
Returns the value of attribute vm.
Attributes inherited from BaseObject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, xml) ⇒ Volume
constructor
A new instance of Volume.
- #parse_xml_attributes!(xml) ⇒ Object
Methods inherited from BaseObject
Constructor Details
#initialize(client, xml) ⇒ Volume
Returns a new instance of Volume.
6 7 8 9 10 |
# File 'lib/ovirt/volume.rb', line 6 def initialize(client, xml) super(client, xml[:id], xml[:href], (xml/'name').first.text) parse_xml_attributes!(xml) self end |
Instance Attribute Details
#bootable ⇒ Object (readonly)
Returns the value of attribute bootable.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def bootable @bootable end |
#disk_type ⇒ Object (readonly)
Returns the value of attribute disk_type.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def disk_type @disk_type end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def format @format end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def interface @interface end |
#quota ⇒ Object (readonly)
Returns the value of attribute quota.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def quota @quota end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def size @size end |
#sparse ⇒ Object (readonly)
Returns the value of attribute sparse.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def sparse @sparse end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def status @status end |
#storage_domain ⇒ Object (readonly)
Returns the value of attribute storage_domain.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def storage_domain @storage_domain end |
#vm ⇒ Object (readonly)
Returns the value of attribute vm.
4 5 6 |
# File 'lib/ovirt/volume.rb', line 4 def vm @vm end |
Class Method Details
.to_xml(storage_domain_id, opts = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ovirt/volume.rb', line 12 def self.to_xml(storage_domain_id,opts={}) builder = Nokogiri::XML::Builder.new do disk_{ storage_domains_{ storage_domain_(:id => storage_domain_id) } size_(opts[:size] || 8589934592) type_(opts[:type] || 'data') bootable_(opts[:bootable] || 'true') interface_(opts[:interface] || 'virtio') format_(opts[:format] || 'cow') sparse_(opts[:sparse] || 'true') if opts[:quota] quota_( :id => opts[:quota]) end } end Nokogiri::XML(builder.to_xml).root.to_s end |
Instance Method Details
#parse_xml_attributes!(xml) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ovirt/volume.rb', line 32 def parse_xml_attributes!(xml) @storage_domain = (xml/'storage_domains/storage_domain').first[:id] @size = (xml/'size').first.text @disk_type = ((xml/'type').first.text rescue nil) @bootable = (xml/'bootable').first.text @interface = (xml/'interface').first.text @format = (xml/'format').first.text @sparse = (xml/'sparse').first.text @status = ((xml/'status').first.text rescue nil) @status ||= ((xml/'status/state').first.text rescue nil) @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil @quota = ((xml/'quota').first[:id] rescue nil) end |