5 # This wrapper implements the Geni Registry and Slice Interfaces on PLC.
6 # Depending on command line options, it starts some combination of a
7 # Registry, an Aggregate Manager, and a Slice Manager.
9 # There are several items that need to be done before starting the wrapper
12 # NOTE: Many configuration settings, including the PLC maintenance account
13 # credentials, URI of the PLCAPI, and PLC DB URI and admin credentials are initialized
14 # from your MyPLC configuration (/etc/planetlab/plc_config*). Please make sure this information
15 # is up to date and accurate.
17 # 1) Import the existing planetlab database, creating the
18 # appropriate geni records. This is done by running the "gimport.py" tool.
20 # 2) Create a "trusted_roots" directory and place the certificate of the root
21 # authority in that directory. Given the defaults in gimport.py, this
22 # certificate would be named "planetlab.gid". For example,
24 # mkdir trusted_roots; cp authorities/planetlab.gid trusted_roots/
26 # TODO: Can all three servers use the same "registry" certificate?
29 # TCP ports for the three servers
35 from optparse import OptionParser
37 from geni.util.hierarchy import Hierarchy
38 from geni.util.trustedroot import TrustedRootList
39 from geni.util.cert import Keypair, Certificate
40 from geni.registry import Registry
41 from geni.aggregate import Aggregate
42 from geni.slicemgr import SliceMgr
51 # Generate command line parser
52 parser = OptionParser(usage="plc [options]")
53 parser.add_option("-r", "--registry", dest="registry", action="store_true",
54 help="run registry server", default=False)
55 parser.add_option("-s", "--slicemgr", dest="sm", action="store_true",
56 help="run slice manager", default=False)
57 parser.add_option("-a", "--aggregate", dest="am", action="store_true",
58 help="run aggregate manager", default=False)
59 parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
60 help="verbose mode", default=False)
61 (options, args) = parser.parse_args()
63 key_file = "server.key"
64 cert_file = "server.cert"
66 if (os.path.exists(key_file)) and (not os.path.exists(cert_file)):
67 # If private key exists and cert doesnt, recreate cert
68 key = Keypair(filename=key_file)
69 cert = Certificate(subject="registry")
70 cert.set_issuer(key=key, subject="registry")
73 cert.save_to_file(cert_file)
75 elif (not os.path.exists(key_file)) or (not os.path.exists(cert_file)):
76 # if no key is specified, then make one up
77 key = Keypair(create=True)
78 key.save_to_file(key_file)
79 cert = Certificate(subject="registry")
80 cert.set_issuer(key=key, subject="registry")
83 cert.save_to_file(cert_file)
85 AuthHierarchy = Hierarchy()
87 TrustedRoots = TrustedRootList()
89 # start registry server
90 if (options.registry):
91 r = Registry("", registry_port, key_file, cert_file)
92 r.trusted_cert_list = TrustedRoots.get_list()
93 r.hierarchy = AuthHierarchy
96 # start aggregate manager
98 a = Aggregate("", aggregate_port, key_file, cert_file)
99 a.trusted_cert_list = TrustedRoots.get_list()
102 # start slice manager
104 s = SliceMgr("", slicemgr_port, key_file, cert_file)
105 s.trusted_cert_list = TrustedRoots.get_list()
108 if __name__ == "__main__":