1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Added missing HostMetrics model

Added missing HostMetrics model that wraps Host.metrics OpaqueRef.

  conn = Fog::Compute.new({
    :provider => 'XenServer',
    :xenserver_url => 'xenserver-test',
    :xenserver_username => 'root',
    :xenserver_password => 'secret',
  })

  pp conn.hosts.first.metrics # => yields

  #  <Fog::Compute::XenServer::HostMetrics
  #    reference="OpaqueRef:161923b3-47e4-7f8c-8995-3030be9d58f8",
  #    uuid="00d47697-3682-1e91-154b-00116a5b7878",
  #    live=true,
  #    memory_free="3311230976",
  #    memory_total="4217688064",
  #    other_config={},
  #    last_updated=2012-12-06 21:19:59 UTC
  #  >
This commit is contained in:
Sergio Rubio 2012-12-06 23:39:50 +01:00
parent 11591b3ed9
commit 2990a6eba0
3 changed files with 37 additions and 1 deletions

View file

@ -36,6 +36,7 @@ module Fog
model :pbd
model :guest_metrics
model :vbd_metrics
model :host_metrics
request_path 'fog/xenserver/requests/compute'
request :create_server

View file

@ -16,7 +16,7 @@ module Fog
attribute :allowed_operations
attribute :enabled
attribute :hostname
attribute :metrics
attribute :__metrics, :aliases => :metrics
attribute :name_description
attribute :other_config
attribute :__pbds, :aliases => :PBDs
@ -39,6 +39,12 @@ module Fog
resident_servers
end
def metrics
return nil unless __metrics
rec = connection.get_record(__metrics, 'host_metrics' )
Fog::Compute::XenServer::HostMetrics.new(rec)
end
end
end

View file

@ -0,0 +1,29 @@
require 'fog/core/model'
module Fog
module Compute
class XenServer
class HostMetrics < Fog::Model
# API Reference here:
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VM_host_metrics
identity :reference
attribute :uuid
attribute :live
attribute :memory_free
attribute :memory_total
attribute :other_config
attribute :last_updated
def initialize(attributes = {})
super
self.last_updated = attributes[:last_updated].to_time
end
end
end
end
end