5 from sfa.util.misc import *
6 from sfa.util.genitable import GeniTable
7 from sfa.util.geniclient import GeniClient
8 from sfa.plc.api import GeniAPI
9 from sfa.util.config import Config
10 from sfa.trust.hierarchy import Hierarchy
11 from sfa.util.report import trace, error
12 from sfa.server.registry import Registries
13 from sfa.util.xmlrpcprotocol import ServerException
18 if not config.SFA_REGISTRY_ENABLED:
21 # Get the path to the sfa server key/cert files from
22 # the sfa hierarchy object
23 sfa_hierarchy = Hierarchy()
24 sfa_key_path = sfa_hierarchy.basedir
25 key_file = os.path.join(sfa_key_path, "server.key")
26 cert_file = os.path.join(sfa_key_path, "server.cert")
28 # get a connection to our local sfa registry
29 # and a valid credential
30 authority = config.SFA_INTERFACE_HRN
31 url = 'http://%s:%s/' %(config.SFA_REGISTRY_HOST, config.SFA_REGISTRY_PORT)
32 registry = GeniClient(url, key_file, cert_file)
33 sfa_api = GeniAPI(key_file = key_file, cert_file = cert_file, interface='registry')
34 credential = sfa_api.getCredential()
37 registries = Registries(sfa_api)
40 # get local peer records
42 peer_records = table.find({'~peer_authority': None})
43 for peer_record in peer_records:
44 peer_auth = peer_record['peer_authority']
45 if peer_auth in registries:
47 records = registries[peer_auth].resolve(credential, peer_record['hrn'])
48 except ServerException:
49 # an exception will be thrown if the record doenst exist
50 # if so remove the record from the local registry
51 registries[sfa_api.hrn].remove_peer_object(credential, peer_record)
54 if __name__ == '__main__':