当前位置: 首页>>代码示例>>Python>>正文


Python cfg.find_config_files方法代码示例

本文整理汇总了Python中oslo_config.cfg.find_config_files方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.find_config_files方法的具体用法?Python cfg.find_config_files怎么用?Python cfg.find_config_files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_config.cfg的用法示例。


在下文中一共展示了cfg.find_config_files方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def upload_config(self):
        try:
            stream = flask.request.stream
            file_path = cfg.find_config_files(project=CONF.project,
                                              prog=CONF.prog)[0]
            flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
            # mode 00600
            mode = stat.S_IRUSR | stat.S_IWUSR
            with os.fdopen(os.open(file_path, flags, mode), 'wb') as cfg_file:
                b = stream.read(BUFFER)
                while b:
                    cfg_file.write(b)
                    b = stream.read(BUFFER)

            CONF.mutate_config_files()
        except Exception as e:
            LOG.error("Unable to update amphora-agent configuration: "
                      "{}".format(str(e)))
            return webob.Response(json=dict(
                message="Unable to update amphora-agent configuration.",
                details=str(e)), status=500)

        return webob.Response(json={'message': 'OK'}, status=202) 
开发者ID:openstack,项目名称:octavia,代码行数:25,代码来源:server.py

示例2: parse_args

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def parse_args(args=[]):
    CONF.register_cli_opts(api_common_opts())
    register_db_drivers_opt()
    # register paste configuration
    paste_grp = cfg.OptGroup('paste_deploy',
                             'Paste Configuration')
    CONF.register_group(paste_grp)
    CONF.register_opts(paste_deploy, group=paste_grp)
    log.register_options(CONF)
    policy.Enforcer(CONF)
    default_config_files = cfg.find_config_files('freezer', 'freezer-api')
    CONF(args=args,
         project='freezer-api',
         default_config_files=default_config_files,
         version=FREEZER_API_VERSION
         ) 
开发者ID:openstack,项目名称:freezer-api,代码行数:18,代码来源:config.py

示例3: parse_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def parse_config():
    DB_INIT = [
        cfg.SubCommandOpt('db',
                          dest='db',
                          title='DB Options',
                          handler=add_db_opts
                          )
    ]
    # register database backend drivers
    config.register_db_drivers_opt()
    # register database cli options
    CONF.register_cli_opts(DB_INIT)
    # register logging opts
    log.register_options(CONF)
    default_config_files = cfg.find_config_files('freezer', 'freezer-api')
    CONF(args=sys.argv[1:],
         project='freezer-api',
         default_config_files=default_config_files,
         version=FREEZER_API_VERSION
         ) 
开发者ID:openstack,项目名称:freezer-api,代码行数:22,代码来源:manage.py

示例4: get_config_files

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def get_config_files():
    """Get the possible configuration files accepted by oslo.config

    This also includes the deprecated ones
    """
    # default files
    conf_files = cfg.find_config_files(project='monasca', prog='monasca-api')
    # deprecated config files (only used if standard config files are not there)
    if len(conf_files) == 0:
        for prog_name in ['api', 'api-config']:
            old_conf_files = cfg.find_config_files(project='monasca', prog=prog_name)
            if len(old_conf_files) > 0:
                LOG.warning('Found deprecated old location "{}" '
                            'of main configuration file'.format(old_conf_files))
                conf_files += old_conf_files
    return conf_files 
开发者ID:openstack,项目名称:monasca-api,代码行数:18,代码来源:config.py

示例5: _get_config_files

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def _get_config_files():
    """Get the possible configuration files accepted by oslo.config

    This also includes the deprecated ones
    """
    # default files
    conf_files = cfg.find_config_files(project='monasca',
                                       prog='monasca-notification')
    # deprecated config files (only used if standard config files are not there)
    if len(conf_files) == 0:
        old_conf_files = cfg.find_config_files(project='monasca',
                                               prog='notification')
        if len(old_conf_files) > 0:
            LOG.warning('Found deprecated old location "{}" '
                        'of main configuration file'.format(old_conf_files))
            conf_files += old_conf_files
    return conf_files 
