Example #1
0
    def get(self):
        api_spec = ChainMap(*load_all_api_specs('wazo_calld.plugins', self.api_filename))

        if not api_spec.get('info'):
            return {'error': "API spec does not exist"}, 404

        return make_response(yaml.dump(dict(api_spec)), 200, {'Content-Type': 'application/x-yaml'})
Example #2
0
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')
Example #3
0
    def get(self):
        specs = []
        for module in iter_entry_points(group=self.api_entry_point):
            try:
                plugin_package = module.module_name.rsplit('.', 1)[0]
                spec = yaml.safe_load(
                    resource_string(plugin_package, self.api_filename))
                if not spec:
                    logger.debug('plugin has no API spec: %s', plugin_package)
                else:
                    specs.append(spec)
            except ImportError:
                logger.debug('failed to import %s', plugin_package)
            except IOError:
                logger.debug('API spec for module "%s" does not exist',
                             module.module_name)
            except IndexError:
                logger.debug('Could not find API spec from module "%s"',
                             module.module_name)
            except NotImplementedError:
                logger.debug(
                    'Are you sure you have an __init__ file in your module "%s"?',
                    module.module_name)
        api_spec = ChainMap(*specs)

        if not api_spec.get('info'):
            return {'error': "API spec does not exist"}, 404

        return make_response(yaml.dump(dict(api_spec)), 200,
                             {'Content-Type': 'application/x-yaml'})
Example #4
0
    def get(self):
        http_specs = load_all_api_specs('wazo_auth.http', self.api_filename)
        external_auth_specs = load_all_api_specs('wazo_auth.external_auth',
                                                 self.api_filename)
        specs = chain(http_specs, external_auth_specs)

        api_spec = ChainMap(*specs)
        if not api_spec.get('info'):
            return {'error': "API spec does not exist"}, 404

        return make_response(yaml.dump(dict(api_spec)), 200,
                             {'Content-Type': 'application/x-yaml'})
Example #5
0
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['log_file'], debug=config['debug'])

    xivo_dao.init_db_from_config(config)

    with pidfile_context(config['pid_file']):
        if 'archives' in config.get('enabled_plugins', {}):
            _load_plugins(config)
        _purge_tables(config)
Example #6
0
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()