7 # Import PLC records into the Geni database. It is indended that this tool be
8 # run once to create Geni records that reflect the current state of the
11 # The import tool assumes that the existing PLC hierarchy should all be part
12 # of "planetlab.us" (see the root_auth and level1_auth variables below).
14 # Public keys are extracted from the users' SSH keys automatically and used to
15 # create GIDs. This is relatively experimental as a custom tool had to be
16 # written to perform conversion from SSH to OpenSSL format. It only supports
17 # RSA keys at this time, not DSA keys.
24 from sfa.util.record import *
25 from sfa.util.genitable import GeniTable
26 from sfa.util.misc import *
27 from sfa.util.config import Config
28 from sfa.util.report import trace, error
30 from sfa.trust.certificate import convert_public_key, Keypair
31 from sfa.trust.trustedroot import *
32 from sfa.trust.hierarchy import *
33 from sfa.trust.gid import create_uuid
34 from sfa.plc.sfaImport import *
38 def process_options():
41 (options, args) = getopt.getopt(sys.argv[1:], '', [])
49 root_auth = config.SFA_REGISTRY_ROOT_AUTH
50 level1_auth = config.SFA_REGISTRY_LEVEL1_AUTH
51 sfaImporter = sfaImport()
52 shell = sfaImporter.shell
53 plc_auth = sfaImporter.plc_auth
54 AuthHierarchy = sfaImporter.AuthHierarchy
55 TrustedRoots = sfaImporter.TrustedRoots
57 if not level1_auth or level1_auth in ['']:
60 print "Import: creating top level authorities"
61 sfaImporter.create_top_level_auth_records(root_auth)
63 if not AuthHierarchy.auth_exists(level1_auth):
64 AuthHierarchy.create_auth(level1_auth)
65 sfaImporter.create_top_level_auth_records(level1_auth)
66 import_auth = level1_auth
68 import_auth = root_auth
70 print "Import: adding", root_auth, "to trusted list"
71 root = AuthHierarchy.get_auth_info(root_auth)
72 TrustedRoots.add_gid(root.get_gid_object())
74 sites = shell.GetSites(plc_auth, {'peer_id': None})
75 # create a fake internet2 site first
76 i2site = {'name': 'Internet2', 'abbreviated_name': 'I2',
77 'login_base': 'internet2', 'site_id': -1}
78 sfaImporter.import_site(import_auth, i2site)
81 sfaImporter.import_site(import_auth, site)
83 if __name__ == "__main__":