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/10/31 01:51:03 UTC
[6/8] git commit: cloudmonkey: autocomplete filter options
cloudmonkey: autocomplete filter options
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/8202b8bb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/8202b8bb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/8202b8bb
Branch: refs/heads/master
Commit: 8202b8bb18f830e2d53f03da92261fd4eebefdae
Parents: ccb3a75
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Oct 31 06:17:59 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Oct 31 06:17:59 2014 +0530
----------------------------------------------------------------------
cloudmonkey/cachemaker.py | 1 +
cloudmonkey/cloudmonkey.py | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/8202b8bb/cloudmonkey/cachemaker.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cachemaker.py b/cloudmonkey/cachemaker.py
index 47749e5..2f2fa87 100644
--- a/cloudmonkey/cachemaker.py
+++ b/cloudmonkey/cachemaker.py
@@ -132,6 +132,7 @@ def monkeycache(apis):
apidict['requiredparams'] = required
apidict['params'] = apiparams
+ apidict['response'] = getvalue(api, 'response')
if verb not in cache:
cache[verb] = {}
cache[verb][subject] = apidict
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/8202b8bb/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 5213e67..08ccb4d 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -424,7 +424,22 @@ class CloudMonkeyShell(cmd.Cmd, object):
idx = param.find("=")
value = param[idx + 1:]
param = param[:idx]
- if len(value) < 36 and idx != -1:
+ if param == "filter":
+ response_params = self.apicache[verb][subject]["response"]
+ used = filter(lambda x: x.strip() != "", value.split(",")[:-1])
+ unused = map(lambda x: x['name'] + ",", filter(lambda x:
+ "name" in x and x["name"] not in used,
+ response_params))
+ last_value = value.split(",")[-1]
+ if last_value:
+ unused = filter(lambda x: x.startswith(last_value),
+ unused)
+ suffix = ",".join(used)
+ if suffix:
+ suffix += ","
+ return filter(lambda x: x.startswith(value),
+ map(lambda x: suffix + x, unused))
+ elif len(value) < 36 and idx != -1:
api = None
logger.debug("[Paramcompl] For %s %s %s=" % (verb, subject,
param))