diff options
| author | Yuriy Taraday <yorik.sar@gmail.com> | 2011-07-15 10:39:23 +0400 |
|---|---|---|
| committer | Yuriy Taraday <yorik.sar@gmail.com> | 2011-07-15 10:39:23 +0400 |
| commit | 2d645197eb21a783de57cf10366db58fd41866fe (patch) | |
| tree | 6f64a4b5eeff593d67e65f775d21556d2c67c46d | |
| parent | 8a9c8bdc0cf6a79ed37090e595d2290fc900537c (diff) | |
| download | nova-2d645197eb21a783de57cf10366db58fd41866fe.tar.gz nova-2d645197eb21a783de57cf10366db58fd41866fe.tar.xz nova-2d645197eb21a783de57cf10366db58fd41866fe.zip | |
Add possibility to call commands without subcommands.
| -rwxr-xr-x | bin/nova-manage | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index a845ab7a9..da285042f 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -925,6 +925,9 @@ class VersionCommands(object): print _("%s (%s)") %\ (version.version_string(), version.version_string_with_vcs()) + def __call__(self): + self.list() + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -1379,14 +1382,19 @@ def main(): command_object = fn() actions = methods_of(command_object) if len(argv) < 1: - print script_name + " category action [<args>]" - print _("Available actions for %s category:") % category - for k, _v in actions: - print "\t%s" % k - sys.exit(2) - action = argv.pop(0) - matches = lazy_match(action, actions) - action, fn = matches[0] + if hasattr(command_object, '__call__'): + action = '__call__' + fn = command_object.__call__ + else: + print script_name + " category action [<args>]" + print _("Available actions for %s category:") % category + for k, _v in actions: + print "\t%s" % k + sys.exit(2) + else: + action = argv.pop(0) + matches = lazy_match(action, actions) + action, fn = matches[0] # For not decorated methods options = getattr(fn, 'options', '') |
