class OVIRT::Volume

Attributes

bootable[R]
disk_type[R]
format[R]
interface[R]
size[R]
sparse[R]
status[R]
storage_domain[R]
vm[R]

Public Class Methods

new(client, xml) click to toggle source
# 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
to_xml(storage_domain_id,opts={}) click to toggle source
# 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')
    }
  end
  Nokogiri::XML(builder.to_xml).root.to_s
end

Public Instance Methods

parse_xml_attributes!(xml) click to toggle source
# File lib/ovirt/volume.rb, line 29
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
 @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href])
end