本文整理汇总了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']
)
示例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)
示例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
示例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
示例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'])
示例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)
示例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)
示例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']
)
示例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)
示例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)
示例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])
示例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']
)
示例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()
示例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)
示例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)