X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclientbin%2Fsfaadmin.py;h=e722e6b68af533e650514e69b16969f8e0a6d3b7;hb=2b76bf5ac8877b5bb82726126a7690873395f4fd;hp=276943b63515368577c8ca5f4aecdd1ee64ac626;hpb=6a9f8253aa3830363b1ac4917b77c287aabc9cc2;p=sfa.git diff --git a/sfa/clientbin/sfaadmin.py b/sfa/clientbin/sfaadmin.py index 276943b6..e722e6b6 100755 --- a/sfa/clientbin/sfaadmin.py +++ b/sfa/clientbin/sfaadmin.py @@ -238,24 +238,35 @@ class SliceManagerCommands(AggregateCommands): self.api= Generic.the_flavour().make_api(interface='slicemgr') -CATEGORIES = {'registry': RegistryCommands, +CATEGORIES = {'cert': CertificateCommands, + 'registry': RegistryCommands, 'aggregate': AggregateCommands, 'slicemgr': SliceManagerCommands} +def category_usage(): + print "Available categories:" + for k in CATEGORIES: + print "\t%s" % k def main(): argv = copy.deepcopy(sys.argv) script_name = argv.pop(0) + # ensure category is specified if len(argv) < 1: print script_name + " category action []" - print "Available categories:" - for k in CATEGORIES: - print "\t%s" % k + category_usage() sys.exit(2) + # ensure category is valid category = argv.pop(0) usage = "%%prog %s action [options]" % (category) parser = OptionParser(usage=usage) - command_class = CATEGORIES[category] + command_class = CATEGORIES.get(category, None) + if not command_class: + print "no such category %s " % category + category_usage() + sys.exit(2) + + # ensure command is valid command_instance = command_class() actions = command_instance._get_commands() if len(argv) < 1: @@ -272,6 +283,7 @@ def main(): action = argv.pop(0) command = getattr(command_instance, action) + # ensure options are valid options = getattr(command, 'options', []) usage = "%%prog %s %s [options]" % (category, action) parser = OptionParser(usage=usage) @@ -285,6 +297,7 @@ def main(): if v is None: del cmd_kwds[k] + # execute commadn try: command(*cmd_args, **cmd_kwds) sys.exit(0)