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 2016/01/19 15:50:25 UTC
[1/2] cloudstack-cloudmonkey git commit: Summary: Allow 'sync' as a
verb without overriding the cloudmonkey sync implementation
Repository: cloudstack-cloudmonkey
Updated Branches:
refs/heads/master f7d04378c -> 20910ff12
Summary: Allow 'sync' as a verb without overriding the cloudmonkey sync implementation
BUG-ID: CLOUDSTACK-9233
Reviewed-by: Frank Maximus <fr...@nuagenetworks.net>
Reported-by :Eric Waegeman <er...@nuagenetworks.net>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/47c2698f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/47c2698f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/47c2698f
Branch: refs/heads/master
Commit: 47c2698fd230f6652438b1858ed8b9f3691f3c23
Parents: 32b110a
Author: Eric Waegeman <er...@alcatel-lucent.com>
Authored: Wed Jan 13 15:48:38 2016 +0100
Committer: Eric Waegeman <er...@alcatel-lucent.com>
Committed: Wed Jan 13 18:17:35 2016 +0100
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/47c2698f/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index b057a2a..f70cf03 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -96,6 +96,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
hook_count = 0
def __init__(self, pname, cfile):
+ self.default_apis = self.completenames('')
self.program_name = pname
self.config_file = cfile
self.config_options = read_config(self.get_attr, self.set_attr,
@@ -169,9 +170,21 @@ class CloudMonkeyShell(cmd.Cmd, object):
self.verbs = self.apicache['verbs']
for verb in self.verbs:
+ handler_name = "do_" + str(verb)
+ handler_doc = str("%ss resources" % verb.capitalize())
+
+ if hasattr(self, handler_name) and getattr(self, handler_name).__doc__ == handler_doc:
+ continue
+
def add_grammar(verb):
+ default_handler = None
+ if self.default_apis.__contains__(verb):
+ default_handler = getattr(self, handler_name)
+
def grammar_closure(self, args):
if not args:
+ if default_handler:
+ default_handler(args)
return
args = args.decode("utf-8")
if self.pipe_runner(u"{0} {1}".format(verb, args)):
@@ -184,15 +197,18 @@ class CloudMonkeyShell(cmd.Cmd, object):
cmd = self.apicache[verb][args_partition[0]]['name']
args = args_partition[2]
except KeyError, e:
- self.monkeyprint("Error: invalid %s api arg " % verb,
+ if default_handler:
+ default_handler(args)
+ else:
+ self.monkeyprint("Error: invalid %s api arg " % verb,
str(e))
return
self.default(u"{0} {1}".format(cmd, args))
return grammar_closure
grammar_handler = add_grammar(verb)
- grammar_handler.__doc__ = "%ss resources" % verb.capitalize()
- grammar_handler.__name__ = "do_" + str(verb)
+ grammar_handler.__doc__ = handler_doc
+ grammar_handler.__name__ = handler_name
setattr(self.__class__, grammar_handler.__name__, grammar_handler)
def monkeyprint(self, *args):
@@ -670,7 +686,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
separator = mline[1]
value = mline[2].lstrip()
if separator == "":
- return [s for s in self.config_options if s.startswith(option)]
+ return [s for s in self.config_options if s.startswith(option)] + self.completedefault(text, line, begidx, endidx)
elif option == "profile":
return [s for s in self.profile_names if s.startswith(value)]
elif option == "display":
@@ -679,6 +695,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
elif option in ["asyncblock", "color", "paramcompletion",
"verifysslcert"]:
return [s for s in ["true", "false"] if s.startswith(value)]
+ elif "set" in self.apicache["verbs"]:
+ return self.completedefault(text, line, begidx, endidx)
return []
[2/2] cloudstack-cloudmonkey git commit: Merge pull request #12 from
'waegemae/master'
Posted by bh...@apache.org.
Merge pull request #12 from 'waegemae/master'
Allow 'sync' as a verb without overriding the cloudmonkey sync implementation
BUG-ID: CLOUDSTACK-9233
Reviewed-by: Frank Maximus frank.maximus@nuagenetworks.net
Reported-by :Eric Waegeman eric.waegeman@nuagenetworks.net
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/20910ff1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/20910ff1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/20910ff1
Branch: refs/heads/master
Commit: 20910ff126d4d6e7adad72d46b01a162cf2f9adb
Parents: f7d0437 47c2698
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Tue Jan 19 15:47:59 2016 +0100
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Tue Jan 19 15:50:09 2016 +0100
----------------------------------------------------------------------
cloudmonkey/cloudmonkey.py | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/20910ff1/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------