cli: Fix cachegen aand cloudmonkey to generate api verbs, revert last commit

Fixes cachegen and reverts "mvn: fix cloudmonkey build"

This reverts commit 6d3de41d42.
This commit is contained in:
Rohit Yadav 2013-01-27 04:17:30 -08:00
parent 6d3de41d42
commit 6c527ffbba
3 changed files with 23 additions and 4 deletions

View File

@ -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:

View File

@ -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):

View File

@ -71,6 +71,20 @@
</arguments>
</configuration>
</execution>
<execution>
<id>cachegen</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${basedir}/cloudmonkey</workingDirectory>
<executable>python</executable>
<arguments>
<argument>cachegen.py</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>package</id>
<phase>compile</phase>