开发者ID:openstack,项目名称:monasca-notification,代码行数:19,代码来源:config.py

示例6: get_config_files

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def get_config_files():
    """Get the possible configuration files accepted by oslo.config

    This also includes the deprecated ones
    """
    # default files
    conf_files = cfg.find_config_files(project='monasca',
                                       prog='monasca-log-api')
    # deprecated config files (only used if standard config files are not there)
    if len(conf_files) == 0:
        old_conf_files = cfg.find_config_files(project='monasca',
                                               prog='log-api')
        if len(old_conf_files) > 0:
            LOG.warning('Found deprecated old location "{}" '
                        'of main configuration file'.format(old_conf_files))
            conf_files += old_conf_files
    return conf_files 
开发者ID:openstack,项目名称:monasca-log-api,代码行数:19,代码来源:config.py

示例7: parse_cache_args

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def parse_cache_args(args=None):
    config_files = cfg.find_config_files(project='searchlight',
                                         prog='searchlight-cache')
    parse_args(args=args, default_config_files=config_files) 
开发者ID:openstack,项目名称:searchlight,代码行数:6,代码来源:config.py

示例8: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def main():
    CONF.register_cli_opt(command_opt)
    if len(sys.argv) < 2:
        script_name = sys.argv[0]
        print("%s command action [<args>]" % script_name)
        print(_("Available commands:"))
        for command in COMMANDS:
            print(_("\t%s") % command)
        sys.exit(2)

    try:
        logging.register_options(CONF)

        cfg_files = cfg.find_config_files(project='searchlight',
                                          prog='searchlight')
        config.parse_args(default_config_files=cfg_files)
        config.set_config_defaults()
        logging.setup(CONF, 'searchlight')

        func_kwargs = {}
        for k in CONF.command.action_kwargs:
            v = getattr(CONF.command, 'action_kwarg_' + k)
            if v is None:
                continue
            if isinstance(v, str):
                v = encodeutils.safe_decode(v)
            func_kwargs[k] = v
        func_args = [encodeutils.safe_decode(arg)
                     for arg in CONF.command.action_args]
        return CONF.command.action_fn(*func_args, **func_kwargs)

    except RuntimeError as e:
        sys.exit("ERROR: %s" % e) 
开发者ID:openstack,项目名称:searchlight,代码行数:35,代码来源:manage.py

示例9: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def main():
    """Parse options and call the appropriate class/method."""
    CONF = config.new_config()
    CONF.register_cli_opt(category_opt)

    try:
        logging.register_options(CONF)
        logging.setup(CONF, "barbican-manage")
        cfg_files = cfg.find_config_files(project='barbican')

        CONF(args=sys.argv[1:],
             project='barbican',
             prog='barbican-manage',
             version=barbican.version.__version__,
             default_config_files=cfg_files)

    except RuntimeError as e:
        sys.exit("ERROR: %s" % e)

    # find sub-command and its arguments
    fn = CONF.category.action_fn
    fn_args = [arg.decode('utf-8') for arg in CONF.category.action_args]
    fn_kwargs = {}
    for k in CONF.category.action_kwargs:
        v = getattr(CONF.category, 'action_kwarg_' + k)
        if v is None:
            continue
        if isinstance(v, six.string_types):
            v = v.decode('utf-8')
        fn_kwargs[k] = v

    # call the action with the remaining arguments
    try:
        ret = fn(*fn_args, **fn_kwargs)
        return(ret)
    except Exception as e:
        sys.exit("ERROR: %s" % e) 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:39,代码来源:barbican_manage.py

示例10: parse_args

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def parse_args(argv, default_config_files=None, default_config_dirs=None):
    default_config_files = (default_config_files or
                            cfg.find_config_files(project='watcher'))
    default_config_dirs = (default_config_dirs or
                           cfg.find_config_dirs(project='watcher'))
    rpc.set_defaults(control_exchange='watcher')
    cfg.CONF(argv[1:],
             project='watcher',
             version=version.version_info.release_string(),
             default_config_dirs=default_config_dirs,
             default_config_files=default_config_files)
    rpc.init(cfg.CONF) 
