def __init__(self):
self.AuthHierarchy = Hierarchy()
- self.TrustedRoots = TrustedRootList()
-
self.config = Config()
+ self.TrustedRoots = TrustedRootList(Config.get_trustedroots_dir(self.config))
self.plc_auth = self.config.get_plc_auth()
self.root_auth = self.config.SFA_REGISTRY_ROOT_AUTH
self.level1_auth = self.config.SFA_REGISTRY_LEVEL1_AUTH
if not auth_record:
auth_record = GeniRecord(hrn=hrn, gid=auth_info.get_gid_object(), type="authority", pointer=-1)
+ auth_record['authority'] = get_authority(auth_record['hrn'])
trace(" inserting authority record for " + hrn)
table.insert(auth_record)
person_gid = AuthHierarchy.create_gid(hrn, create_uuid(), pkey)
table = GeniTable()
person_record = GeniRecord(hrn=hrn, gid=person_gid, type="user", pointer=person['person_id'])
- try:
+ person_record['authority'] = get_authority(person_record['hrn'])
+ existing_records = table.find({'hrn': hrn, 'type': 'user', 'pointer': person['person_id']})
+ if not existing_records:
table.insert(person_record)
- except:
+ else:
trace("Import: %s exists, updating " % hrn)
- existing_record = table.find(person_record)
+ existing_record = existing_records[0]
person_record['record_id'] = existing_record['record_id']
table.update(person_record)
pkey = Keypair(create=True)
slice_gid = AuthHierarchy.create_gid(hrn, create_uuid(), pkey)
slice_record = GeniRecord(hrn=hrn, gid=slice_gid, type="slice", pointer=slice['slice_id'])
+ slice_record['authority'] = get_authority(slice_record['hrn'])
table = GeniTable()
- try:
+ existing_records = table.find({'hrn': hrn, 'type': 'slice', 'pointer': slice['slice_id']})
+ if not existing_records:
table.insert(slice_record)
- except:
+ else:
trace("Import: %s exists, updating " % hrn)
- existing_record = table.find(slice_record)
+ existing_record = existing_records[0]
slice_record['record_id'] = existing_record['record_id']
table.update(slice_record)
pkey = Keypair(create=True)
node_gid = AuthHierarchy.create_gid(hrn, create_uuid(), pkey)
node_record = GeniRecord(hrn=hrn, gid=node_gid, type="node", pointer=node['node_id'])
- try:
+ node_record['authority'] = get_authority(node_record['hrn'])
+ existing_records = table.find({'hrn': hrn, 'type': 'node', 'pointer': node['node_id']})
+ if not existing_records:
table.insert(node_record)
- except:
+ else:
trace("Import: %s exists, updating " % hrn)
- existing_record = table.find(node_record)
+ existing_record = existing_records[0]
node_record['record_id'] = existing_record['record_id']
table.update(node_record)
table = GeniTable()
auth_record = GeniRecord(hrn=hrn, gid=auth_info.get_gid_object(), type="authority", pointer=site['site_id'])
- try:
+ auth_record['authority'] = get_authority(auth_record['hrn'])
+ existing_records = table.find({'hrn': hrn, 'type': 'authority', 'pointer': site['site_id']})
+ if not existing_records:
table.insert(auth_record)
- except:
+ else:
trace("Import: %s exists, updating " % hrn)
- existing_record = table.find(auth_record)
+ existing_record = existing_record[0]
auth_record['record_id'] = existing_record['record_id']
table.update(auth_record)