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