當前位置: 首頁>>代碼示例>>Python>>正文


Python cfg.set_defaults方法代碼示例

本文整理匯總了Python中oslo_config.cfg.set_defaults方法的典型用法代碼示例。如果您正苦於以下問題:Python cfg.set_defaults方法的具體用法?Python cfg.set_defaults怎麽用?Python cfg.set_defaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oslo_config.cfg的用法示例。


在下文中一共展示了cfg.set_defaults方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: set_middleware_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_middleware_defaults():
    """Update default configuration options for oslo.middleware."""
    # CORS Defaults
    cfg.set_defaults(cors.CORS_OPTS,
                     allow_headers=['X-Auth-Token',
                                    'X-Openstack-Request-Id',
                                    'X-Identity-Status',
                                    'X-Roles',
                                    'X-Service-Catalog',
                                    'X-User-Id',
                                    'X-Tenant-Id'],
                     expose_headers=['X-Auth-Token',
                                     'X-Openstack-Request-Id',
                                     'X-Subject-Token',
                                     'X-Service-Token'],
                     allow_methods=['GET',
                                    'PUT',
                                    'POST',
                                    'DELETE',
                                    'PATCH']
                     ) 
開發者ID:openstack,項目名稱:masakari,代碼行數:23,代碼來源:config.py

示例2: set_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_defaults(conf, policy_file=None):
    """Set defaults for configuration variables.

    Overrides default options values.

    :param conf: Configuration object, managed by the caller.
    :type conf: oslo.config.cfg.ConfigOpts

    :param policy_file: The base filename for the file that
                        defines policies.
    :type policy_file: unicode
    """
    _register(conf)

    if policy_file is not None:
        cfg.set_defaults(_options, policy_file=policy_file) 
開發者ID:openstack,項目名稱:oslo.policy,代碼行數:18,代碼來源:opts.py

示例3: get_ksa_adapter_opts

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def get_ksa_adapter_opts(default_service_type, deprecated_opts=None):
    """Get auth, Session, and Adapter conf options from keystonauth1.loading.

    :param default_service_type: Default for the service_type conf option on
                                 the Adapter.
    :param deprecated_opts: dict of deprecated opts to register with the ksa
                            Adapter opts.  Works the same as the
                            deprecated_opts kwarg to:
                    keystoneauth1.loading.session.Session.register_conf_options
    :return: List of cfg.Opts.
    """
    opts = ks_loading.get_adapter_conf_options(include_deprecated=False,
                                               deprecated_opts=deprecated_opts)

    for opt in opts[:]:
        # Remove version-related opts.  Required/supported versions are
        # something the code knows about, not the operator.
        if opt.dest in _ADAPTER_VERSION_OPTS:
            opts.remove(opt)

    # Override defaults that make sense for nova
    cfg.set_defaults(opts,
                     valid_interfaces=['internal', 'public'],
                     service_type=default_service_type)
    return opts 
開發者ID:openstack,項目名稱:cyborg,代碼行數:27,代碼來源:utils.py

示例4: add_auth_options

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def add_auth_options(options, service_type):
    def add_options(opts, opts_to_add):
        for new_opt in opts_to_add:
            for opt in opts:
                if opt.name == new_opt.name:
                    break
            else:
                opts.append(new_opt)

    opts = copy.deepcopy(options)
    opts.insert(0, loading.get_auth_common_conf_options()[0])
    # NOTE(dims): There are a lot of auth plugins, we just generate
    # the config options for a few common ones
    plugins = ['password', 'v2password', 'v3password']
    for name in plugins:
        plugin = loading.get_plugin_loader(name)
        add_options(opts, loading.get_auth_plugin_conf_options(plugin))
    add_options(opts, loading.get_session_conf_options())
    adapter_opts = loading.get_adapter_conf_options(
        include_deprecated=False)
    cfg.set_defaults(adapter_opts, service_type=service_type,
                     valid_interfaces=DEFAULT_VALID_INTERFACES)
    add_options(opts, adapter_opts)
    opts.sort(key=lambda x: x.name)
    return opts 
開發者ID:openstack,項目名稱:ironic-inspector,代碼行數:27,代碼來源:keystone.py

示例5: set_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_defaults():
    from oslo_middleware import cors
    cfg.set_defaults(cors.CORS_OPTS,
                     allow_headers=[
                         'Authorization',
                         'X-Auth-Token',
                         'X-Subject-Token',
                         'X-User-Id',
                         'X-Domain-Id',
                         'X-Project-Id',
                         'X-Roles']) 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:13,代碼來源:opts.py

示例6: set_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_defaults(logging_context_format_string):
    cfg.set_defaults(
        log_opts,
        logging_context_format_string=logging_context_format_string) 
開發者ID:qunarcorp,項目名稱:open_dnsdb,代碼行數:6,代碼來源:log.py

示例7: parse_args

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def parse_args(args=None, usage=None, default_config_files=None):
    if "OSLO_LOCK_PATH" not in os.environ:
        lockutils.set_defaults(tempfile.gettempdir())

    CONF(args=args,
         project='searchlight',
         version=version.cached_version_string(),
         usage=usage,
         default_config_files=default_config_files) 
開發者ID:openstack,項目名稱:searchlight,代碼行數:11,代碼來源:config.py

示例8: set_cors_middleware_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_cors_middleware_defaults():
    """Update default configuration options for oslo.middleware."""
    # CORS Defaults
    # TODO(krotscheck): Update with https://review.opendev.org/#/c/285368/
    cfg.set_defaults(cors.CORS_OPTS,
                     allow_headers=['X-Auth-Token',
                                    'X-OpenStack-Request-ID'],
                     expose_headers=['X-OpenStack-Request-ID'],
                     allow_methods=['GET',
                                    'POST']
                     ) 
開發者ID:openstack,項目名稱:searchlight,代碼行數:13,代碼來源:config.py

示例9: set_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_defaults(logging_context_format_string=None,
                 default_log_levels=None):
    """Set default values for the configuration options used by oslo.log."""
    # Just in case the caller is not setting the
    # default_log_level. This is insurance because
    # we introduced the default_log_level parameter
    # later in a backwards in-compatible change
    if default_log_levels is not None:
        cfg.set_defaults(
            _options.log_opts,
            default_log_levels=default_log_levels)
    if logging_context_format_string is not None:
        cfg.set_defaults(
            _options.log_opts,
            logging_context_format_string=logging_context_format_string) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:17,代碼來源:log.py

示例10: tempest_set_log_file

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def tempest_set_log_file(filename):
    """Provide an API for tempest to set the logging filename.

    .. warning:: Only Tempest should use this function.

    We don't want applications to set a default log file, so we don't
    want this in set_defaults(). Because tempest doesn't use a
    configuration file we don't have another convenient way to safely
    set the log file default.

    """
    cfg.set_defaults(_options.logging_cli_opts, log_file=filename) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:14,代碼來源:log.py

示例11: set_service_provider_default

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_service_provider_default():
    cfg.set_defaults(provider_configuration.serviceprovider_opts,
                     service_provider=[_dummy_bgpvpn_provider]) 
開發者ID:openstack,項目名稱:networking-bgpvpn,代碼行數:5,代碼來源:opts.py

示例12: set_middleware_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_middleware_defaults():
    """Update default configuration options for oslo.middleware."""
    # CORS Defaults
    # TODO(krotscheck): Update with https://review.openstack.org/#/c/285368/
    cfg.set_defaults(cors.CORS_OPTS,
                     allow_headers=['X-Auth-Token',
                                    'X-Openstack-Request-Id',
                                    'X-Project-Id',
                                    'X-Identity-Status',
                                    'X-User-Id',
                                    'X-Storage-Token',
                                    'X-Domain-Id',
                                    'X-User-Domain-Id',
                                    'X-Project-Domain-Id',
                                    'X-Roles'],
                     expose_headers=['X-Auth-Token',
                                     'X-Openstack-Request-Id',
                                     'X-Project-Id',
                                     'X-Identity-Status',
                                     'X-User-Id',
                                     'X-Storage-Token',
                                     'X-Domain-Id',
                                     'X-User-Domain-Id',
                                     'X-Project-Domain-Id',
                                     'X-Roles'],
                     allow_methods=['GET',
                                    'PUT',
                                    'POST',
                                    'DELETE',
                                    'PATCH']
                     ) 
