From 6c527ffbbaeafd3a697f3f7bf3222e12646f7d22 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sun, 27 Jan 2013 04:17:30 -0800 Subject: [PATCH] cli: Fix cachegen aand cloudmonkey to generate api verbs, revert last commit Fixes cachegen and reverts "mvn: fix cloudmonkey build" This reverts commit 6d3de41d4262abeedab234a08e8fb5714b69a9bf. --- tools/cli/cloudmonkey/cachegen.py | 11 ++++++++--- tools/cli/cloudmonkey/cloudmonkey.py | 2 +- tools/cli/pom.xml | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/cli/cloudmonkey/cachegen.py b/tools/cli/cloudmonkey/cachegen.py index e03b6fddf89..509c0c68587 100644 --- a/tools/cli/cloudmonkey/cachegen.py +++ b/tools/cli/cloudmonkey/cachegen.py @@ -16,11 +16,13 @@ # under the License. try: - from common import grammar + import re from marvin.cloudstackAPI import * from marvin import cloudstackAPI except ImportError, e: - pass + import sys + print "ImportError", e + sys.exit(1) completions = cloudstackAPI.__all__ @@ -43,9 +45,12 @@ def main(): completing commands and help docs. This reduces the overall search and cache_miss (computation) complexity from O(n) to O(1) for any valid cmd. """ + pattern = re.compile("[A-Z]") + verbs = list(set([x[:pattern.search(x).start()] for x in completions + if pattern.search(x) is not None]).difference(['cloudstack'])) # datastructure {'verb': {cmd': ['api', [params], doc, required=[]]}} cache_verbs = {} - for verb in grammar: + for verb in verbs: completions_found = filter(lambda x: x.startswith(verb), completions) cache_verbs[verb] = {} for api_name in completions_found: diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index aabcde543fb..ecd0c82fb11 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -514,7 +514,7 @@ class CloudMonkeyShell(cmd.Cmd, object): def main(): pattern = re.compile("[A-Z]") verbs = list(set([x[:pattern.search(x).start()] for x in completions - if pattern.search(x) is not None])) + if pattern.search(x) is not None]).difference(['cloudstack'])) for verb in verbs: def add_grammar(verb): def grammar_closure(self, args): diff --git a/tools/cli/pom.xml b/tools/cli/pom.xml index c76cd650d42..aba5ec3c2a5 100644 --- a/tools/cli/pom.xml +++ b/tools/cli/pom.xml @@ -71,6 +71,20 @@ + + cachegen + compile + + exec + + + ${basedir}/cloudmonkey + python + + cachegen.py + + + package compile