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.
- #create_console(vm) ⇒ Object
- #create_vbd(device, vm, vdi) ⇒ Object
- #create_vdi(name, dev) ⇒ Object
- #create_vif(vm, network, mac) ⇒ Object
- #create_vm(name, memory) ⇒ Object
-
#find_vm(name) ⇒ Object
Find a certain VM by a given domain-name.
-
#get_local_sr ⇒ Object
gives the local storage resource.
-
#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
80 81 82 |
# File 'lib/xen/host.rb', line 80 def call(function_name, *params) @connection.call(function_name, *params) end |
#create_console(vm) ⇒ Object
71 72 73 |
# File 'lib/xen/host.rb', line 71 def create_console(vm) Console.create(vm, self) end |
#create_vbd(device, vm, vdi) ⇒ Object
59 60 61 |
# File 'lib/xen/host.rb', line 59 def create_vbd(device, vm, vdi) VBD.create(device, vm, vdi, self) end |
#create_vdi(name, dev) ⇒ Object
55 56 57 |
# File 'lib/xen/host.rb', line 55 def create_vdi(name, dev) VDI.create(name, dev, self) end |
#create_vif(vm, network, mac) ⇒ Object
63 64 65 |
# File 'lib/xen/host.rb', line 63 def create_vif(vm, network, mac) VIF.create(vm, network, mac, self) end |
#create_vm(name, memory) ⇒ Object
67 68 69 |
# File 'lib/xen/host.rb', line 67 def create_vm(name, memory) VM.create(name, memory, self) 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_local_sr ⇒ Object
gives the local storage resource
51 52 53 |
# File 'lib/xen/host.rb', line 51 def get_local_sr SR.get_local(self) end |
#get_value(function, *params) ⇒ Object
Call to the API, Returns only the return value.
85 86 87 |
# File 'lib/xen/host.rb', line 85 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
75 76 77 |
# File 'lib/xen/host.rb', line 75 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 |