class OVIRT::Volume

Attributes

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

Public Class Methods

new(client, xml) click to toggle source
Calls superclass method OVIRT::BaseObject::new
   # File lib/ovirt/volume.rb
 6 def initialize(client, xml)
 7   super(client, xml[:id], xml[:href], (xml/'name').first.text)
 8   parse_xml_attributes!(xml)
 9   self
10 end
to_xml(opts={}) click to toggle source
   # File lib/ovirt/volume.rb
12 def self.to_xml(opts={})
13    builder = Nokogiri::XML::Builder.new do
14     disk_{
15       if opts[:storage_domain_id]
16         storage_domains_{
17           storage_domain_(:id => opts[:storage_domain_id])
18         }
19       end
20       if opts[:size]
21         size_(opts[:size])
22       end
23       if opts[:type]
24         type_(opts[:type])
25       end
26       if opts[:bootable]
27         bootable_(opts[:bootable])
28       end
29       if opts[:disk_profile]
30          disk_profile_(:id => opts[:disk_profile])
31       end
32       if opts[:interface]
33         interface_(opts[:interface])
34       end
35       if opts[:format]
36         format_(opts[:format])
37       end
38       if opts[:sparse]
39         sparse_(opts[:sparse])
40       end
41       if opts[:quota]
42         quota_( :id => opts[:quota])
43       end
44       if opts[:alias]
45         alias_(opts[:alias])
46       end
47       if opts[:wipe_after_delete]
48         wipe_after_delete(opts[:wipe_after_delete])
49       end
50     }
51   end
52   Nokogiri::XML(builder.to_xml).root.to_s
53 end

Public Instance Methods

parse_xml_attributes!(xml) click to toggle source
   # File lib/ovirt/volume.rb
55 def parse_xml_attributes!(xml)
56  @storage_domain = ((xml/'storage_domains/storage_domain').first[:id] rescue nil)
57  @size = (xml/'size').first.text
58  @disk_type = ((xml/'type').first.text rescue nil)
59  @bootable = ((xml/'bootable').first.text rescue nil)
60  @interface = ((xml/'interface').first.text rescue nil)
61  @format = ((xml/'format').first.text rescue nil)
62  @sparse = ((xml/'sparse').first.text rescue nil)
63  @status = ((xml/'status/state').first.text rescue nil)
64  @disk_profile = Link::new(@client, (xml/'disk_profile').first[:id], (xml/'disk_profile').first[:href]) rescue nil
65  @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil
66  @quota = ((xml/'quota').first[:id] rescue nil)
67  @alias = ((xml/'alias').first.text rescue nil)
68  @wipe_after_delete = ((xml/'wipe_after_delete').first.text rescue nil)
69 end