def main(): config.init(app.common_opts, sys.argv[1:]) application = app.setup_app() host = CONF.bind_host port = CONF.bind_port workers = CONF.api_workers if workers < 1: LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) workers = 1 LOG.info(_LI("Cinder_APIGW on http://%(host)s:%(port)s with %(workers)s"), { 'host': host, 'port': port, 'workers': workers }) service = wsgi.Server(CONF, 'Tricircle Cinder_APIGW', application, host, port) restapp.serve(service, CONF, workers) LOG.info(_LI("Configuration:")) CONF.log_opt_values(LOG, std_logging.INFO) restapp.wait()
def setup_logging(): """Sets up the logging options for a log with supplied name.""" product_name = "tricircle" logging.setup(cfg.CONF, product_name) LOG.info(_LI("Logging enabled!")) LOG.info(_LI("%(prog)s version %(version)s"), {'prog': sys.argv[0], 'version': version.version_info.release_string()}) LOG.debug("command line: %s", " ".join(sys.argv))
def _setup_logging(): """Sets up the logging options for a log with supplied name.""" product_name = "tricircle" logging.setup(cfg.CONF, product_name) LOG.info(_LI("Logging enabled!")) LOG.info(_LI("%(prog)s version %(version)s"), { 'prog': sys.argv[0], 'version': version.version_info }) LOG.debug("command line: %s", " ".join(sys.argv))
def test_rpc(self, ctx, payload): LOG.info(_LI("xmanager receive payload: %s"), payload) info_text = "xmanager receive payload: %s" % payload return info_text
def start(self): ver_str = version.version_info LOG.info(_LI('Starting %(topic)s node (version %(version)s)'), {'topic': self.topic, 'version': ver_str}) self.basic_config_check() self.manager.init_host() self.manager.pre_start_hook() LOG.debug(_("Creating RPC server for service %s"), self.topic) target = messaging.Target(topic=self.topic, server=self.host) endpoints = [ self.manager, baserpc.BaseServerRPCAPI(self.manager.service_name) ] endpoints.extend(self.manager.additional_endpoints) self.rpc_server = rpc.get_server(target, endpoints, self.serializer) self.rpc_server.start() self.manager.post_start_hook() if self.periodic_enable: if self.periodic_fuzzy_delay: initial_delay = random.randint(0, self.periodic_fuzzy_delay) else: initial_delay = None self.tg.add_dynamic_timer(self.periodic_tasks, initial_delay=initial_delay, periodic_interval_max=self.interval_max)
def load_paste_app(app_name): """Builds and returns a WSGI app from a paste config file. :param app_name: Name of the application to load :raises ConfigFilesNotFoundError when config file cannot be located :raises RuntimeError when application cannot be loaded from config file """ config_path = cfg.CONF.find_file(cfg.CONF.api_paste_config) if not config_path: raise cfg.ConfigFilesNotFoundError( config_files=[cfg.CONF.api_paste_config]) config_path = os.path.abspath(config_path) LOG.info(_LI("Config paste file: %s"), config_path) try: app = deploy.loadapp("config:%s" % config_path, name=app_name) except (LookupError, ImportError): msg = (_("Unable to load %(app_name)s from " "configuration file %(config_path)s.") % {'app_name': app_name, 'config_path': config_path}) LOG.exception(msg) raise RuntimeError(msg) return app
def _init_compute_node(self, context, resources): """Initialise the compute node if it does not already exist. The nova scheduler will be inoperable if compute_node is not defined. The compute_node will remain undefined if we fail to create it or if there is no associated service registered. If this method has to create a compute node it needs initial values - these come from resources. :param context: security context :param resources: initial values """ # try to get the compute node record from the # database. If we get one we use resources to initialize compute_node = self._get_compute_node(context) if compute_node: self._copy_resources(compute_node, resources) compute_node.save() return # there was no local copy and none in the database # so we need to create a new compute node. This needs # to be initialised with resource values. compute_node = objects.ComputeNode(context) service = objects.Service.get_by_host_and_binary( context, self.host, 'nova-compute') compute_node.host = self.host compute_node.service_id = service['id'] self._copy_resources(compute_node, resources) compute_node.create() LOG.info(_LI('Compute_service record created for ' '%(host)s:%(node)s'), {'host': self.host, 'node': utils.get_node_name(self.host)})
def _parse_network_vlan_ranges(self): try: self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( cfg.CONF.tricircle.network_vlan_ranges) except Exception: LOG.exception(_LE('Failed to parse network_vlan_ranges. ' 'Service terminated!')) sys.exit(1) LOG.info(_LI('Network VLAN ranges: %s'), self.network_vlan_ranges)
def main(): config.init(xservice.common_opts, sys.argv[1:]) host = CONF.host workers = CONF.workers if workers < 1: LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) workers = 1 LOG.info(_LI("XJob Server on http://%(host)s with %(workers)s"), {'host': host, 'workers': workers}) xservice.serve(xservice.create_service(), workers) LOG.info(_LI("Configuration:")) CONF.log_opt_values(LOG, std_logging.INFO) xservice.wait()
def main(): config.init(xservice.common_opts, sys.argv[1:]) host = CONF.host workers = CONF.workers if workers < 1: LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) workers = 1 LOG.info(_LI("XJob Server on http://%(host)s with %(workers)s"), { 'host': host, 'workers': workers }) xservice.serve(xservice.create_service(), workers) LOG.info(_LI("Configuration:")) CONF.log_opt_values(LOG, logging.INFO) xservice.wait()
def main(): config.init(app.common_opts, sys.argv[1:]) application = app.setup_app() host = CONF.bind_host port = CONF.bind_port workers = CONF.api_workers if workers < 1: LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) workers = 1 LOG.info(_LI("Admin API on http://%(host)s:%(port)s with %(workers)s"), {'host': host, 'port': port, 'workers': workers}) service = wsgi.Server(CONF, 'Tricircle Admin_API', application, host, port) restapp.serve(service, CONF, workers) LOG.info(_LI("Configuration:")) CONF.log_opt_values(LOG, std_logging.INFO) restapp.wait()
def main(): config.init(sys.argv[1:]) config.setup_logging() application = app.setup_app() host = CONF.bind_host port = CONF.bind_port workers = CONF.api_workers if workers < 1: LOG.warning(_LW("Wrong worker number, worker = %(workers)s"), workers) workers = 1 LOG.info(_LI("Server on http://%(host)s:%(port)s with %(workers)s"), {'host': host, 'port': port, 'workers': workers}) serving.run_simple(host, port, application, processes=workers) LOG.info(_LI("Configuration:")) CONF.log_opt_values(LOG, std_logging.INFO)
def __init__(self): self.drivers = {} # NOTE(zhiyuan) here we call __init__ of super class's super class, # which is NamedExtensionManager's __init__ to bypass initialization # process of ml2 type manager super(managers.TypeManager, self).__init__('tricircle.network.type_drivers', cfg.CONF.tricircle.type_drivers, invoke_on_load=True) LOG.info(_LI('Loaded type driver names: %s'), self.names()) self._register_types() self._check_tenant_network_types( cfg.CONF.tricircle.tenant_network_types) self._check_bridge_network_type(cfg.CONF.tricircle.bridge_network_type)
def __init__(self): self.drivers = {} # NOTE(zhiyuan) here we call __init__ of super class's super class, # which is NamedExtensionManager's __init__ to bypass initialization # process of ml2 type manager super(managers.TypeManager, self).__init__( 'tricircle.network.type_drivers', cfg.CONF.tricircle.type_drivers, invoke_on_load=True) LOG.info(_LI('Loaded type driver names: %s'), self.names()) self._register_types() self._check_tenant_network_types( cfg.CONF.tricircle.tenant_network_types) self._check_bridge_network_type( cfg.CONF.tricircle.bridge_network_type)
def start(self): ver_str = version.version_info LOG.info(_LI('Starting %(topic)s node (version %(version)s)'), { 'topic': self.topic, 'version': ver_str }) self.basic_config_check() self.manager.init_host() self.manager.pre_start_hook() LOG.debug(_("Creating RPC server for service %s"), self.topic) target = messaging.Target(topic=self.topic, server=self.host) endpoints = [ self.manager, baserpc.BaseServerRPCAPI(self.manager.service_name) ] endpoints.extend(self.manager.additional_endpoints) self.rpc_server = rpc.get_server(target, endpoints, self.serializer) self.rpc_server.start() self.manager.post_start_hook() if self.periodic_enable: if self.periodic_fuzzy_delay: initial_delay = random.randint(0, self.periodic_fuzzy_delay) else: initial_delay = None self.tg.add_dynamic_timer(self.periodic_tasks, initial_delay=initial_delay, periodic_interval_max=self.interval_max)