request: check for unauthorized access 405 return code

Signed-off-by: Rohit Yadav <rohit.ya...@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/cea286ce
Tree: 
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/cea286ce
Diff: 
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/cea286ce

Branch: refs/heads/master
Commit: cea286ce67c72b78e483ac989f4bd48439556795
Parents: 8eacc30
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Tue Aug 12 12:53:50 2014 +0200
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Tue Aug 12 12:53:50 2014 +0200

----------------------------------------------------------------------
 cloudmonkey/requester.py | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/cea286ce/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index 2a34850..6787d7f 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -65,6 +65,10 @@ def login(url, username, password):
 
     if resp.status_code == 200:
         sessionkey = resp.json()['loginresponse']['sessionkey']
+    elif resp.status_code == 405:
+        print "Method not allowed, unauthorized access on URL: %s" % url
+        session = None
+        sessionkey = None
     elif resp.status_code == 531:
         print "Error authenticating at %s, with username: %s" \
               ", and password: %s" % (url, username, password)

Reply via email to