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
16 if not config.SFA_REGISTRY_ENABLED:
19 # Get the path to the sfa server key/cert files from
20 # the sfa hierarchy object
21 sfa_hierarchy = Hierarchy()
22 sfa_key_path = sfa_hierarchy.basedir
23 key_file = os.path.join(sfa_key_path, "server.key")
24 cert_file = os.path.join(sfa_key_path, "server.cert")
26 # get a connection to our local sfa registry
27 # and a valid credential
28 authority = config.SFA_INTERFACE_HRN
29 url = 'http://%s:%s/' %(config.SFA_REGISTRY_HOST, config.SFA_REGISTRY_PORT)
30 registry = GeniClient(url, key_file, cert_file)
31 sfa_api = GeniAPI(key_file = key_file, cert_file = cert_file, interface='registry')
32 credential = sfa_api.getCredential()
35 registries = Registries(sfa_api)
38 # get local peer records
40 peer_records = table.find({'~peer_authority': None})
42 # get a list of authorities contained in the peer record list
43 for peer_record in peer_records:
44 peer_auth = peer_record['peer_authority']
45 if peer_auth in registries:
46 records = registries[peer_auth].resolve(credential, peer_record['hrn'])
48 table.remove(peer_record)
50 if __name__ == '__main__':