Class: Pangea::Host
Overview
A Physical Host
xen-api: Class host
<tt> require ‘pangea’
host = Host.connect('xen.example.net’, ‘username’, ‘password’) </tt>
Class Method Summary collapse
-
.connect(url, username, password) ⇒ Object
Connect to the Host xml-rpc server.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Checks if the connection to the host xml-rpc server is alive.
-
#cpus ⇒ Object
Get the list of resident virtual machines controlled by the hypervisor.
-
#initialize(link, ref) ⇒ Host
constructor
:nodoc:.
-
#label ⇒ Object
Returns the label of the Host (hostname).
-
#metrics ⇒ Object
Get the Pangea::HostMetrics object for this host.
-
#networks ⇒ Object
Returns the list of networks available in this host.
-
#reconnect ⇒ Object
Reconnect to the Host.
-
#resident_vms ⇒ Object
Get the list of resident virtual machines controlled by the hypervisor.
-
#sched_policy ⇒ Object
Get the Xen scheduling policy.
-
#software_version ⇒ Object
List some properties from the hypervisor:.
- #to_s ⇒ Object
Methods inherited from XObject
Constructor Details
#initialize(link, ref) ⇒ Host
:nodoc:
84 85 86 87 |
# File 'lib/pangea/objects.rb', line 84 def initialize(link, ref) #:nodoc: super(link, ref) @proxy_name = 'host' end |
Class Method Details
.connect(url, username, password) ⇒ Object
Connect to the Host xml-rpc server
Returns a Pangea::Host object
There’s no direct mapping to xen-api
198 199 200 201 202 203 |
# File 'lib/pangea/objects.rb', line 198 def self.connect(url, username, password) @link = Link.new(url, username, password) @link.connect @ref = @link.client.call('host.get_all', @link.sid)['Value'][0] Host.new(@link, @ref) end |
Instance Method Details
#alive? ⇒ Boolean
Checks if the connection to the host xml-rpc server is alive
There’s no direct mapping to xen-api
221 222 223 224 225 226 227 228 229 |
# File 'lib/pangea/objects.rb', line 221 def alive? begin ref_call :get_uuid rescue Exception => e #puts e.message return false end true end |
#cpus ⇒ Object
Get the list of resident virtual machines controlled by the hypervisor.
Returns an Array of Pangea::HostCpu objects
xen-api: host.get_host_cpus
120 121 122 123 124 125 126 |
# File 'lib/pangea/objects.rb', line 120 def cpus list = [] ref_call(:get_host_CPUs).each do |hcpu| list << HostCpu.new(@link, hcpu) end list end |
#label ⇒ Object
Returns the label of the Host (hostname)
92 93 94 |
# File 'lib/pangea/objects.rb', line 92 def label ref_call :get_name_label end |
#metrics ⇒ Object
Get the Pangea::HostMetrics object for this host
xen-api: host.get_metrics
161 162 163 |
# File 'lib/pangea/objects.rb', line 161 def metrics HostMetrics.new(@link, ref_call(:get_metrics)) end |
#networks ⇒ Object
Returns the list of networks available in this host
If you are using a bridged network configuration (‘network-script network-bridge’ in xend-config.sxp), it will return an Array of Pangea::Network objects available in the host, one for each bridge available.
There’s no direct mapping to xen-api AFAIK
175 176 177 178 179 180 181 182 |
# File 'lib/pangea/objects.rb', line 175 def networks nets = [] p = @link.client.proxy( 'network' ) p.get_all(@link.sid)['Value'].each do |ref| nets << Network.new(@link, ref) end nets end |
#reconnect ⇒ Object
Reconnect to the Host
There’s no direct mapping to xen-api
210 211 212 213 214 |
# File 'lib/pangea/objects.rb', line 210 def reconnect raise LinkConnectError.new("You need to connect at least once before reconnecting") if @link.nil? @link.connect @ref = @link.client.call('host.get_all', @link.sid)['Value'][0] end |
#resident_vms ⇒ Object
Get the list of resident virtual machines controlled by the hypervisor.
Returns an Array of Pangea::VM objects
xen-api: host.get_resident_VMs
104 105 106 107 108 109 110 |
# File 'lib/pangea/objects.rb', line 104 def resident_vms vms = [] ref_call(:get_resident_VMs).each do |vm| vms << VM.new(@link, vm) end vms end |
#sched_policy ⇒ Object
Get the Xen scheduling policy
Returns a string
xen-api: host.get_sched_policy
152 153 154 |
# File 'lib/pangea/objects.rb', line 152 def sched_policy ref_call :get_sched_policy end |
#software_version ⇒ Object
List some properties from the hypervisor:
machine: Host Architecture Xen: Xen Version system: Host OS (i.e. Linux) release: Xen Kernel Version host: hostname
Returns a Hash
xen-api: host.get_software_version
141 142 143 |
# File 'lib/pangea/objects.rb', line 141 def software_version ref_call :get_software_version end |
#to_s ⇒ Object
184 185 186 187 188 189 |
# File 'lib/pangea/objects.rb', line 184 def to_s "Label: #{label}\n" + "UUID: #{uuid}\n" + "Sched Policy: #{sched_policy}\n" + "Xen Version: #{software_version['Xen']}" end |