X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fserver%2Fsfa-clean-peer-records.py;h=3a34fbcc7bb5d5d7281aca976df186ac50208070;hb=7e85c7c9539ba8e8c21940ab6d620961c4eec009;hp=bcb917bc5627d0d5d468f1ee3c4156e0dc853dde;hpb=0225ac44fbf7a9c6b9bfd152c2e97315da39e1c4;p=sfa.git diff --git a/sfa/server/sfa-clean-peer-records.py b/sfa/server/sfa-clean-peer-records.py index bcb917bc..3a34fbcc 100644 --- a/sfa/server/sfa-clean-peer-records.py +++ b/sfa/server/sfa-clean-peer-records.py @@ -12,7 +12,8 @@ from sfa.trust.certificate import Keypair from sfa.trust.hierarchy import Hierarchy from sfa.server.registry import Registries -from sfa.storage.table import SfaTable +from sfa.storage.alchemy import dbsession +from sfa.storage.persistentobjs import RegRecord from sfa.client.sfaserverproxy import SfaServerProxy @@ -45,15 +46,14 @@ def main(): tree.load(registries.keys()) # get local peer records - table = SfaTable() - peer_records = table.find({'~peer_authority': None}) + peer_records=dbsession.query(RegRecord).filter (RegRecord.peer_authority != None).all() found_records = [] hrn_dict = {} for record in peer_records: - registry_hrn = tree.best_match(record['hrn']) + registry_hrn = tree.best_match(record.hrn) if registry_hrn not in hrn_dict: hrn_dict[registry_hrn] = [] - hrn_dict[registry_hrn].append(record['hrn']) + hrn_dict[registry_hrn].append(record.hrn) # attempt to resolve the record at the authoritative interface for registry_hrn in hrn_dict: @@ -75,8 +75,8 @@ def main(): # remove what wasnt found for peer_record in peer_records: - if peer_record['hrn'] not in found_records: - registries[sfa_api.hrn].Remove(peer_record['hrn'], credential, peer_record['type']) + if peer_record.hrn not in found_records: + registries[sfa_api.hrn].Remove(peer_record.hrn, credential, peer_record.type) if __name__ == '__main__': main()