Class: XenAPI::Session
- Inherits:
-
Object
- Object
- XenAPI::Session
- Defined in:
- lib/xenapi/session.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(uri, &block) ⇒ Session
constructor
A new instance of Session.
- #login_with_password(username, password, timeout = 1200) ⇒ Object
- #method_missing(name, *args) ⇒ Object
-
#task(*args) ⇒ Object
Avoiding method missing to get lost with Rake Task (considering Xen tasks as Rake task (???).
Methods included from Network
Methods included from Task
#task_create, #task_destroy, #task_record
Methods included from Storage
#all_storages, #storage_name, #storage_record, #storage_record_by_uuid, #storage_ref
Methods included from Vbd
Methods included from Vdi
#create_VDI_for, #vdi_clone, #vdi_name_description=, #vdi_name_label, #vdi_name_label=, #vdi_record, #vdi_ref, #vdi_resize, #vdi_virtual_size
Methods included from VirtualMachine
#adjust_vcpu_settings, #cd_ref, #configure_network_interfaces_on, #created_vifs, #exists_on_hypervisor?, #export, #hdd_physical_utilisation, #hdd_size, #import, #insert_iso_cd, #master_address, #next_disk_number, #remove_disks_from_hypervisor, #set_cpus_size, #set_memory_size, #tools_outdated?, #vbds, #vifs, #vm_clone, #vm_main_vif_ref, #vm_record, #vm_ref
Constructor Details
#initialize(uri, &block) ⇒ Session
Returns a new instance of Session.
15 16 17 |
# File 'lib/xenapi/session.rb', line 15 def initialize(uri, &block) @uri, @block = uri, block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/xenapi/session.rb', line 54 def method_missing(name, *args) raise XenAPI::UnauthenticatedClient.new unless @key proxy = @client.proxy(name.to_s, @key, *args) Dispatcher.new(proxy, &@block) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
13 14 15 |
# File 'lib/xenapi/session.rb', line 13 def key @key end |
Instance Method Details
#close ⇒ Object
44 45 46 |
# File 'lib/xenapi/session.rb', line 44 def close @session.logout(@key) end |
#login_with_password(username, password, timeout = 1200) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xenapi/session.rb', line 19 def login_with_password(username, password, timeout = 1200) begin @client = XMLRPC::Client.new2(@uri, nil, timeout) @session = @client.proxy("session") response = @session.login_with_password(username, password) raise XenAPI::ErrorFactory.create(*response['ErrorDescription']) unless response['Status'] == 'Success' @key = response["Value"] #Let's check if it is a working master. It's a small pog due to xen not working as we would like self.pool.get_all self rescue Exception => exc error = XenAPI::ErrorFactory.wrap(exc) if @block # returns a new session @block.call(error) else raise error end end end |
#task(*args) ⇒ Object
Avoiding method missing to get lost with Rake Task (considering Xen tasks as Rake task (???)
50 51 52 |
# File 'lib/xenapi/session.rb', line 50 def task(*args) method_missing("task", *args) end |