Class: Xen::Connection
- Inherits:
-
Object
- Object
- Xen::Connection
- Defined in:
- lib/xen/connection.rb
Instance Method Summary collapse
-
#call(function_name, *params) ⇒ Object
Make a direct call to the Xen API.
-
#initialize(host, port = 2000, login = 'user', pass = '') ⇒ Connection
constructor
Initializes an xml-rpc connection to a Xen host, and logs in with the given credentials.
-
#session_id ⇒ Object
Returns the session_id of the connection.
- #to_s ⇒ Object
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, login = 'user', pass = '') @server = XMLRPC::Client.new(host,'/', port) @session = @server.call("session.login_with_password", login, 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_id ⇒ Object
Returns the session_id of the connection
16 17 18 |
# File 'lib/xen/connection.rb', line 16 def session_id @session['Value'] end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/xen/connection.rb', line 27 def to_s session_id.to_s end |