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/11/12 19:15:49 UTC
[1/2] cloudstack-cloudmonkey git commit: cloudmonkey: for
username/password auth, have option to configure domain
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 <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/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 <ro...@shapeblue.com>
Authored: Wed Nov 12 23:09:58 2014 +0530
Committer: Rohit Yadav <ro...@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
[2/2] cloudstack-cloudmonkey git commit: cloudmonkey: autocomplete
when cursor is not at the end, auto add space
Posted by bh...@apache.org.
cloudmonkey: autocomplete when cursor is not at the end, auto add space
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/3ce218da
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/3ce218da
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/3ce218da
Branch: refs/heads/master
Commit: 3ce218da7d8d9c93eec9930f56eb7b7c954c9b3b
Parents: 3cd63b9
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Nov 12 23:42:08 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Nov 12 23:45:34 2014 +0530
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/3ce218da/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 187a7dc..607687b 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -409,7 +409,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
self.monkeyprint("Error on parsing and printing ", e)
def completedefault(self, text, line, begidx, endidx):
- partitions = line.partition(" ")
+ partitions = line[:endidx].partition(" ")
verb = partitions[0].strip()
rline = partitions[2].lstrip().partition(" ")
subject = rline[0]
@@ -423,7 +423,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
search_string = ""
if separator != " ": # Complete verb subjects
- autocompletions = self.apicache[verb].keys()
+ autocompletions = map(lambda x: x + " ",
+ self.apicache[verb].keys())
search_string = subject
else: # Complete subject params
autocompletions = map(lambda x: x + "=",
@@ -431,7 +432,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
self.apicache[verb][subject]['params']))
search_string = text
if self.paramcompletion == 'true':
- param = line.split(" ")[-1]
+ param = line[:endidx].split(" ")[-1]
idx = param.find("=")
value = param[idx + 1:]
param = param[:idx]
@@ -484,7 +485,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
arg = filter(lambda x: x['name'] == param, params)[0]
if "type" in arg and arg["type"] == "boolean":
return filter(lambda x: x.startswith(value),
- ["true", "false"])
+ ["true ", "false "])
related = arg['related']
apis = filter(lambda x: 'list' in x, related)
logger.debug("[Paramcompl] Related APIs: %s" % apis)
@@ -515,7 +516,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
name = option[1]
if uuid.startswith(value):
print uuid, name
- autocompletions = uuids
+ autocompletions = map(lambda x: x + " ", uuids)
search_string = value
if subject != "" and line.split(" ")[-1].find('=') == -1: