Module: XenApi
- Defined in:
- lib/xenapi/xenapi/client.rb,
lib/xenapi/xenapi.rb,
lib/xenapi/xenapi/errors.rb,
lib/xenapi/xenapi/dispatcher.rb,
lib/xenapi/xenapi/xmlrpc_client.rb,
lib/xenapi/xenapi/async_dispatcher.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Errors Classes: AsyncDispatcher, Client, Dispatcher, XMLRPCClient
Class Method Summary collapse
-
.connect(uris, username, password, options = {}) {|client| ... } ⇒ Object
Perform some action in a session context.
Class Method Details
.connect(uris, username, password, options = {}) {|client| ... } ⇒ Object
Perform some action in a session context
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/xenapi/xenapi.rb', line 26 def self.connect(uris, username, password, ={}) uris = uris.respond_to?(:shift) ? uris.dup : [uris] method = [:slave_login] ? :slave_local_login_with_password : :login_with_password client = Client.new(uris, [:timeout] || 10, [:ssl_verify] || :verify_peer) begin args = [method, username, password] args << [:api_version] if .has_key?(:api_version) client.send(*args) if block_given? return yield client else [:keep_session] = true return client end ensure client.logout unless [:keep_session] || client.xenapi_session.nil? end end |