cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: requestor: handle the case of socket error in login method
Date Mon, 30 Jun 2014 21:48:34 GMT
Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master aab83711b -> 2fcc12d68


requestor: handle the case of socket error in login method

cloudmonkey would break if mgmt server is not running instead of handling the
case of socket error, connection refused. The fix adds a try catch block on the
login by username/password mechanism.

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


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

Branch: refs/heads/master
Commit: 2fcc12d68af8484424bf2a3799ad9ddc5ea62c99
Parents: aab8371
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Tue Jul 1 03:16:54 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Jul 1 03:16:54 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/requester.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/2fcc12d6/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index 8e3a352..ae8c927 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -57,7 +57,12 @@ def login(url, username, password):
     sessionkey = ''
     session = requests.Session()
 
-    resp = session.post(url, params=args)
+    try:
+        resp = session.post(url, params=args)
+    except requests.exceptions.ConnectionError, e:
+        print "Connection refused by server"
+        return None, None
+
     if resp.status_code == 200:
         sessionkey = resp.json()['loginresponse']['sessionkey']
     elif resp.status_code == 531:


Mime
View raw message