Class: OVIRT::Volume

Inherits:
BaseObject show all
Defined in:
lib/ovirt/volume.rb

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#client, #href, #id, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

#parse_bool, #parse_version

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

#aliasObject (readonly)

Returns the value of attribute alias.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def alias
  @alias
end

#bootableObject (readonly)

Returns the value of attribute bootable.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def bootable
  @bootable
end

#disk_profileObject (readonly)

Returns the value of attribute disk_profile.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def disk_profile
  @disk_profile
end

#disk_typeObject (readonly)

Returns the value of attribute disk_type.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def disk_type
  @disk_type
end

#formatObject (readonly)

Returns the value of attribute format.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def format
  @format
end

#interfaceObject (readonly)

Returns the value of attribute interface.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def interface
  @interface
end

#quotaObject (readonly)

Returns the value of attribute quota.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def quota
  @quota
end

#sizeObject (readonly)

Returns the value of attribute size.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def size
  @size
end

#sparseObject (readonly)

Returns the value of attribute sparse.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def sparse
  @sparse
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def status
  @status
end

#storage_domainObject (readonly)

Returns the value of attribute storage_domain.



4
5
6
# File 'lib/ovirt/volume.rb', line 4

def storage_domain
  @storage_domain
end

#vmObject (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(opts = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ovirt/volume.rb', line 12

def self.to_xml(opts={})
   builder = Nokogiri::XML::Builder.new do
    disk_{
      if opts[:storage_domain_id]
        storage_domains_{
          storage_domain_(:id => opts[:storage_domain_id])
        }
      end
      if opts[:size]
        size_(opts[:size])
      end
      if opts[:type]
        type_(opts[:type])
      end
      if opts[:bootable]
        bootable_(opts[:bootable])
      end
      if opts[:disk_profile]
         disk_profile_(:id => opts[:disk_profile])
      end
      if opts[:interface]
        interface_(opts[:interface])
      end
      if opts[:format]
        format_(opts[:format])
      end
      if opts[:sparse]
        sparse_(opts[:sparse])
      end
      if opts[:quota]
        quota_( :id => opts[:quota])
      end
      if opts[:alias]
        alias_(opts[:alias])
      end
      if opts[:wipe_after_delete]
        wipe_after_delete(opts[:wipe_after_delete])
      end
    }
  end
  Nokogiri::XML(builder.to_xml).root.to_s
end

Instance Method Details

#parse_xml_attributes!(xml) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ovirt/volume.rb', line 55

def parse_xml_attributes!(xml)
 @storage_domain = ((xml/'storage_domains/storage_domain').first[:id] rescue nil)
 @size = (xml/'size').first.text
 @disk_type = ((xml/'type').first.text rescue nil)
 @bootable = ((xml/'bootable').first.text rescue nil)
 @interface = ((xml/'interface').first.text rescue nil)
 @format = ((xml/'format').first.text rescue nil)
 @sparse = ((xml/'sparse').first.text rescue nil)
 @status = ((xml/'status/state').first.text rescue nil)
 @disk_profile = Link::new(@client, (xml/'disk_profile').first[:id], (xml/'disk_profile').first[:href]) rescue nil
 @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil
 @quota = ((xml/'quota').first[:id] rescue nil)
 @alias = ((xml/'alias').first.text rescue nil)
 @wipe_after_delete = ((xml/'wipe_after_delete').first.text rescue nil)
end