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
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.
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():
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
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):
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)