You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2014/06/30 23:48:34 UTC
git commit: requestor: handle the case of socket error in login method
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 <ro...@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 <ro...@shapeblue.com>
Authored: Tue Jul 1 03:16:54 2014 +0530
Committer: Rohit Yadav <ro...@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: