Sha256: 73a722b229400df588503e297c62130bab884008b81e0c9983b46f3c409c86e4

Contents?: true

Size: 1.58 KB

Versions: 8

Compression:

Stored size: 1.58 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

    # @return [Hash]
    def cpu_info
      JSON.parse self["cpu_info"]
    end

    # @return [Bool]
    def enabled?
      self['status'] == 'enabled'
    end

    # @return [Bool]
    def disabled?
      self['status'] == 'disabled'
    end

    # @return [Yao::Resources::ComputeServices]
    def service
      Yao::ComputeServices.new(self['service'])
    end

    alias hostname hypervisor_hostname
    alias type     hypervisor_type
    alias version  hypervisor_version

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

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

      # @param id [String]
      # @return [Yao::Resources::Hypervisor::Uptime]
      def uptime(id)
        json = GET([resources_path, id, "uptime"].join("/")).body
        Yao::Resources::Hypervisor::Uptime.new(json["hypervisor"])
      end
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/hypervisor.rb
yao-0.20.0 lib/yao/resources/hypervisor.rb
yao-0.19.0 lib/yao/resources/hypervisor.rb
yao-0.18.0 lib/yao/resources/hypervisor.rb
yao-0.17.0 lib/yao/resources/hypervisor.rb
yao-0.16.0 lib/yao/resources/hypervisor.rb
yao-0.15.0 lib/yao/resources/hypervisor.rb
yao-0.14.0 lib/yao/resources/hypervisor.rb