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/29 07:57:50 UTC
[1/2] git commit: cloudmonkey: don't show filter= if a pending
parameter is there
Repository: cloudstack-cloudmonkey
Updated Branches:
refs/heads/master fa79185f7 -> 78920d02a
cloudmonkey: don't show filter= if a pending parameter is there
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/b9ad1c63
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/b9ad1c63
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/b9ad1c63
Branch: refs/heads/master
Commit: b9ad1c632d77b9697667603832f9fcce700957c6
Parents: fa79185
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Oct 29 12:27:02 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Oct 29 12:27:02 2014 +0530
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/b9ad1c63/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 526f454..2690ef8 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -398,7 +398,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
autocompletions = uuids
search_string = value
- if subject != "":
+ if subject != "" and line.split(" ")[-1].find('=') == -1:
autocompletions.append("filter=")
return [s for s in autocompletions if s.startswith(search_string)]
[2/2] git commit: cloudmonkey: Implement caching mechanism for
paramcompletion background calls
Posted by bh...@apache.org.
cloudmonkey: Implement caching mechanism for paramcompletion background calls
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/78920d02
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/78920d02
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/78920d02
Branch: refs/heads/master
Commit: 78920d02a849577afe43a6f1057c510413a577eb
Parents: b9ad1c6
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Oct 29 12:27:25 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Oct 29 12:27:25 2014 +0530
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 47 ++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/78920d02/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index 2690ef8..efe90e4 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -22,13 +22,14 @@ try:
import argparse
import atexit
import cmd
+ import copy
import json
import logging
import os
import shlex
import sys
+ import time
import types
- import copy
import urllib
from cachemaker import loadcache, savecache, monkeycache, splitverbsubject
@@ -73,6 +74,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
config_options = []
profile_names = []
verbs = []
+ param_cache = {}
prompt = "🐵 > "
protocol = "http"
host = "localhost"
@@ -385,16 +387,41 @@ class CloudMonkeyShell(cmd.Cmd, object):
related = filter(lambda x: x['name'] == param,
params)[0]['related']
api = min(filter(lambda x: 'list' in x, related), key=len)
- response = self.make_request(api, args={'listall': 'true'})
- responsekey = filter(lambda x: 'response' in x,
- response.keys())[0]
- result = response[responsekey]
uuids = []
- for key in result.keys():
- if isinstance(result[key], list):
- for element in result[key]:
- if 'id' in element.keys():
- uuids.append(element['id'])
+ if api in self.param_cache.keys() and self.param_cache[api]["ts"] > (int(time.time()) - 1000):
+ for option in self.param_cache[api]["options"]:
+ uuid = option[0]
+ name = option[1]
+ if uuid.startswith(value):
+ uuids.append(uuid)
+ else:
+ response = self.make_request(api, args={'listall': 'true', 'templatefilter': 'all'})
+ responsekey = filter(lambda x: 'response' in x,
+ response.keys())[0]
+ result = response[responsekey]
+ self.param_cache[api] = {}
+ self.param_cache[api]["ts"] = int(time.time())
+ self.param_cache[api]["options"] = []
+ for key in result.keys():
+ if isinstance(result[key], list):
+ for element in result[key]:
+ if 'id' in element.keys():
+ uuid = element['id']
+ name = ""
+ if 'name' in element.keys():
+ name = element['name']
+ elif 'username' in element.keys():
+ name = element['username']
+ self.param_cache[api]["options"].append((uuid, name,))
+ uuids.append(uuid)
+
+ if len(uuids) > 1:
+ print "\n"
+ for option in self.param_cache[api]["options"]:
+ uuid = option[0]
+ name = option[1]
+ if uuid.startswith(value):
+ print uuid, name
autocompletions = uuids
search_string = value