Sha256: baf89a2435a8f462a7f2aba9455e41d2248027634fdd67fe7ec8f105e4e72b40

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 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"
    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

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.8.0 lib/yao/resources/hypervisor.rb