开发者ID:openstack,项目名称:watcher,代码行数:14,代码来源:config.py

示例11: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def main():
    """Parse options and call the appropriate class/method."""
    CONF = config.new_config()
    CONF.register_cli_opt(category_opt)

    try:
        logging.register_options(CONF)
        logging.setup(CONF, "barbican-manage")
        cfg_files = cfg.find_config_files(project='barbican')

        CONF(args=sys.argv[1:],
             project='barbican',
             prog='barbican-manage',
             version=barbican.version.__version__,
             default_config_files=cfg_files)

    except RuntimeError as e:
        sys.exit("ERROR: %s" % e)

    # find sub-command and its arguments
    fn = CONF.category.action_fn
    fn_args = [arg.decode('utf-8') for arg in CONF.category.action_args]
    fn_kwargs = {}
    for k in CONF.category.action_kwargs:
        v = getattr(CONF.category, 'action_kwarg_' + k)
        if v is None:
            continue
        if isinstance(v, bytes):
            v = v.decode('utf-8')
        fn_kwargs[k] = v

    # call the action with the remaining arguments
    try:
        return fn(*fn_args, **fn_kwargs)
    except Exception as e:
        sys.exit("ERROR: %s" % e) 
开发者ID:openstack,项目名称:barbican,代码行数:38,代码来源:barbican_manage.py

示例12: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def main():
    try:
        CONF.register_cli_opt(command_opt)
        default_config_files = cfg.find_config_files('senlin', 'senlin-manage')
        config.parse_args(sys.argv, 'senlin-manage', default_config_files)
        logging.setup(CONF, 'senlin-manage')
    except RuntimeError as e:
        sys.exit("ERROR: %s" % e)

    try:
        CONF.command.func()
    except Exception as e:
        sys.exit("ERROR: %s" % e) 
开发者ID:openstack,项目名称:senlin,代码行数:15,代码来源:manage.py

示例13: setup_app

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import find_config_files [as 别名]
def setup_app(config):
    """App factory."""
    # By default we expect path to oslo config file in environment variable
    # REFSTACK_OSLO_CONFIG (option for testing and development)
    # If it is empty we look up those config files
    # in the following directories:
    #   ~/.${project}/
    #   ~/
    #   /etc/${project}/
    #   /etc/

    default_config_files = ((os.getenv('REFSTACK_OSLO_CONFIG'), )
                            if os.getenv('REFSTACK_OSLO_CONFIG')
                            else cfg.find_config_files('refstack'))
    CONF('',
         project='refstack',
         default_config_files=default_config_files)

    log.setup(CONF, 'refstack')
    CONF.log_opt_values(LOG, logging.DEBUG)

    template_path = CONF.api.template_path % {'project_root': PROJECT_ROOT}
    static_root = CONF.api.static_root % {'project_root': PROJECT_ROOT}
    app_conf = dict(config.app)
    app = pecan.make_app(
        app_conf.pop('root'),
        debug=CONF.api.app_dev_mode,
        static_root=static_root,
        template_path=template_path,
        hooks=[
            JWTAuthHook(), JSONErrorHook(), CORSHook(),
            pecan.hooks.RequestViewerHook(
                {'items': ['status', 'method', 'controller', 'path', 'body']},
                headers=False, writer=WritableLogger(LOG, logging.DEBUG)
            )
        ]
    )

    beaker_conf = {
        'session.key': 'refstack',
        'session.type': 'ext:database',
        'session.url': CONF.database.connection,
        'session.timeout': 604800,
        'session.validate_key': api_utils.get_token(),
        'session.sa.pool_recycle': 600
    }
    app = SessionMiddleware(app, beaker_conf)

    if CONF.api.app_dev_mode:
        LOG.debug('\n\n <<< Refstack UI is available at %s >>>\n\n',
                  CONF.ui_url)

    return app 
开发者ID:openstack-archive,项目名称:refstack,代码行数:55,代码来源:app.py


注:本文中的oslo_config.cfg.find_config_files方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。