- # remove any record in existing_hrns that does not
- # have a plc record
- site_existing_records_only = lambda (r_hrn, r_type): r_hrn.startswith(site_hrn)
- site_existing_records = filter(site_existing_records_only, existing_records.keys())
- for (record_hrn, type) in site_existing_records:
- found = False
- if type == 'user':
- for person in persons_dict.values():
- tmp_hrn = email_to_hrn(site_hrn, person['email'])
- if record_hrn == tmp_hrn:
- found = True
-
- elif type == 'node':
- for node in nodes_dict.values():
- tmp_hrn = hostname_to_hrn(import_auth, site['login_base'], node['hostname'])
- if record_hrn == tmp_hrn:
- found = True
- elif type == 'slice':
- for slice in slices_dict.values():
- tmp_hrn = slicename_to_hrn(import_auth, slice['name'])
- if record_hrn == tmp_hrn:
- found = True
- else:
- continue
-
- if not found:
- trace("Import: Removing %s %s" % (type, record_hrn))
- record_object = existing_records[(record_hrn, type)]
- sfaImporter.delete_record(record_hrn, type)
-
- # remove stale site_records
- site_records_only = lambda(r_hrn, r_type): r_type == 'authority' and r_hrn != import_auth
- site_records = filter(site_records_only, existing_records.keys())
- for (record_hrn, type) in site_records: