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


Python cfg.ConfigOpts方法代码示例

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


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

示例1: change_sack_size

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def change_sack_size():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([_SACK_NUMBER_OPT])
    conf = service.prepare_service(conf=conf, log_to_std=True)
    s = incoming.get_driver(conf)
    try:
        report = s.measures_report(details=False)
    except incoming.SackDetectionError:
        LOG.error('Unable to detect the number of storage sacks.\n'
                  'Ensure gnocchi-upgrade has been executed.')
        return
    remainder = report['summary']['measures']
    if remainder:
        LOG.error('Cannot change sack when non-empty backlog. Process '
                  'remaining %s measures and try again', remainder)
        return
    LOG.info("Removing current %d sacks", s.NUM_SACKS)
    s.remove_sacks()
    LOG.info("Creating new %d sacks", conf.sacks_number)
    s.upgrade(conf.sacks_number) 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:22,代码来源:manage.py

示例2: main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def main():
    opt = cfg.SubCommandOpt(
        'category', title='command',
        description='kuryr-k8s-status command or category to execute',
        handler=add_parsers)

    conf = cfg.ConfigOpts()
    conf.register_cli_opt(opt)
    conf(sys.argv[1:])

    os_vif.initialize()
    objects.register_locally_defined_vifs()

    try:
        return conf.category.action_fn()
    except Exception:
        print('Error:\n%s' % traceback.format_exc())
        # This is 255 so it's not confused with the upgrade check exit codes.
        return 255 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:21,代码来源:status.py

示例3: setup_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setup_config(config_file=''):
    global TEST_CONF
    TEST_CONF = cfg.ConfigOpts()

    TEST_CONF.register_group(identity_group)
    TEST_CONF.register_opts(identity_options, group=identity_group)

    config_to_load = []
    local_config = './etc/castellan/castellan-functional.conf'
    main_config = '/etc/castellan/castellan-functional.conf'
    if os.path.isfile(config_file):
        config_to_load.append(config_file)
    elif os.path.isfile(local_config):
        config_to_load.append(local_config)
    elif os.path.isfile(main_config):
        config_to_load.append(main_config)

    TEST_CONF(
        (),  # Required to load an anonymous configuration
        default_config_files=config_to_load
    ) 
开发者ID:openstack,项目名称:castellan,代码行数:23,代码来源:config.py

示例4: _main

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def _main():
    import eventlet
    eventlet.monkey_patch(all=True)
    # Monkey patch the original current_thread to use the up-to-date _active
    # global variable. See https://bugs.launchpad.net/bugs/1863021 and
    # https://github.com/eventlet/eventlet/issues/592
    import __original_module_threading as orig_threading
    import threading  # noqa
    orig_threading.current_thread.__globals__['_active'] = threading._active

    from oslo_config import cfg

    logging.basicConfig(level=logging.DEBUG)

    conf = cfg.ConfigOpts()
    conf.register_cli_opts(_options.eventlet_backdoor_opts)
    conf(sys.argv[1:])

    where_running_thread = _initialize_if_enabled(conf)
    if not where_running_thread:
        raise RuntimeError(_("Did not create backdoor at requested location"))
    else:
        _where_running, thread = where_running_thread
        thread.wait() 
开发者ID:openstack,项目名称:oslo.service,代码行数:26,代码来源:eventlet_backdoor.py

示例5: get_conf

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def get_conf(self, conf=CONF):
        """Convert secret store conf into oslo conf

        Returns an oslo.config() object to pass to keymanager.API(conf)
        """
        vault_conf = cfg.ConfigOpts()
        options.set_defaults(
            vault_conf,
            backend='vault',
            vault_root_token_id=conf.vault_plugin.root_token_id,
            vault_approle_role_id=conf.vault_plugin.approle_role_id,
            vault_approle_secret_id=conf.vault_plugin.approle_secret_id,
            vault_kv_mountpoint=conf.vault_plugin.kv_mountpoint,
            vault_url=conf.vault_plugin.vault_url,
            vault_ssl_ca_crt_file=conf.vault_plugin.ssl_ca_crt_file,
            vault_use_ssl=conf.vault_plugin.use_ssl
        )
        return vault_conf 
