From b3eb20067d71d92432ac4368fe89c08a7bf5fdcb Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Tue, 6 Apr 2010 21:17:53 +0000 Subject: [PATCH] dont attempt to sync interface info every time the interfaces class is instantiated. Move this into its own function and call once when the services are started --- sfa/server/interface.py | 16 ++++++++++------ sfa/server/sfa-server.py | 17 ++++++++++++++++- sfa/util/server.py | 6 ------ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/sfa/server/interface.py b/sfa/server/interface.py index ca72b80c..9b4c039a 100644 --- a/sfa/server/interface.py +++ b/sfa/server/interface.py @@ -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. diff --git a/sfa/server/sfa-server.py b/sfa/server/sfa-server.py index d492f7af..58bfdb9c 100755 --- a/sfa/server/sfa-server.py +++ b/sfa/server/sfa-server.py @@ -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): diff --git a/sfa/util/server.py b/sfa/util/server.py index 197297d3..38bbfca9 100644 --- a/sfa/util/server.py +++ b/sfa/util/server.py @@ -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) -- 2.43.0