Sha256: ead6fe870e37c7fbb0c3cf7762c72b084c15a5a2c67b98d139c80179467c3731

Contents?: true

Size: 989 Bytes

Versions: 15

Compression:

Stored size: 989 Bytes

Contents

module OVIRT

  class AffinityGroup < BaseObject
    attr_reader :name, :positive, :enforcing

    def initialize(client, xml)
      super(client, xml[:id], xml[:href], (xml/'name').first.text)
      parse_xml_attributes!(xml)
      self
    end

    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

    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
  end
end

Version data entries

15 entries across 13 versions & 2 rubygems

Version Path
rbovirt-0.1.7 lib/ovirt/affinity_group.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rbovirt-0.1.6/lib/ovirt/affinity_group.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rbovirt-0.1.6/lib/ovirt/affinity_group.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rbovirt-0.1.6/lib/ovirt/affinity_group.rb
rbovirt-0.1.6 lib/ovirt/affinity_group.rb
rbovirt-0.1.5 lib/ovirt/affinity_group.rb
rbovirt-0.1.4 lib/ovirt/affinity_group.rb
rbovirt-0.1.3 lib/ovirt/affinity_group.rb
rbovirt-0.1.2 lib/ovirt/affinity_group.rb
rbovirt-0.0.38 lib/ovirt/affinity_group.rb
rbovirt-0.1.1 lib/ovirt/affinity_group.rb
rbovirt-0.0.37 lib/ovirt/affinity_group.rb
rbovirt-0.0.36 lib/ovirt/affinity_group.rb
rbovirt-0.1.0 lib/ovirt/affinity_group.rb
rbovirt-0.0.35 lib/ovirt/affinity_group.rb