X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclientbin%2Fsfaadmin.py;h=2bf1d0c4fdfe165e1f60d24b52971e5cd4e5d046;hb=9d5668aadd696be064aaa0177a46da7dd89ebd8c;hp=276943b63515368577c8ca5f4aecdd1ee64ac626;hpb=6a9f8253aa3830363b1ac4917b77c287aabc9cc2;p=sfa.git diff --git a/sfa/clientbin/sfaadmin.py b/sfa/clientbin/sfaadmin.py index 276943b6..2bf1d0c4 100755 --- a/sfa/clientbin/sfaadmin.py +++ b/sfa/clientbin/sfaadmin.py @@ -238,24 +238,36 @@ 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 +284,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 +298,7 @@ def main(): if v is None: del cmd_kwds[k] + # execute commadn try: command(*cmd_args, **cmd_kwds) sys.exit(0)