cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/2] git commit: updated refs/heads/master to 10f9516
Date Sun, 16 Jun 2013 13:29:22 GMT
cloumonkey: Remove junk from requester.py

This fix removes junk from 6e22843acb6bbd61260849fac171bba61ac6650f which was
supposed to just improve error messages and not messup the whole async block
logic and go into an infinite recursion or fail with some key error.

Signed-off-by: Rohit Yadav <rohit.yadav@wingify.com>


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

Branch: refs/heads/master
Commit: 10f9516015121fc0521616d3b6d675ac7561c7d9
Parents: 1a058d7
Author: Rohit Yadav <rohit.yadav@wingify.com>
Authored: Sun Jun 16 18:34:32 2013 +0530
Committer: Rohit Yadav <rohit.yadav@wingify.com>
Committed: Sun Jun 16 18:34:32 2013 +0530

----------------------------------------------------------------------
 tools/cli/cloudmonkey/requester.py | 47 ++++++++-------------------------
 1 file changed, 11 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/10f95160/tools/cli/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/requester.py b/tools/cli/cloudmonkey/requester.py
index d2dae6d..b06e1fc 100644
--- a/tools/cli/cloudmonkey/requester.py
+++ b/tools/cli/cloudmonkey/requester.py
@@ -125,61 +125,36 @@ def monkeyrequest(command, args, isasync, asyncblock, logger, host,
port,
         command = "queryAsyncJobResult"
         request = {'jobid': jobid}
         timeout = int(timeout)
-        pollperiod = 3
+        pollperiod = 2
         progress = 1
         while timeout > 0:
             print '\r' + '.' * progress,
             sys.stdout.flush()
-            progress += 1
+            time.sleep(pollperiod)
             timeout = timeout - pollperiod
+            progress += 1
             logger_debug(logger, "Job %s to timeout in %ds" % (jobid, timeout))
-            sys.stdout.flush()
-            if re.match("queryAsyncJobResult", command):
-                time.sleep(pollperiod)
-            else:
-                response, error = monkeyrequest(command, request, isasync,
-                                                asyncblock, logger,
-                                                host, port,  apikey, secretkey,
-                                                timeout, protocol, path)
+            response, error = make_request(command, request, logger,
+                                           host, port, apikey, secretkey,
+                                           protocol, path)
+            if error is not None:
+                return response, error
 
+            response = process_json(response)
             responsekeys = filter(lambda x: 'response' in x, response.keys())
 
             if len(responsekeys) < 1:
-                time.sleep(pollperiod)
                 continue
 
             result = response[responsekeys[0]]
             jobstatus = result['jobstatus']
-            jobresultcode = result['jobresultcode']
-            try:
-                jobresult = result["jobresult"]
-                logger_debug(logger, "jobresult %s" % (jobresult))
-                sys.stdout.flush()
-                return response, None
-            except KeyError:
-                logger_debug(logger, "No jobresult yet %s" % (result))
-                sys.stdout.flush()
-
-            if jobresultcode != 0:
-                error = "Error: resultcode %d for jobid %s" % (jobresultcode,
-                                                               jobid)
-                logger_debug(logger, "%s" % (error))
-                return response, error
-            else:
-                # if we get a valid respons resultcode give back results
-                response, error = monkeyrequest(command, request, isasync,
-                                                asyncblock, logger,
-                                                host, port,  apikey, secretkey,
-                                                timeout, protocol, path)
-                logger_debug(logger, "Ok: %s" % (jobid))
-                return response, error
-
             if jobstatus == 2:
+                jobresult = result["jobresult"]
                 error = "\rAsync job %s failed\nError %s, %s" % (jobid,
                         jobresult["errorcode"], jobresult["errortext"])
                 return response, error
             elif jobstatus == 1:
-                print '\r',
+                print "\r" + " " * progress,
                 return response, error
             else:
                 logger_debug(logger, "We should not arrive here!")


Mime
View raw message