Class: OVIRT::AffinityGroup

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

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#client, #href, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

#parse_bool, #parse_version

Constructor Details

#initialize(client, xml) ⇒ AffinityGroup

Returns a new instance of AffinityGroup.



6
7
8
9
10
# File 'lib/ovirt/affinity_group.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

#enforcingObject (readonly)

Returns the value of attribute enforcing.



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

def enforcing
  @enforcing
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#positiveObject (readonly)

Returns the value of attribute positive.



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

def positive
  @positive
end

Class Method Details

.to_xml(opts = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ovirt/affinity_group.rb', line 12

def self.to_xml(opts={})
   builder = Nokogiri::XML::Builder.new do
    affinity_group_{
      if opts[:name]
        name_(opts[:name])
      end
      if opts[:positive]
        positive_(opts[:positive])
      end
      if opts[:enforcing]
        enforcing_(opts[:enforcing])
      end
    }
   end
   Nokogiri::XML(builder.to_xml).root.to_s
end

Instance Method Details

#parse_xml_attributes!(xml) ⇒ Object



29
30
31
32
33
34
# File 'lib/ovirt/affinity_group.rb', line 29

def parse_xml_attributes!(xml)
 @name = (xml/'name').first.text
 @positive = (xml/'positive').first.text if (xml/'positive')
 @enforcing = (xml/'enforcing').first.text if (xml/'enforcing')
 @cluster = Link::new(@client, (xml/'cluster').first[:id], (xml/'cluster').first[:href]) rescue nil
end