本文整理汇总了Python中oslo_config.cfg.NoSuchOptError方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.NoSuchOptError方法的具体用法?Python cfg.NoSuchOptError怎么用?Python cfg.NoSuchOptError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_config.cfg
的用法示例。
在下文中一共展示了cfg.NoSuchOptError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def __init__(self, message=None, **kwargs):
self.kwargs = kwargs
if 'code' not in self.kwargs and hasattr(self, 'code'):
self.kwargs['code'] = self.code
if message:
self.message = message
try:
self.message = self.message % kwargs
except KeyError:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception('Exception in string format operation, '
'kwargs: %s', kwargs)
try:
ferr = CONF.fatal_exception_format_errors
except cfg.NoSuchOptError:
ferr = CONF.oslo_versionedobjects.fatal_exception_format_errors
if ferr:
raise
super(ZunException, self).__init__(self.message)
示例2: set_user_creds
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def set_user_creds(cls, config):
# normal user creds
# Fixme(eliqiao): this is quick workaround to passing tempest
# legacy credentials provider is removed by tempest
# I8c24cd17f643083dde71ab2bd2a38417c54aeccb.
# TODO(eliqiao): find a way to using an accounts.yaml file
# check Ia5132c5cb32355d6f26b8acdd92a0e55a2c19f41
cls.user = CONF.auth.admin_username
cls.passwd = CONF.auth.admin_password
# NOTE(toabctl): also allow the old style tempest definition
try:
cls.tenant = CONF.auth.admin_project_name
except cfg.NoSuchOptError:
cls.tenant = CONF.auth.admin_tenant_name
warnings.warn("the config option 'admin_tenant_name' from the "
"'auth' section is deprecated. Please switch "
"to 'admin_project_name'.")
示例3: __init__
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def __init__(self, message=None, **kwargs):
self.kwargs = kwargs
if 'code' not in self.kwargs and hasattr(self, 'code'):
self.kwargs['code'] = self.code
if message:
self.message = message
try:
self.message = self.message % kwargs
except Exception:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception('Exception in string format operation, '
'kwargs: %s', kwargs)
try:
if CONF.fatal_exception_format_errors:
raise
except cfg.NoSuchOptError:
# Note: work around for Bug: #1447873
if CONF.oslo_versionedobjects.fatal_exception_format_errors:
raise
super(MagnumException, self).__init__(self.message)
示例4: set_mysql_engine
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def set_mysql_engine():
try:
mysql_engine = neutron_config.command.mysql_engine
except cfg.NoSuchOptError:
mysql_engine = None
global MYSQL_ENGINE
MYSQL_ENGINE = (mysql_engine or
model_base.BASEV2.__table_args__['mysql_engine'])
示例5: is_loaded
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def is_loaded(self):
try:
return (odl_const.ODL_ML2_MECH_DRIVER_V2 in
cfg.CONF.ml2.mechanism_drivers)
except cfg.NoSuchOptError:
return False
示例6: set_admin_creds
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def set_admin_creds(cls, config):
cls.admin_user = CONF.auth.admin_username
cls.admin_passwd = CONF.auth.admin_password
# NOTE(toabctl): also allow the old style tempest definition
try:
cls.admin_tenant = CONF.auth.admin_project_name
except cfg.NoSuchOptError:
cls.admin_tenant = CONF.auth.admin_tenant_name
warnings.warn("the config option 'admin_tenant_name' from the "
"'auth' section is deprecated. Please switch "
"to 'admin_project_name'.")
示例7: safe_get
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def safe_get(self, value):
try:
return self.__getattr__(value)
except cfg.NoSuchOptError:
return None
示例8: opt_exists
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def opt_exists(conf_parent, opt):
try:
return conf_parent[opt]
except cfg.NoSuchOptError:
return False
示例9: metrics_initialize
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def metrics_initialize():
"""
Initialize metrics constant
"""
global METRICS
try:
METRICS = get_plugin_instance(PLUGIN_NAMESPACE, cfg.CONF.metrics.driver)
except (NoMatches, MultipleMatches, NoSuchOptError) as error:
raise PluginLoadError('Error loading metrics driver. Check configuration: %s' % error)
return METRICS
示例10: safe_get
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import NoSuchOptError [as 别名]
def safe_get(self, value):
"""get default group value from CONF
:param value: value.
:return: get default group value from CONF.
"""
try:
return self.__getattr__(value)
except cfg.NoSuchOptError:
return None