using sfa.util.namespace instead of sfa.util.misc
[sfa.git] / sfa / server / sfa-clean-peer-records.py
index fbf3b68..1a858ce 100644 (file)
@@ -2,11 +2,13 @@
 
 import sys
 import os
-from sfa.util.misc import *
+import traceback
+from sfa.util.namespace 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
@@ -24,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
@@ -36,7 +39,6 @@ def main():
     # get peer registries
     registries = Registries(sfa_api)
 
-
     # get local peer records
     table = GeniTable()
     peer_records = table.find({'~peer_authority': None})
@@ -44,12 +46,14 @@ def main():
         peer_auth = peer_record['peer_authority']
         if peer_auth in registries:
             try:
-                records = registries[peer_auth].resolve(credential, peer_record['hrn'])
-            except ServerException:    
+                peer_record_hrn = peer_record['hrn']
+                arg_list = [credential, peer_record_hrn]
+                records = registries[peer_auth].resolve(credential, peer_record_hrn)
+            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)
-            except:    
-               pass
+            except:
+                traceback.print_exc()
 if __name__ == '__main__':
     main()