开发者ID:openstack,项目名称:barbican,代码行数:20,代码来源:vault_secret_store.py

示例6: paste_deploy_app

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def paste_deploy_app(paste_config_file, app_name, conf):
    """Load a WSGI app from a PasteDeploy configuration.

    Use deploy.loadapp() to load the app from the PasteDeploy configuration,
    ensuring that the supplied ConfigOpts object is passed to the app and
    filter constructors.

    :param paste_config_file: a PasteDeploy config file
    :param app_name: the name of the app/pipeline to load from the file
    :param conf: a ConfigOpts object to supply to the app and its filters
    :returns: the WSGI app
    """
    setup_paste_factories(conf)
    try:
        return deploy.loadapp("config:%s" % paste_config_file, name=app_name)
    finally:
        teardown_paste_factories() 
开发者ID:openstack,项目名称:senlin,代码行数:19,代码来源:wsgi.py

示例7: create

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def create(context, conf):
    config_dir = utils.find_config(CONF.provider_config_dir)
    config_file = os.path.abspath(os.path.join(config_dir,
                                               'eisoo.conf'))
    config = cfg.ConfigOpts()
    config(args=['--config-file=' + config_file])
    config.register_opts(eisoo_client_opts,
                         group=SERVICE + '_client')

    LOG.info('Creating eisoo client with url %s.',
             config.eisoo_client.eisoo_endpoint)
    abclient = client.ABClient(config.eisoo_client.eisoo_endpoint,
                               config.eisoo_client.eisoo_app_id,
                               config.eisoo_client.eisoo_app_secret)

    return abclient 
开发者ID:openstack,项目名称:karbor,代码行数:18,代码来源:eisoo.py

示例8: setUp

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
        super(KubernetesClientTest, self).setUp()
        self._context = RequestContext(user_id='demo',
                                       project_id='abcd',
                                       auth_token='efgh',
                                       service_catalog=None)

        self.conf = cfg.ConfigOpts()
        k8s.register_opts(self.conf)
        self.host_url = 'https://192.168.98.35:6443'
        self.conf.set_default('k8s_host',
                              self.host_url,
                              'k8s_client')
        self.conf.set_override('k8s_ssl_ca_cert',
                               '/etc/provider.d/server-ca.crt',
                               'k8s_client')
        self.conf.set_override('k8s_cert_file',
                               '/etc/provider.d/client-admin.crt',
                               'k8s_client')
        self.conf.set_override('k8s_key_file',
                               '/etc/provider.d/client-admin.key',
                               'k8s_client') 
开发者ID:openstack,项目名称:karbor,代码行数:24,代码来源:test_k8s_client.py

示例9: setUp

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
        super(SwiftClientTest, self).setUp()
        service_catalog = [
            {
                'endpoints': [
                    {'publicURL': 'http://127.0.0.1:8080/v1/AUTH_abcd', }
                ],
                'type': 'object-store',
                'name': 'swift',
            },
        ]
        self._context = RequestContext(user_id='demo',
                                       project_id='abcd',
                                       auth_token='efgh',
                                       service_catalog=service_catalog)

        self.conf = cfg.ConfigOpts()
        swift.register_opts(self.conf) 
开发者ID:openstack,项目名称:karbor,代码行数:20,代码来源:test_swift_client.py

