From 3c335bd88316a82e0295e061236233a5ca599993 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 23 Jan 2013 14:12:38 -0800 Subject: [PATCH] cli: Fix asyncblock to search for correct key instead of hardcoded index Signed-off-by: Rohit Yadav --- tools/cli/cloudmonkey/cloudmonkey.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index 339a2014522..d679e5059f1 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