Sha256: 3d45113aaa8007c13f0278c2b86c409082a1d32196707efc48ec157188a948fa

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

require 'ostruct'

module Yao::Resources
  class Hypervisor < Base
    friendly_attributes :hypervisor_hostname, :hypervisor_type, :hypervisor_version, :running_vms, :current_workload,
                        :vcpus, :vcpus_used,
                        :memory_mb, :memory_mb_used, :free_disk_gb,
                        :local_gb, :local_gb_used, :free_disk_gb, :status

    def cpu_info
      JSON.parse self["cpu_info"]
    end

    def enabled?
      self['status'] == 'enabled'
    end

    alias hostname hypervisor_hostname
    alias type     hypervisor_hostname
    alias version  hypervisor_version

    self.service        = "compute"
    self.resource_name  = "os-hypervisor"
    self.resources_name = "os-hypervisors"

    class << self
      def list_detail(query={})
        return_resources(
          resources_from_json(
            GET([resources_path, "detail"].join("/"), query).body
          )
        )
      end

      def statistics
        json = GET([resources_path, "statistics"].join("/")).body
        Yao::Resources::Hypervisor::Statistics.new(json["hypervisor_statistics"])
      end

      def uptime(id)
        res = resource_from_json(
                GET([resources_path, id, "uptime"].join("/")).body
              )
        Yao::Resources::Hypervisor::Uptime.new(res)
      end
    end

    class Statistics < OpenStruct; end
    class Uptime     < OpenStruct; end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
yao-0.7.0 lib/yao/resources/hypervisor.rb
yao-0.6.3 lib/yao/resources/hypervisor.rb
yao-0.6.2 lib/yao/resources/hypervisor.rb
yao-0.6.1 lib/yao/resources/hypervisor.rb
yao-0.6.0 lib/yao/resources/hypervisor.rb
yao-0.5.0 lib/yao/resources/hypervisor.rb
yao-0.4.3 lib/yao/resources/hypervisor.rb
yao-0.4.2 lib/yao/resources/hypervisor.rb
yao-0.4.1 lib/yao/resources/hypervisor.rb
yao-0.4.0 lib/yao/resources/hypervisor.rb