X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fserver%2Fsfa-clean-peer-records.py;h=111743a541ae3b44da7414f9d6bb734a9f614e94;hb=46d0dba101b2d2ce041e3627fabadb2bed37d9be;hp=635b11498ea0f0769917c4fb4c26c945d9e5277b;hpb=a873096fb18d61f2049b56016dc10cb907bc8763;p=sfa.git diff --git a/sfa/server/sfa-clean-peer-records.py b/sfa/server/sfa-clean-peer-records.py index 635b1149..111743a5 100644 --- a/sfa/server/sfa-clean-peer-records.py +++ b/sfa/server/sfa-clean-peer-records.py @@ -2,14 +2,18 @@ import sys import os +import traceback from sfa.util.misc import * from sfa.util.genitable import GeniTable from sfa.util.geniclient import GeniClient from sfa.plc.api import GeniAPI from sfa.util.config import Config +from sfa.trust.certificate import Keypair from sfa.trust.hierarchy import Hierarchy from sfa.util.report import trace, error from sfa.server.registry import Registries +from sfa.util.xmlrpcprotocol import ServerException +import socket def main(): config = Config() @@ -22,6 +26,7 @@ def main(): sfa_key_path = sfa_hierarchy.basedir key_file = os.path.join(sfa_key_path, "server.key") cert_file = os.path.join(sfa_key_path, "server.cert") + key = Keypair(filename=key_file) # get a connection to our local sfa registry # and a valid credential @@ -42,11 +47,17 @@ def main(): peer_auth = peer_record['peer_authority'] if peer_auth in registries: try: - records = registries[peer_auth].resolve(credential, peer_record['hrn']) - except: + peer_record_hrn = peer_record['hrn'] + arg_list = [credential, peer_record_hrn] + request_hash = key.compute_hash(arg_list) + records = registries[peer_auth].resolve(credential, peer_record_hrn, request_hash) + except ServerException: # an exception will be thrown if the record doenst exist # if so remove the record from the local registry - registries[sfa_api.hrn].remove_peer_object(credential, peer_record) - + arg_list = [credential] + request_hash = key.compute_hash(arg_list) + registries[sfa_api.hrn].remove_peer_object(credential, peer_record, request_hash) + except: + traceback.print_exc() if __name__ == '__main__': main()