4 # This wrapper implements the Geni Registry and Slice Interfaces on PLC.
5 # Depending on command line options, it starts some combination of a
6 # Registry, an Aggregate Manager, and a Slice Manager.
8 # There are several items that need to be done before starting the wrapper
11 # 1) Update util/config.py to match the parameters of your PLC installation.
13 # 2) Import the existing planetlab database, creating the
14 # appropriate geni records. This is done by running the "import.py" tool.
16 # 3) Create a "trusted_roots" directory and place the certificate of the root
17 # authority in that directory. Given the defaults in import.py, this
18 # certificate would be named "planetlab.gid". For example,
20 # mkdir trusted_roots; cp authorities/planetlab.gid trusted_roots/
22 # TODO: Can all three servers use the same "registry" certificate?
25 # TCP ports for the three servers
31 from optparse import OptionParser
33 from util.hierarchy import Hierarchy
34 from util.trustedroot import TrustedRootList
35 from util.cert import Keypair, Certificate
36 from registry import Registry
37 #from aggregate import Aggregate
38 from slicemgr import SliceMgr
47 # Generate command line parser
48 parser = OptionParser(usage="plc [options]")
49 parser.add_option("-r", "--registry", dest="registry", action="store_true",
50 help="run registry server", default=False)
51 parser.add_option("-s", "--slicemgr", dest="sm", action="store_true",
52 help="run slice manager", default=False)
53 parser.add_option("-a", "--aggregate", dest="am", action="store_true",
54 help="run aggregate manager", default=False)
55 parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
56 help="verbose mode", default=False)
57 (options, args) = parser.parse_args()
59 key_file = "server.key"
60 cert_file = "server.cert"
62 # if no key is specified, then make one up
63 if (not os.path.exists(key_file)) or (not os.path.exists(cert_file)):
64 key = Keypair(create=True)
65 key.save_to_file(key_file)
67 cert = Certificate(subject="registry")
68 cert.set_issuer(key=key, subject="registry")
71 cert.save_to_file(cert_file)
73 AuthHierarchy = Hierarchy()
75 TrustedRoots = TrustedRootList()
77 # start registry server
78 if (options.registry):
79 r = Registry("", registry_port, key_file, cert_file)
80 r.trusted_cert_list = TrustedRoots.get_list()
81 r.hierarchy = AuthHierarchy
84 # start aggregate manager
86 a = Aggregate("", aggregate_port, key_file, cert_file)
87 a.trusted_cert_list = TrustedRoots.get_list()
92 s = SliceMgr("", slicemgr_port, key_file, cert_file)
93 s.trusted_cert_list = TrustedRoots.get_list()
96 if __name__ == "__main__":