refactored
authorTony Mack <tmack@cs.princeton.edu>
Fri, 7 May 2010 22:54:57 +0000 (22:54 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Fri, 7 May 2010 22:54:57 +0000 (22:54 +0000)
sfa/managers/registry_manager_pl.py
sfa/server/aggregate.py
sfa/server/interface.py
sfa/server/registry.py

index 1af2caf..2486738 100644 (file)
@@ -129,7 +129,7 @@ def list(api, xrn, origin_hrn=None):
     tree = prefixTree()
     tree.load(registry_hrns)
     registry_hrn = tree.best_match(hrn)
-    
+   
     #if there was no match then this record belongs to an unknow registry
     if not registry_hrn:
         raise MissingAuthority(xrn)
index ce66048..3793a83 100644 (file)
@@ -31,20 +31,12 @@ class Aggregates(Interfaces):
  
     def __init__(self, api, conf_file = "/etc/sfa/aggregates.xml"):
         Interfaces.__init__(self, api, conf_file, 'ma')
-
-    def get_connections(self, interfaces):
-        """
-        Get connection details for the trusted peer aggregates from file and 
-        create an connection to each. 
-        """
-        connections = Interfaces.get_connections(self, interfaces)
-
         # set up a connection to the local registry
         address = self.api.config.SFA_AGGREGATE_HOST
         port = self.api.config.SFA_AGGREGATE_PORT
         url = 'http://%(address)s:%(port)s' % locals()
         local_aggregate = {'hrn': self.api.hrn, 'addr': address, 'port': port}
-        self.interfaces[self.api.hrn] = local_aggregate 
-        connections[self.api.hrn] = xmlrpcprotocol.get_server(url, self.api.key_file, self.api.cert_file)
-        return connections
+        self.interfaces[self.api.hrn] = local_aggregate
 
+        # get connections
+        self.update(self.get_connections())
index 8e5822e..5099e9f 100644 (file)
@@ -65,8 +65,6 @@ class Interfaces(dict):
         for interface in interfaces:
             self.interfaces[interface['hrn']] = interface
 
-        # get connections
-        self.update(self.get_connections(self.interfaces))
 
     def sync_interfaces(self):
         """
@@ -100,7 +98,7 @@ class Interfaces(dict):
             try:
                 # get gid from the registry
                 interface_info =  self.interfaces[new_hrn]
-                interface = self.get_connections(self.interfaces[new_hrn])[new_hrn]
+                interface = self[new_hrn]
                 trusted_gids = interface.get_trusted_certs()
                 if trusted_gids:
                     # the gid we want shoudl be the first one in the list, 
@@ -167,16 +165,14 @@ class Interfaces(dict):
                 record = SfaRecord(dict=record)
                 table.insert(record)
                         
-    def get_connections(self, interfaces):
+    def get_connections(self):
         """
         read connection details for the trusted peer registries from file return 
         a dictionary of connections keyed on interface hrn. 
         """
         connections = {}
         required_fields = self.default_fields.keys()
-        if not isinstance(interfaces, list):
-            interfaces = [interfaces]
-        for interface in interfaces:
+        for interface in self.interfaces.values():
             # make sure the required fields are present and not null
             if not all([interface.get(key) for key in required_fields]):
                 continue
index 8c60e09..caa128d 100644 (file)
@@ -38,19 +38,11 @@ class Registries(Interfaces):
 
     def __init__(self, api, conf_file = "/etc/sfa/registries.xml"):
         Interfaces.__init__(self, api, conf_file, 'sa') 
-
-    def get_connections(self, interfaces):
-        """
-        read connection details for the trusted peer registries from file return 
-        a dictionary of connections keyed on interface hrn. 
-        """
-        connections = Interfaces.get_connections(self, interfaces)
-
-        # set up a connection to the local registry
         address = self.api.config.SFA_REGISTRY_HOST
         port = self.api.config.SFA_REGISTRY_PORT
         url = 'http://%(address)s:%(port)s' % locals()
         local_registry = {'hrn': self.api.hrn, 'addr': address, 'port': port}
         self.interfaces[self.api.hrn] = local_registry
-        connections[self.api.hrn] = xmlrpcprotocol.get_server(url, self.api.key_file, self.api.cert_file)            
-        return connections 
+       
+        # get connections
+        self.update(self.get_connections())