開發者ID:cloud-security-research,項目名稱:sgx-kms,代碼行數:33,代碼來源:config.py

示例13: parse_config

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def parse_config(args, default_config_files=None):
    set_defaults()
    log.register_options(CONF)
    policy_opts.set_defaults(CONF)
    osprofiler_opts.set_defaults(CONF)
    db_options.set_defaults(CONF)

    for group, options in opts.list_opts():
        CONF.register_opts(list(options),
                           group=None if group == 'DEFAULT' else group)

    CONF(args[1:], project='vitrage', validate_default_values=True,
         default_config_files=default_config_files)

    if CONF.profiler.enabled:
        osprofiler_initializer.init_from_conf(
            conf=CONF,
            context=None,
            project='vitrage',
            service='api',
            host=CONF.api.host
        )

    for datasource in CONF.datasources.types:
        opts.register_opts(datasource, CONF.datasources.path)

    keystone_client.register_keystoneauth_opts()
    log.setup(CONF, 'vitrage')
    CONF.log_opt_values(LOG, log.DEBUG)
    messaging.setup() 
開發者ID:openstack,項目名稱:vitrage,代碼行數:32,代碼來源:config.py

示例14: prepare_service

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def prepare_service(argv=(), conf=cfg.CONF):
    log.register_options(conf)
    gmr_opts.set_defaults(conf)

    config.parse_args(argv)
    cfg.set_defaults(_options.log_opts,
                     default_log_levels=_DEFAULT_LOG_LEVELS)
    log.setup(conf, 'python-watcher')
    conf.log_opt_values(LOG, log.DEBUG)
    objects.register_all()

    gmr.TextGuruMeditation.register_section(
        _('Plugins'), plugins_conf.show_plugins)
    gmr.TextGuruMeditation.setup_autorun(version, conf=conf) 
開發者ID:openstack,項目名稱:watcher,代碼行數:16,代碼來源:service.py

示例15: set_defaults

# 需要導入模塊: from oslo_config import cfg [as 別名]
# 或者: from oslo_config.cfg import set_defaults [as 別名]
def set_defaults(**kwargs):
    """Override the default values for configuration options.

    This method permits a project to override the default CORS option values.
    For example, it may wish to offer a set of sane default headers which
    allow it to function with only minimal additional configuration.

    :param allow_credentials: Whether to permit credentials.
    :type allow_credentials: bool
    :param expose_headers: A list of headers to expose.
    :type expose_headers: List of Strings
    :param max_age: Maximum cache duration in seconds.
    :type max_age: Int
    :param allow_methods: List of HTTP methods to permit.
    :type allow_methods: List of Strings
    :param allow_headers: List of HTTP headers to permit from the client.
    :type allow_headers: List of Strings
    """
    # Since 'None' is a valid config override, we have to use kwargs. Else
    # there's no good way for a user to override only one option, because all
    # the others would be overridden to 'None'.

    valid_params = set(k.name for k in CORS_OPTS
                       if k.name != 'allowed_origin')
    passed_params = set(k for k in kwargs)

    wrong_params = passed_params - valid_params
    if wrong_params:
        raise AttributeError('Parameter(s) [%s] invalid, please only use [%s]'
                             % (wrong_params, valid_params))

    # Set global defaults.
    cfg.set_defaults(CORS_OPTS, **kwargs) 
開發者ID:openstack,項目名稱:oslo.middleware,代碼行數:35,代碼來源:cors.py


注:本文中的oslo_config.cfg.set_defaults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。