mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
cli: Show progress during polling for async jobs
If asyncblock is set to true, prints dots as polling requests are made. When result is obtained, dots are wiped and result is printed. Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
parent
9a66beb658
commit
c7563cb7bd
@ -266,7 +266,11 @@ class CloudMonkeyShell(cmd.Cmd, object):
|
||||
command = "queryAsyncJobResult"
|
||||
requests = {'jobid': jobId}
|
||||
timeout = int(self.timeout)
|
||||
pollperiod = 3
|
||||
while timeout > 0:
|
||||
progress = int((int(self.timeout) - timeout) / pollperiod ) + 1
|
||||
print '\r' + '.' * progress,
|
||||
sys.stdout.flush()
|
||||
response = process_json(conn.make_request_with_auth(command,
|
||||
requests))
|
||||
responsekeys = filter(lambda x: 'response' in x,
|
||||
@ -282,9 +286,10 @@ class CloudMonkeyShell(cmd.Cmd, object):
|
||||
jobresult["errortext"])
|
||||
return
|
||||
elif jobstatus == 1:
|
||||
print '\r',
|
||||
return response
|
||||
time.sleep(4)
|
||||
timeout = timeout - 4
|
||||
time.sleep(pollperiod)
|
||||
timeout = timeout - pollperiod
|
||||
logger.debug("job: %s to timeout in %ds" % (jobId, timeout))
|
||||
self.print_shell("Error:", "Async query timeout for jobid=", jobId)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user