cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/2] cloudstack-cloudmonkey git commit: cloudmonkey: for username/password auth, have option to configure domain
Date Wed, 12 Nov 2014 18:15:49 GMT
Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master 24faf56d5 -> 3ce218da7


cloudmonkey: for username/password auth, have option to configure domain

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/3cd63b9e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/3cd63b9e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/3cd63b9e

Branch: refs/heads/master
Commit: 3cd63b9e2c697dd9a029871194be45c4c8d7be49
Parents: 24faf56
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Wed Nov 12 23:09:58 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Nov 12 23:31:49 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py |  5 +++--
 cloudmonkey/config.py      |  1 +
 cloudmonkey/requester.py   | 10 ++++++----
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/3cd63b9e/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index e3790d3..187a7dc 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -107,7 +107,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
 
     def init_credential_store(self):
         self.credentials = {'apikey': self.apikey, 'secretkey': self.secretkey,
-                            'username': self.username,
+                            'domain': self.domain, 'username': self.username,
                             'password': self.password}
         parsed_url = urlparse(self.url)
         self.protocol = "http" if not parsed_url.scheme else parsed_url.scheme
@@ -566,7 +566,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
         key, value = (args[0].strip(), args[2].strip())
         if not key:
             return
-        allowed_blank_keys = ["username", "password", "apikey", "secretkey"]
+        allowed_blank_keys = ["username", "password", "apikey", "secretkey",
+                              "domain"]
         if key not in allowed_blank_keys and not value:
             print "Blank value of %s is not allowed" % key
             return

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/3cd63b9e/cloudmonkey/config.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/config.py b/cloudmonkey/config.py
index 1cf9976..c6bcc3a 100644
--- a/cloudmonkey/config.py
+++ b/cloudmonkey/config.py
@@ -66,6 +66,7 @@ default_profile['timeout'] = '3600'
 default_profile['expires'] = '600'
 default_profile['username'] = 'admin'
 default_profile['password'] = 'password'
+default_profile['domain'] = '/'
 default_profile['apikey'] = ''
 default_profile['secretkey'] = ''
 default_profile['verifysslcert'] = 'true'

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/3cd63b9e/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index 627063e..3ac60d5 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -52,7 +52,7 @@ def writeError(msg):
     sys.stderr.flush()
 
 
-def login(url, username, password):
+def login(url, username, password, domain="/"):
     """
     Login and obtain a session to be used for subsequent API calls
     Wrong username/password leads to HTTP error code 531
@@ -62,7 +62,7 @@ def login(url, username, password):
     args["command"] = 'login'
     args["username"] = username
     args["password"] = password
-    args["domain"] = "/"
+    args["domain"] = domain
     args["response"] = "json"
 
     sessionkey = ''
@@ -82,7 +82,8 @@ def login(url, username, password):
         sessionkey = None
     elif resp.status_code == 531:
         writeError("Error authenticating at %s using username: %s"
-                   ", and password: %s" % (url, username, password))
+                   ", password: %s, domain: %s" % (url, username, password,
+                                                   domain))
         session = None
         sessionkey = None
     else:
@@ -103,6 +104,7 @@ def make_request_with_password(command, args, logger, url, credentials,
     args = args.copy()
     username = credentials['username']
     password = credentials['password']
+    domain = credentials['domain']
 
     if not (username and password):
         error = "Username and password cannot be empty"
@@ -119,7 +121,7 @@ def make_request_with_password(command, args, logger, url, credentials,
 
         # obtain a valid session if not supplied
         if not (session and sessionkey):
-            session, sessionkey = login(url, username, password)
+            session, sessionkey = login(url, username, password, domain)
             if not (session and sessionkey):
                 return None, 'Authentication failed'
             credentials['session'] = session


Mime
View raw message