You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/01/26 17:21:39 UTC

[3/50] [abbrv] git commit: cli: Fix asyncblock to search for correct key instead of hardcoded index

cli: Fix asyncblock to search for correct key instead of hardcoded index

Signed-off-by: Rohit Yadav <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/3c335bd8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/3c335bd8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/3c335bd8

Branch: refs/heads/marvin-refactor-phase1
Commit: 3c335bd88316a82e0295e061236233a5ca599993
Parents: 7a927e3
Author: Rohit Yadav <bh...@apache.org>
Authored: Wed Jan 23 14:12:38 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Wed Jan 23 14:57:41 2013 -0800

----------------------------------------------------------------------
 tools/cli/cloudmonkey/cloudmonkey.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3c335bd8/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