Class: Xen::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/xen/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 2000, login = 'user', pass = '') ⇒ Connection

Initializes an xml-rpc connection to a Xen host, and logs in with the given credentials.

Example

Xen::Connection.new (‘xenhost.example.com’, 2000, ‘login’, ‘pass’)



10
11
12
13
# File 'lib/xen/connection.rb', line 10

def initialize(host, port = 2000,  = 'user', pass = '')
  @server = XMLRPC::Client.new(host,'/', port)
  @session = @server.call("session.login_with_password", , pass)
end

Instance Method Details

#call(function_name, *params) ⇒ Object

Make a direct call to the Xen API.

Example

call(‘session.get_this_host’, session_id) # => “Value”=>“3a8f495d-939d-823b-fa08-fc407c73dc94”



23
24
25
# File 'lib/xen/connection.rb', line 23

def call(function_name, *params)
  call_without_session(function_name, session_id, *params)
end

#session_idObject

Returns the session_id of the connection



16
17
18
# File 'lib/xen/connection.rb', line 16

def session_id
  @session['Value']
end

#to_sObject



27
28
29
# File 'lib/xen/connection.rb', line 27

def to_s
  session_id.to_s
end