
module OVIRT
  class DataCenter < BaseObject
    attr_reader :description, :status, :storage_type, :storage_format, :supported_versions, :version

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

    private

    def parse_xml_attributes!(xml)
      @description = (xml/'description').first.text rescue nil
      @status = (xml/'status').first.text.strip
      @storage_type = (xml/'storage_type').first.text rescue nil
      @storage_format = (xml/'storage_format').first.text rescue nil
      @supported_versions = (xml/'supported_versions').collect { |v|
        parse_version v
      }
      @version = parse_version xml rescue nil
    end
  end
 
end


module OVIRT
  class DataCenter < BaseObject
    attr_reader :description, :status, :local, :storage_type, :storage_format, :supported_versions, :version

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

    private

    def parse_xml_attributes!(xml)
      @description = (xml/'description').first.text rescue nil
      @status = (xml/'status').first.text.strip
      @local = parse_bool((xml/'local').first.text) rescue nil
      @storage_type = (xml/'storage_type').first.text rescue nil
      @storage_format = (xml/'storage_format').first.text rescue nil
      @supported_versions = (xml/'supported_versions').collect { |v|
        parse_version v
      }
      @version = parse_version xml rescue nil
    end
  end
 
end

Add support for Data Center "local" attribute
Add support for Data Center "local" attribute

In version 3.4 of oVirt Engine the concept of type of a Data Center has
been relaxed, so that multiple types of storage (local, NFS, Fibre
Channel, etc) can be used in the same Data Center. So Data Centers no
longer have a type, but a "local" flag tha indicates if the storage is
only locally accessible or if it may be shared by multiple hosts. This
flag isn't currently available in the Ruby API. This patch adds it,
preserving the existing "storage_type" attribute for backwards
compatibility.

Signed-off-by: Juan Hernandez <59e5b8140de97cc91c3fb6c5342dce948469af8c@redhat.com>
