dont attempt to sync interface info every time the interfaces class is instantiated...
authorTony Mack <tmack@cs.princeton.edu>
Tue, 6 Apr 2010 21:17:53 +0000 (21:17 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 6 Apr 2010 21:17:53 +0000 (21:17 +0000)
sfa/server/interface.py
sfa/server/sfa-server.py
sfa/util/server.py

index ca72b80..9b4c039 100644 (file)
@@ -54,14 +54,21 @@ class Interfaces(dict):
             raise SfaInfaildArgument('Invalid type %s: must be in %s' % (type, self.types))    
         dict.__init__(self, {})
         self.api = api
-        
+        self.type = type  
         # load config file
         self.interface_info = XmlStorage(conf_file, self.default_dict)
         self.interface_info.load()
         self.interfaces = self.interface_info.values()[0].values()[0]
         if not isinstance(self.interfaces, list):
             self.interfaces = [self.interfaces]
-        
+        # get connections
+        self.update(self.get_connections(self.interfaces))
+
+    def sync_interfaces(self):
+        """
+        Install missing trusted gids and db records for our federated
+        interfaces
+        """     
         # Attempt to get any missing peer gids
         # There should be a gid file in /etc/sfa/trusted_roots for every
         # peer registry found in in the registries.xml config file. If there
@@ -73,11 +80,8 @@ class Interfaces(dict):
         self.get_peer_gids(new_hrns)
 
         # update the local db records for these registries
-        self.update_db_records(type)
+        self.update_db_records(self.type)
         
-        # create connections to the registries
-        self.update(self.get_connections(self.interfaces))
-
     def get_peer_gids(self, new_hrns):
         """
         Install trusted gids from the specified interfaces.  
index d492f7a..58bfdb9 100755 (executable)
@@ -43,6 +43,9 @@ from sfa.trust.certificate import Keypair, Certificate
 from sfa.trust.hierarchy import Hierarchy
 from sfa.util.config import Config
 from sfa.util.report import trace
+from sfa.plc.api import SfaAPI
+from sfa.server.registry import Registries
+from sfa.server.aggregate import Aggregates
 
 # after http://www.erlenstar.demon.co.uk/unix/faq_2.html
 def daemon():
@@ -147,6 +150,17 @@ def init_server(options, config):
             manager.init_server()    
             
 
+def sync_interfaces():
+    """
+    Attempt to install missing trusted gids and db records for 
+    our federated interfaces
+    """
+    api = SfaAPI()
+    registries = Registries(api)
+    aggregates = Aggregates(api)
+    registries.sync_interfaces()
+    aggregates.sync_interfaces()
+
 def main():
     # xxx get rid of globals - name consistently CamelCase or under_score
     global AuthHierarchy
@@ -179,7 +193,8 @@ def main():
     server_cert_file = os.path.join(hierarchy.basedir, "server.cert")
 
     init_server_key(server_key_file, server_cert_file, config, hierarchy)
-    init_server(options, config)   
+    init_server(options, config)
+    sync_interfaces()   
  
     # start registry server
     if (options.registry):
index 197297d..38bbfca 100644 (file)
@@ -101,12 +101,6 @@ class SecureXMLRpcRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
                               cert_file = self.server.cert_file)
             # get arguments
             request = self.rfile.read(int(self.headers["content-length"]))
-            # In previous versions of SimpleXMLRPCServer, _dispatch
-            # could be overridden in this class, instead of in
-            # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
-            # check to see if a subclass implements _dispatch and dispatch
-            # using that method if present.
-            #response = self.server._marshaled_dispatch(request, getattr(self, '_dispatch', None))
             remote_addr = (remote_ip, remote_port) = self.connection.getpeername()
             self.api.remote_addr = remote_addr
             response = self.api.handle(remote_addr, request)