Class: Xen::Host
- Inherits:
-
Object
- Object
- Xen::Host
- Defined in:
- lib/xen/host.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#call(function_name, *params) ⇒ Object
Call to the API.
-
#find_vm(name) ⇒ Object
Find a certain VM by a given domain-name.
-
#get_value(function, *params) ⇒ Object
Call to the API, Returns only the return value.
-
#initialize(host, port = 2000, login = 'user', pass = '') ⇒ Host
constructor
Creates a new Host object, and initiates an API connection to the given host on the given port, with a login and pass.
-
#networks ⇒ Object
Gives the different bridges on your system.
- #record ⇒ Object
- #to_s ⇒ Object
-
#uid ⇒ Object
Returns the uid of the host.
-
#version ⇒ Object
Gives the API version number in the form of major.minor vendor.
-
#vms ⇒ Object
Gives an array of active VM’s on that Host.
Constructor Details
#initialize(host, port = 2000, login = 'user', pass = '') ⇒ Host
Creates a new Host object, and initiates an API connection to the given host on the given port, with a login and pass.
8 9 10 11 |
# File 'lib/xen/host.rb', line 8 def initialize(host, port = 2000, login = 'user', pass = '') @host = host @connection = Connection.new(host, port, login, pass) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/xen/host.rb', line 5 def connection @connection end |
Instance Method Details
#call(function_name, *params) ⇒ Object
Call to the API
55 56 57 |
# File 'lib/xen/host.rb', line 55 def call(function_name, *params) @connection.call(function_name, *params) end |
#find_vm(name) ⇒ Object
Find a certain VM by a given domain-name.
26 27 28 |
# File 'lib/xen/host.rb', line 26 def find_vm name vms.detect { |vm| vm.name == name } # || raise Exception end |
#get_value(function, *params) ⇒ Object
Call to the API, Returns only the return value.
60 61 62 |
# File 'lib/xen/host.rb', line 60 def get_value(function, *params) call(function, *params)['Value'] end |
#networks ⇒ Object
Gives the different bridges on your system
31 32 33 34 35 |
# File 'lib/xen/host.rb', line 31 def networks get_value("network.get_all").collect do |network_uid| Network.new(network_uid, self) end end |
#record ⇒ Object
46 47 48 |
# File 'lib/xen/host.rb', line 46 def record get_value("host.get_record") end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/xen/host.rb', line 50 def to_s uid.to_s end |
#uid ⇒ Object
Returns the uid of the host.
14 15 16 |
# File 'lib/xen/host.rb', line 14 def uid # Lazy Loaded @uid ||= get_value("session.get_this_host", @connection.session_id) end |
#version ⇒ Object
Gives the API version number in the form of major.minor vendor.
38 39 40 41 42 43 44 |
# File 'lib/xen/host.rb', line 38 def version major = get_value("host.get_API_version_major", uid) minor = get_value("host.get_API_version_minor", uid) vendor = get_value("host.get_API_version_vendor", uid) "#{major}.#{minor} #{vendor}" end |