cli: Fix asyncblock to search for correct key instead of hardcoded index Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/d2600dca Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/d2600dca Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/d2600dca Branch: refs/heads/marvin-refactor Commit: d2600dca8a1a88990ce591175d72facf2af72118 Parents: 02ccdf5 Author: Rohit Yadav <[email protected]> Authored: Wed Jan 23 14:12:38 2013 -0800 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Jan 24 17:48:35 2013 +0530 ---------------------------------------------------------------------- tools/cli/cloudmonkey/cloudmonkey.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2600dca/tools/cli/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index 339a201..d679e50 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -262,8 +262,9 @@ class CloudMonkeyShell(cmd.Cmd, object): return isAsync = isAsync and (self.asyncblock == "true") - if isAsync and 'jobid' in response[response.keys()[0]]: - jobId = response[response.keys()[0]]['jobid'] + responsekey = filter(lambda x: 'response' in x, response.keys())[0] + if isAsync and 'jobid' in response[responsekey]: + jobId = response[responsekey]['jobid'] command = "queryAsyncJobResult" requests = {'jobid': jobId} timeout = int(self.timeout) @@ -282,7 +283,7 @@ class CloudMonkeyShell(cmd.Cmd, object): jobstatus = result['jobstatus'] if jobstatus == 2: jobresult = result["jobresult"] - self.print_shell("Async query failed for jobid=", + self.print_shell("\rAsync query failed for jobid", jobId, "\nError", jobresult["errorcode"], jobresult["errortext"]) return @@ -293,7 +294,7 @@ class CloudMonkeyShell(cmd.Cmd, object): timeout = timeout - pollperiod progress += 1 logger.debug("job: %s to timeout in %ds" % (jobId, timeout)) - self.print_shell("Error:", "Async query timeout for jobid=", jobId) + self.print_shell("Error:", "Async query timeout for jobid", jobId) return response
