2012-04-02 07:25:03 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class XenServer
|
|
|
|
|
|
|
|
class Host < Fog::Model
|
|
|
|
# API Reference here:
|
|
|
|
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=host
|
|
|
|
|
|
|
|
identity :reference
|
|
|
|
|
|
|
|
attribute :name, :aliases => :name_label
|
|
|
|
attribute :uuid
|
|
|
|
attribute :address
|
|
|
|
attribute :allowed_operations
|
|
|
|
attribute :enabled
|
|
|
|
attribute :hostname
|
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
# >
2012-12-06 17:39:50 -05:00
|
|
|
attribute :__metrics, :aliases => :metrics
|
2012-04-02 07:25:03 -04:00
|
|
|
attribute :name_description
|
|
|
|
attribute :other_config
|
|
|
|
attribute :__pbds, :aliases => :PBDs
|
|
|
|
attribute :__pifs, :aliases => :PIFs
|
|
|
|
attribute :__resident_vms, :aliases => :resident_VMs
|
|
|
|
|
|
|
|
def pifs
|
|
|
|
__pifs.collect { |pif| connection.pifs.get pif }
|
|
|
|
end
|
|
|
|
|
|
|
|
def pbds
|
|
|
|
__pbds.collect { |pbd| connection.pbds.get pbd }
|
|
|
|
end
|
|
|
|
|
|
|
|
def resident_servers
|
|
|
|
__resident_vms.collect { |ref| connection.servers.get ref }
|
|
|
|
end
|
|
|
|
|
|
|
|
def resident_vms
|
|
|
|
resident_servers
|
|
|
|
end
|
|
|
|
|
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
# >
2012-12-06 17:39:50 -05:00
|
|
|
def metrics
|
|
|
|
return nil unless __metrics
|
|
|
|
rec = connection.get_record(__metrics, 'host_metrics' )
|
|
|
|
Fog::Compute::XenServer::HostMetrics.new(rec)
|
|
|
|
end
|
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|