Class: CloudstackRubyClient::Client
- Inherits:
-
BaseClient
- Object
- BaseClient
- CloudstackRubyClient::Client
- Defined in:
- lib/cloudstack_ruby_client/client.rb
Constant Summary collapse
- @@API_LIST =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#login(params = {}) ⇒ Object
login api command.
-
#logout(params = {}) ⇒ Object
logout api command.
-
#sub_module ⇒ Object
Api command injection.
-
#version ⇒ Object
CloudStack management server version.
- #wait_for_async_job(job, timeout = nil) ⇒ Object
Methods inherited from BaseClient
Constructor Details
This class inherits a constructor from CloudstackRubyClient::BaseClient
Class Method Details
.API_LIST ⇒ Object
25 26 27 |
# File 'lib/cloudstack_ruby_client/client.rb', line 25 def self.API_LIST @@API_LIST end |
Instance Method Details
#login(params = {}) ⇒ Object
login api command
35 36 37 |
# File 'lib/cloudstack_ruby_client/client.rb', line 35 def login(params = {}) auth_request(params, "login") end |
#logout(params = {}) ⇒ Object
logout api command
41 42 43 |
# File 'lib/cloudstack_ruby_client/client.rb', line 41 def logout(params = {}) auth_request(params, "logout") end |
#sub_module ⇒ Object
Api command injection
17 18 19 20 21 22 23 |
# File 'lib/cloudstack_ruby_client/client.rb', line 17 CloudstackRubyClient::Api.constants.collect{|k| CloudstackRubyClient::Api.const_get(k) }.select {|k| k.is_a?(Module)}.each do |sub_module| include sub_module @@API_LIST.concat sub_module.instance_methods(false) end |
#version ⇒ Object
CloudStack management server version
30 31 32 |
# File 'lib/cloudstack_ruby_client/client.rb', line 30 def version self.list_capabilities["capability"]["cloudstackversion"] end |
#wait_for_async_job(job, timeout = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cloudstack_ruby_client/client.rb', line 45 def wait_for_async_job(job, timeout=nil) wait_time = 1 slept_time = 0 if job.has_key? 'jobid' then job_id = job['jobid'] else job_id = job end return Timeout::timeout(timeout) do while true do job_stat = self.query_async_job_result(:jobid => job_id) if job_stat[:jobprocstatus] == 0 then #pending sleep wait_time slept_time += wait_time if slept_time >= 30 then wait_time = 5 elsif slept_time >= 10 then wait_time = 2 end else return job_stat end end end end |