def main(argv=None): argv = argv or sys.argv[1:] with _PreConfigLogger() as logger: logger.debug('Starting wazo-dird') config = load_config(logger, argv) xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level']) xivo_logging.silence_loggers(['Flask-Cors', 'urllib3', 'stevedore.extension'], logging.WARNING) if config['user']: change_user(config['user']) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) with pidfile_context(config['pid_filename'], config['foreground']): try: controller.run() except KeyboardInterrupt: # exit without stack trace pass
def main(argv=None): argv = argv or sys.argv[1:] with _PreConfigLogger() as logger: logger.debug('Starting wazo-dird') config = load_config(argv) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) xivo_logging.silence_loggers( ['Flask-Cors', 'amqp', 'urllib3', 'stevedore.extension'], logging.WARNING) if config['user']: change_user(config['user']) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(): xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING) config = get_config(sys.argv[1:]) xivo_logging.setup_logging( config['log_filename'], config['foreground'], config['debug'], config['log_level'], ) user = config.get('user') if user: change_user(user) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) with pidfile_context(config['pid_filename'], config['foreground']): try: controller.run() except KeyboardInterrupt: pass
def main(): cli_config = _parse_args() file_config = read_config_file_hierarchy( ChainMap(cli_config, _DEFAULT_CONFIG)) service_key = _load_key_file( ChainMap(cli_config, file_config, _DEFAULT_CONFIG)) config = ChainMap(cli_config, service_key, file_config, _DEFAULT_CONFIG) user = config.get('user') if user: change_user(user) xivo_dao.init_db_from_config(config) setup_logging(config['logfile'], config['foreground'], config['debug']) silence_loggers(['Flask-Cors'], logging.WARNING) set_xivo_uuid(config, logger) with pidfile_context(config['pidfile'], config['foreground']): logger.info('Starting xivo-agentd') try: _run(config) except Exception: logger.exception('Unexpected error:') except KeyboardInterrupt: pass finally: logger.info('Stopping xivo-agentd')
def main(): xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING) config = get_config(sys.argv[1:]) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) if config['user']: change_user(config['user']) if config["db_upgrade_on_startup"]: database.upgrade(config["db_uri"]) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(): cti_config.init_cli_config(sys.argv[1:]) cti_config.init_config_file() cti_config.init_auth_config() xivo_dao.init_db_from_config(config) cti_config.update_db_config() user = config.get('user') if user: change_user(user) setup_logging(config['logfile'], config['foreground'], config['debug']) silence_loggers( ['amqp', 'urllib3', 'Flask-Cors', 'kombu', 'stevedore.extension'], logging.WARNING) xivo_uuid = get_xivo_uuid(logger) register_class.setup(xivo_uuid) ctid = context.get('cti_server') ctid.setup() with ServiceCatalogRegistration('xivo-ctid', xivo_uuid, config['consul'], config['service_discovery'], config['bus'], partial(self_check, config)): ctid.run()
def main(): _print_deprecation_notice() setup_logging('/dev/null', foreground=True, debug=False) silence_loggers(['urllib3.connectionpool'], level=logging.WARNING) init_db_from_config(default_config()) with pidfile_context(PIDFILENAME, foreground=True): _generate_call_logs()
def main(argv=None): argv = argv or sys.argv[1:] config = load_config(argv) if config['user']: change_user(config['user']) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'] ) xivo_logging.silence_loggers( ['amqp', 'Flask-Cors', 'iso8601', 'kombu', 'swaggerpy', 'urllib3', 'ari.model', 'stevedore.extension'], logging.WARNING, ) if config['debug']: xivo_logging.silence_loggers(['swaggerpy'], logging.INFO) set_xivo_uuid(config, logger) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) controller.run()
def main(): cli_config = _parse_args() file_config = read_config_file_hierarchy(ChainMap(cli_config, _DEFAULT_CONFIG)) config = ChainMap(cli_config, file_config, _DEFAULT_CONFIG) setup_logging(config['logfile'], config['foreground'], config['debug']) silence_loggers(['urllib3'], logging.WARNING) xivo_dao.init_db_from_config(config) with pidfile_context(config['pidfile'], config['foreground']): agid.init(config) agid.run()
def main(): cli_args = parse_cli_args() config = load_config() xivo_logging.setup_logging('/dev/null', log_level=cli_args['log_level']) xivo_logging.silence_loggers(['stevedore.extension'], logging.WARNING) token = AuthClient(**config['auth']).token.new(expiration=300)['token'] del config['auth']['username'] del config['auth']['password'] tenants = AuthClient(token=token, **config['auth']).tenants.list()['items'] auth_tenants = set(tenant['uuid'] for tenant in tenants) auth_tenant_slugs = {tenant['uuid']: tenant['slug'] for tenant in tenants} logger.debug('wazo-auth tenants: %s', auth_tenants) init_db_from_config(config) default_sip_template_service = DefaultSIPTemplateService( sip_dao, transport_dao, ) with session_scope() as session: confd_tenants = set() confd_tenant_without_slugs = set() for tenant in session.query(Tenant).all(): confd_tenants.add(tenant.uuid) if not tenant.slug: confd_tenant_without_slugs.add(tenant.uuid) logger.debug('wazo-confd tenants: %s', confd_tenants) removed_tenants = confd_tenants - auth_tenants for tenant_uuid in removed_tenants: logger.info('Removing tenant: %s... (SKIP)', tenant_uuid) remove_tenant(tenant_uuid) with session_scope() as session: for tenant_uuid in auth_tenants: tenant = tenant_dao.find_or_create_tenant(tenant_uuid) default_sip_template_service.generate_sip_templates(tenant) for tenant_uuid in confd_tenant_without_slugs: slug = auth_tenant_slugs.get(tenant_uuid) if not slug: continue tenant = tenant_dao.find_or_create_tenant(tenant_uuid) tenant.slug = slug session.flush()
def main(): conf = config.load_config(sys.argv[1:]) if conf['user']: change_user(conf['user']) xivo_logging.setup_logging(conf['log_file'], FOREGROUND, conf['debug'], conf['log_level']) xivo_logging.silence_loggers( ['Flask-Cors', 'urllib3', 'stevedore.extension'], logging.WARNING) set_xivo_uuid(conf, logger) controller = Controller(conf) with pidfile_context(conf['pid_file'], FOREGROUND): controller.run()
def main(argv): config = load_config(argv) if config['user']: change_user(config['user']) xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level']) xivo_logging.silence_loggers(['amqp', 'Flask-Cors', 'iso8601', 'kombu', 'swaggerpy', 'urllib3', 'ari.model'], logging.WARNING) set_xivo_uuid(config, logger) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) with pidfile_context(config['pid_filename'], config['foreground']): controller.run()
def test_that_loggers_are_leveled_down(self, mocked_logging): loggers = {} to_silence = ['one', 'two', 'three'] def get_loggers(logger_name): loggers[logger_name] = logger = Mock() return logger mocked_logging.getLogger = get_loggers silence_loggers(to_silence, logging.ERROR) for logger in loggers.values(): logger.setLevel.assert_called_once_with(logging.ERROR) assert_that(loggers.keys(), contains_inanyorder(*to_silence))
def main(): cli_args = parse_cli_args() config = load_config() xivo_logging.setup_logging('/dev/null', log_level=cli_args['log_level']) xivo_logging.silence_loggers(['stevedore.extension'], logging.WARNING) tenant_uuid = get_master_tenant_uuid(config['auth']) init_db_from_config(config) wazo_uuid = info_dao.get().uuid bus = BusPublisher.from_config( config['bus'], wazo_uuid, ) sysconfd = SysconfdPublisher.from_config(config) if not cli_args['authorizations_only']: ingress_http_service = build_ingress_http_service() extension_features_service = build_extension_features_service() meeting_service = CRUDService( meeting_dao, build_meeting_validator(), MeetingNotifier( bus, sysconfd, ingress_http_service, extension_features_service, tenant_uuid, ), ) meeting_date_limit = datetime.now(timezone.utc) - timedelta(hours=24) remove_meetings_older_than(meeting_date_limit, meeting_service) authorization_notifier = MeetingAuthorizationNotifier(bus) meeting_authorization_service = build_authorization_service( authorization_notifier) meeting_authorization_date_limit = datetime.now( timezone.utc) - timedelta(hours=24) remove_meeting_authorizations_older_than(meeting_authorization_date_limit, meeting_authorization_service) sysconfd.flush() bus.flush()
def main(argv): config = load_config(argv) xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level']) xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING) if config['user']: change_user(config['user']) xivo_dao.init_db_from_config(config) init_bus_from_config(ChainMap(config, {'uuid': info_dao.get().uuid})) setup_sysconfd(config['sysconfd']['host'], config['sysconfd']['port']) controller = Controller(config) with pidfile_context(config['pid_filename'], config['foreground']): controller.run()
def main(): conf = config.load_config(sys.argv[1:]) if conf['user']: change_user(conf['user']) xivo_logging.setup_logging(conf['log_file'], FOREGROUND, conf['debug'], conf['log_level']) xivo_logging.silence_loggers(['Flask-Cors', 'urllib3'], logging.WARNING) try: set_xivo_uuid(conf, logger) except UUIDNotFound: # handled in the controller pass controller = Controller(conf) with pidfile_context(conf['pid_file'], FOREGROUND): controller.run()
def main(argv=None): argv = argv or sys.argv[1:] with _PreConfigLogger() as logger: logger.debug('Starting wazo-phoned') config = load_config(logger, argv) setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) silence_loggers(['amqp'], logging.WARNING) if config['user']: change_user(config['user']) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) controller.run()
def main(): argv = sys.argv[1:] config = load_config(argv) if config['user']: change_user(config['user']) setup_logging( config['logfile'], debug=config['debug'], log_level=config['log_level'] ) silence_loggers(['amqp'], level=logging.WARNING) if config["db_upgrade_on_startup"]: database.upgrade(config["db_uri"]) xivo_dao.init_db_from_config({'db_uri': config['cel_db_uri']}) set_xivo_uuid(config, logger) controller = Controller(config) controller.run()
def main(argv): config = load_config(argv) if config['user']: change_user(config['user']) xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level']) xivo_logging.silence_loggers([ 'amqp', 'Flask-Cors', 'iso8601', 'kombu', 'swaggerpy', 'urllib3', 'ari.model' ], logging.WARNING) set_xivo_uuid(config, logger) controller = Controller(config) signal.signal(signal.SIGTERM, partial(sigterm, controller)) with pidfile_context(config['pid_filename'], config['foreground']): controller.run()
def main(argv): config = load_config(argv) xivo_logging.setup_logging(config['log_filename'], config['foreground'], config['debug'], config['log_level']) xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING) if config['user']: change_user(config['user']) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) with pidfile_context(config['pid_filename'], config['foreground']): controller.run()
def main(): config = load_config() xivo_logging.setup_logging(config['log_file'], debug=config['debug'], log_level=config['log_level']) xivo_logging.silence_loggers(['urllib3'], logging.WARNING) xivo_logging.silence_loggers(['aioamqp'], logging.WARNING) if config['user']: change_user(config['user']) create_or_update_exchange(config['bus']) authenticator = Authenticator(config) bus_service = BusService(config['bus']) protocol_encoder = SessionProtocolEncoder() protocol_decoder = SessionProtocolDecoder() session_factory = SessionFactory(config, authenticator, bus_service, protocol_encoder, protocol_decoder) controller = Controller(config, session_factory, bus_service) controller.setup() controller.run()
def main(argv=None): argv = argv or sys.argv[1:] config = load_config(logger, argv) user = config.get('user') if user: change_user(user) xivo_dao.init_db_from_config(config) setup_logging(config['logfile'], debug=config['debug']) silence_loggers(['Flask-Cors', 'amqp'], logging.WARNING) set_xivo_uuid(config, logger) logger.info('Starting wazo-agentd') try: _run(config) except Exception: logger.exception('Unexpected error:') except KeyboardInterrupt: pass finally: logger.info('Stopping wazo-agentd')
def main(): xivo_logging.silence_loggers(SPAMMY_LOGGERS, logging.WARNING) config = get_config(sys.argv[1:]) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) user = config.get('user') if user: change_user(user) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(argv=None): argv = argv or sys.argv[1:] config = load_config(argv) xivo_logging.setup_logging( config['log_filename'], debug=config['debug'], log_level=config['log_level'], ) xivo_logging.silence_loggers(['Flask-Cors'], logging.WARNING) xivo_logging.silence_loggers(['amqp'], logging.INFO) if config['user']: change_user(config['user']) try: set_xivo_uuid(config, logger) except UUIDNotFound: if config['service_discovery']['enabled']: raise controller = Controller(config) controller.run()
def main(): cli_config = _parse_args() file_config = read_config_file_hierarchy( ChainMap(cli_config, _DEFAULT_CONFIG)) key_config = _load_key_file( ChainMap(cli_config, file_config, _DEFAULT_CONFIG)) config = ChainMap(cli_config, key_config, file_config, _DEFAULT_CONFIG) setup_logging(config['logfile'], debug=config['debug']) silence_loggers(['urllib3'], logging.WARNING) user = config.get('user') if user: change_user(user) xivo_dao.init_db_from_config(config) token_renewer = TokenRenewer(AuthClient(**config['auth'])) config['agentd']['client'] = AgentdClient(**config['agentd']) config['calld']['client'] = CalldClient(**config['calld']) config['confd']['client'] = ConfdClient(**config['confd']) config['dird']['client'] = DirdClient(**config['dird']) config['auth']['client'] = AuthClient(**config['auth']) def on_token_change(token_id): config['agentd']['client'].set_token(token_id) config['calld']['client'].set_token(token_id) config['confd']['client'].set_token(token_id) config['dird']['client'].set_token(token_id) config['auth']['client'].set_token(token_id) token_renewer.subscribe_to_token_change(on_token_change) agid.init(config) with token_renewer: agid.run()
def main(): _print_deprecation_notice() setup_logging('/dev/null', debug=False) silence_loggers(['urllib3.connectionpool'], level=logging.WARNING) with pidfile_context(PIDFILENAME): _generate_call_logs()