Sha256: dc38a26d9534feb72cf489b990896cab946e1e40e65fc229dbef9c122b035765

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module OVIRT
  class Client
    def cluster_version(cluster_id)
      c = cluster(cluster_id)
      return c.version.split('.')[0].to_i, c.version.split('.')[1].to_i
    end

    def cluster_version?(cluster_id, major)
      c = cluster(cluster_id)
      c.version.split('.')[0] == major
    end

    def clusters(opts={})
      headers = {:accept => "application/xml; detail=datacenters"}
      search= opts[:search] || ("datacenter=%s" % current_datacenter.name)
      http_get("/clusters?search=%s" % CGI.escape(search), headers).xpath('/clusters/cluster').collect do |cl|
        cluster = OVIRT::Cluster.new(self, cl)
        #the following line is needed as a work-around a bug in RHEV 3.0 rest-api
        cluster if cluster.datacenter.id == current_datacenter.id
      end.compact
    end

    def cluster(cluster_id)
      headers = {:accept => "application/xml; detail=datacenters"}
      cluster_xml = http_get("/clusters/%s" % cluster_id, headers)
      OVIRT::Cluster.new(self, cluster_xml.root)
    end

    def networks(opts)
      cluster_id = opts[:cluster_id] || current_cluster.id
      http_get("/clusters/%s/networks" % cluster_id, http_headers).xpath('/networks/network').collect do |cl|
        OVIRT::Network.new(self, cl)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rbovirt-0.0.15 lib/client/cluster_api.rb
rbovirt-0.0.14 lib/client/cluster_api.rb
rbovirt-0.0.13 lib/client/cluster_api.rb