+def init_server(options, config):
+ """
+ Execute the init method defined in the manager file
+ """
+ manager_base = 'sfa.managers'
+ if options.registry:
+ mgr_type = config.SFA_REGISTRY_TYPE
+ manager_module = manager_base + ".registry_manager_%s" % mgr_type
+ try: manager = __import__(manager_module, fromlist=[manager_base])
+ except: manager = None
+ if manager and hasattr(manager, 'init_server'):
+ manager.init_server()
+ if options.am:
+ mgr_type = config.SFA_AGGREGATE_TYPE
+ manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
+ try: manager = __import__(manager_module, fromlist=[manager_base])
+ except: manager = None
+ if manager and hasattr(manager, 'init_server'):
+ manager.init_server()
+ if options.sm:
+ mgr_type = config.SFA_SM_TYPE
+ manager_module = manager_base + ".slice_manager_%s" % mgr_type
+ try: manager = __import__(manager_module, fromlist=[manager_base])
+ except: manager = None
+ if manager and hasattr(manager, 'init_server'):
+ manager.init_server()
+ if options.cm:
+ mgr_type = config.SFA_CM_TYPE
+ manager_module = manager_base + ".component_manager_%s" % mgr_type
+ try: manager = __import__(manager_module, fromlist=[manager_base])
+ except: manager = None
+ if manager and hasattr(manager, 'init_server'):
+ manager.init_server()
+
+def sync_interfaces(server_key_file, server_cert_file):
+ """
+ Attempt to install missing trusted gids and db records for
+ our federated interfaces
+ """
+ api = SfaAPI(key_file = server_key_file, cert_file = server_cert_file)
+ registries = Registries(api)
+ aggregates = Aggregates(api)
+ registries.sync_interfaces()
+ aggregates.sync_interfaces()
+
+def main():
+ # Generate command line parser
+ parser = OptionParser(usage="sfa-server [options]")
+ parser.add_option("-r", "--registry", dest="registry", action="store_true",
+ help="run registry server", default=False)
+ parser.add_option("-s", "--slicemgr", dest="sm", action="store_true",
+ help="run slice manager", default=False)
+ parser.add_option("-a", "--aggregate", dest="am", action="store_true",
+ help="run aggregate manager", default=False)
+ parser.add_option("-c", "--component", dest="cm", action="store_true",
+ help="run component server", default=False)
+ parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
+ help="verbose mode", default=False)
+ parser.add_option("-d", "--daemon", dest="daemon", action="store_true",
+ help="Run as daemon.", default=False)
+ (options, args) = parser.parse_args()
+ if options.verbose: sfa_logger.setLevel(logging.DEBUG)
+
+ config = Config()
+ if config.SFA_API_DEBUG: sfa_logger.setLevel(logging.DEBUG)
+ hierarchy = Hierarchy()
+ server_key_file = os.path.join(hierarchy.basedir, "server.key")
+ 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)
+ sync_interfaces(server_key_file, server_cert_file)
+
+ if (options.daemon): daemon()