Method: CloudstackClient::Connection#send_async_request
- Defined in:
- lib/cloudstack_client/connection.rb
#send_async_request(params) ⇒ Object
Sends an asynchronous request and waits for the response.
The contents of the ‘jobresult’ element are returned upon completion of the command.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cloudstack_client/connection.rb', line 90 def send_async_request(params) data = send_request(params) params = { 'command' => 'queryAsyncJobResult', 'jobid' => data[k('jobid')] } max_tries.times do data = send_request(params) print "." if @verbose case data[k('jobstatus')] when 1 return data[k('jobresult')] when 2 raise JobError, "Request failed (#{data[k('jobresultcode')]}): #{data[k('jobresult')][k('errortext')]}." end STDOUT.flush if @verbose sleep @async_poll_interval end raise TimeoutError, "Asynchronous request timed out." end |