示例10: setUp

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
        super(CinderProtectionPluginTest, self).setUp()
        plugin_config = cfg.ConfigOpts()
        plugin_config_fixture = self.useFixture(fixture.Config(plugin_config))
        plugin_config_fixture.load_raw_values(
            group='cinder_backup_protection_plugin',
            poll_interval=0,
        )
        self.plugin = CinderBackupProtectionPlugin(plugin_config)
        cfg.CONF.set_default('cinder_endpoint',
                             'http://127.0.0.1:8776/v2',
                             'cinder_client')

        self.cntxt = RequestContext(user_id='demo',
                                    project_id='abcd',
                                    auth_token='efgh')
        self.cinder_client = client_factory.ClientFactory.create_client(
            "cinder", self.cntxt) 
开发者ID:openstack,项目名称:karbor,代码行数:20,代码来源:test_cinder_protection_plugin.py

示例11: __init__

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def __init__(self, application, conf=None):
        """Base middleware constructor

        :param  conf: a cfg.ConfigOpts object
        """
        self.application = application
        self.oslo_conf = conf 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:9,代码来源:http_proxy_to_wsgi.py

示例12: prepare_conf

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def prepare_conf():
    conf = cfg.ConfigOpts()

    opts.set_defaults()
    policy_opts.set_defaults(conf)
    return conf 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:8,代码来源:utils.py

示例13: metricd

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def metricd():
    conf = cfg.ConfigOpts()
    conf.register_cli_opts([
        cfg.IntOpt("stop-after-processing-metrics",
                   default=0,
                   min=0,
                   help="Number of metrics to process without workers, "
                   "for testing purpose"),
    ])
    conf = service.prepare_service(conf=conf)

    if conf.stop_after_processing_metrics:
        metricd_tester(conf)
    else:
        MetricdServiceManager(conf).run() 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:17,代码来源:metricd.py

示例14: upgrade

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def upgrade():
    conf = cfg.ConfigOpts()
    sack_number_opt = copy.copy(_SACK_NUMBER_OPT)
    sack_number_opt.default = 128
    conf.register_cli_opts([
        cfg.BoolOpt("skip-index", default=False,
                    help="Skip index upgrade."),
        cfg.BoolOpt("skip-storage", default=False,
                    help="Skip storage upgrade."),
        cfg.BoolOpt("skip-incoming", default=False,
                    help="Skip incoming storage upgrade."),
        cfg.BoolOpt("skip-archive-policies-creation", default=False,
                    help="Skip default archive policies creation."),
        sack_number_opt,
    ])
    conf = service.prepare_service(conf=conf, log_to_std=True)
    if not conf.skip_index:
        index = indexer.get_driver(conf)
        LOG.info("Upgrading indexer %s", index)
        index.upgrade()
    if not conf.skip_storage:
        s = storage.get_driver(conf)
        LOG.info("Upgrading storage %s", s)
        s.upgrade()
    if not conf.skip_incoming:
        i = incoming.get_driver(conf)
        LOG.info("Upgrading incoming storage %s", i)
        i.upgrade(conf.sacks_number)

    if (not conf.skip_archive_policies_creation
            and not index.list_archive_policies()
            and not index.list_archive_policy_rules()):
        if conf.skip_index:
            index = indexer.get_driver(conf)
        for name, ap in six.iteritems(archive_policy.DEFAULT_ARCHIVE_POLICIES):
            index.create_archive_policy(ap)
        index.create_archive_policy_rule("default", "*", "low") 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:39,代码来源:manage.py

示例15: prepare_service

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def prepare_service(conf=None):
    if conf is None:
        conf = cfg.ConfigOpts()

    opts.set_defaults()
    policy_opts.set_defaults(conf)
    conf = service.prepare_service(conf=conf)
    cfg_path = conf.oslo_policy.policy_file
    if not os.path.isabs(cfg_path):
        cfg_path = conf.find_file(cfg_path)
    if cfg_path is None or not os.path.exists(cfg_path):
        cfg_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                   '..', 'rest', 'policy.json'))
    conf.set_default('policy_file', cfg_path, group='oslo_policy')
    return conf 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:17,代码来源:api.py


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