3 # sfi -- slice-based facility interface
7 #from cert import Keypair, Certificate
8 from optparse import OptionParser
10 def create_cmd_parser(command):
11 cmdargs = {"list": "name",
15 "update": "name record",
19 "create": "name rspec",
25 if command not in cmdargs:
26 print "Invalid command\n"
27 print "Commands:list,show,delete,add,update,nodes,slices,resources,create,delete,start,stop,reset"
30 parser = OptionParser(usage="sfi [sfi_options] %s [options] %s" \
31 % (command, cmdargs[command]))
32 if command in ("nodes", "resources"):
33 parser.add_option("-f", "--format", dest="format",type="choice",
34 help="output format (dns|ip|hrn|rspec)",default="rspec",
35 choices=("dns","ip","hrn","rspec"))
36 elif command in ("list", "show", "delete"):
37 parser.add_option("-t", "--type", dest="type",type="choice",
38 help="type filter (user|slice|sa|ma|node|aggregate)",
39 choices=("user","slice","sa","ma","node","aggregate"))
43 parser = OptionParser(usage="sfi [options] command [command_options] [command_args]",
44 description="Commands: list,show,delete,add,update,nodes,slices,resources,create,delete,start,stop,reset")
45 parser.add_option("-r", "--registry", dest="registry",
46 help="root registry", metavar="URL")
47 parser.add_option("-s", "--slicemgr", dest="sm",
48 help="slice manager", metavar="URL")
49 parser.add_option("-d", "--dir", dest="dir",
50 help="working directory", metavar="PATH")
51 parser.add_option("-v", "--verbose",
52 action="store_true", dest="verbose", default=False,
54 parser.disable_interspersed_args()
55 (options, args) = parser.parse_args()
57 (cmd_opts, cmd_args) = create_cmd_parser(command).parse_args(args[1:])
59 print options.registry,options.sm,options.dir,options.verbose
61 if command in ("nodes", "resources"):
63 elif command in ("list","show","delete"):
68 if __name__=="__main__":