本文整理汇总了Python中oslo_config.cfg.Opt方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.Opt方法的具体用法?Python cfg.Opt怎么用?Python cfg.Opt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_config.cfg
的用法示例。
在下文中一共展示了cfg.Opt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def test_list_opts(self):
for group, opt_list in opts.list_opts():
if isinstance(group, str):
self.assertEqual('DEFAULT', group)
else:
self.assertIsInstance(group, cfg.OptGroup)
for opt in opt_list:
self.assertIsInstance(opt, cfg.Opt)
示例2: test_list_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def test_list_opts(self):
for group, opt_list in opts.list_opts():
if isinstance(group, six.string_types):
self.assertEqual(group, 'DEFAULT')
else:
self.assertIsInstance(group, cfg.OptGroup)
for opt in opt_list:
self.assertIsInstance(opt, cfg.Opt)
示例3: _register_sensor_container_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def _register_sensor_container_opts():
partition_opts = [
cfg.StrOpt(
'sensor_node_name', default='sensornode1',
help='name of the sensor node.'),
cfg.Opt(
'partition_provider',
type=types.Dict(value_type=types.String()),
default={'name': DEFAULT_PARTITION_LOADER},
help='Provider of sensor node partition config.')
]
_register_opts(partition_opts, group='sensorcontainer')
# Other options
other_opts = [
cfg.BoolOpt(
'single_sensor_mode', default=False,
help='Run in a single sensor mode where parent process exits when a sensor crashes / '
'dies. This is useful in environments where partitioning, sensor process life '
'cycle and failover is handled by a 3rd party service such as kubernetes.')
]
_register_opts(other_opts, group='sensorcontainer')
# CLI options
cli_opts = [
cfg.StrOpt(
'sensor-ref',
help='Only run sensor with the provided reference. Value is of the form '
'<pack>.<sensor-name> (e.g. linux.FileWatchSensor).'),
cfg.BoolOpt(
'single-sensor-mode', default=False,
help='Run in a single sensor mode where parent process exits when a sensor crashes / '
'dies. This is useful in environments where partitioning, sensor process life '
'cycle and failover is handled by a 3rd party service such as kubernetes.')
]
_register_cli_opts(cli_opts)
示例4: _dummy_opt
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def _dummy_opt(name):
# A config option that can't be set by the user, so it behaves as if it's
# ignored; but consuming code may expect it to be present in a conf group.
return cfg.Opt(name, type=lambda x: None)
示例5: list_syntribos_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def list_syntribos_opts():
def wrap_try_except(func):
def wrap(*args):
try:
func(*args)
except IOError:
msg = _(
"\nCan't open a file or directory specified in the "
"config file under the section `[syntribos]`; verify "
"if the path exists.\nFor more information please refer "
"the debug logs.")
print(msg)
exit(1)
return wrap
return [
cfg.StrOpt("endpoint", default="",
sample_default="http://localhost/app",
help=_("The target host to be tested")),
cfg.IntOpt("threads", default=16,
sample_default="16",
help=_("Maximum number of threads syntribos spawns "
"(experimental)")),
cfg.Opt("templates", type=ContentType("r"),
default="",
sample_default="~/.syntribos/templates",
help=_("A directory of template files, or a single "
"template file, to test on the target API")),
cfg.StrOpt("payloads", default="",
sample_default="~/.syntribos/data",
help=_(
"The location where we can find syntribos'"
"payloads")),
cfg.MultiStrOpt("exclude_results",
default=[""],
sample_default=["500_errors", "length_diff"],
help=_(
"Defect types to exclude from the "
"results output")),
cfg.Opt("custom_root", type=wrap_try_except(ExistingDirType()),
short="c",
sample_default="/your/custom/root",
help=_(
"The root directory where the subfolders that make up"
" syntribos' environment (logs, templates, payloads, "
"configuration files, etc.)"),
deprecated_for_removal=True),
cfg.StrOpt("meta_vars", sample_default="/path/to/meta.json",
help=_(
"The path to a meta variable definitions file, which "
"will be used when parsing your templates")),
]
示例6: _register_sensor_container_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import Opt [as 别名]
def _register_sensor_container_opts(ignore_errors=False):
logging_opts = [
cfg.StrOpt(
'logging', default='/etc/st2/logging.sensorcontainer.conf',
help='location of the logging.conf file')
]
st2cfg.do_register_opts(logging_opts, group='sensorcontainer', ignore_errors=ignore_errors)
# Partitioning options
partition_opts = [
cfg.StrOpt(
'sensor_node_name', default='sensornode1',
help='name of the sensor node.'),
cfg.Opt(
'partition_provider',
type=types.Dict(value_type=types.String()),
default={'name': DEFAULT_PARTITION_LOADER},
help='Provider of sensor node partition config.')
]
st2cfg.do_register_opts(partition_opts, group='sensorcontainer', ignore_errors=ignore_errors)
# Other options
other_opts = [
cfg.BoolOpt(
'single_sensor_mode', default=False,
help='Run in a single sensor mode where parent process exits when a sensor crashes / '
'dies. This is useful in environments where partitioning, sensor process life '
'cycle and failover is handled by a 3rd party service such as kubernetes.')
]
st2cfg.do_register_opts(other_opts, group='sensorcontainer', ignore_errors=ignore_errors)
# CLI options
cli_opts = [
cfg.StrOpt(
'sensor-ref',
help='Only run sensor with the provided reference. Value is of the form '
'<pack>.<sensor-name> (e.g. linux.FileWatchSensor).'),
cfg.BoolOpt(
'single-sensor-mode', default=False,
help='Run in a single sensor mode where parent process exits when a sensor crashes / '
'dies. This is useful in environments where partitioning, sensor process life '
'cycle and failover is handled by a 3rd party service such as kubernetes.')
]
st2cfg.do_register_cli_opts(cli_opts, ignore_errors=ignore_errors)