本文整理汇总了Python中oslo_config.cfg.SubCommandOpt方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.SubCommandOpt方法的具体用法?Python cfg.SubCommandOpt怎么用?Python cfg.SubCommandOpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_config.cfg
的用法示例。
在下文中一共展示了cfg.SubCommandOpt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [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
示例2: parse_config
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def parse_config():
DB_INIT = [
cfg.SubCommandOpt('db',
dest='db',
title='DB Options',
handler=add_db_opts
)
]
# register database backend drivers
config.register_db_drivers_opt()
# register database cli options
CONF.register_cli_opts(DB_INIT)
# register logging opts
log.register_options(CONF)
default_config_files = cfg.find_config_files('freezer', 'freezer-api')
CONF(args=sys.argv[1:],
project='freezer-api',
default_config_files=default_config_files,
version=FREEZER_API_VERSION
)
示例3: main
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def main():
command_opt = cfg.SubCommandOpt('command',
title='Command',
help='Available commands',
handler=add_command_parsers)
CONF.register_cli_opt(command_opt)
CONF(project='zun')
CONF.command.func()
示例4: test_run_db_manage_app
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def test_run_db_manage_app(self, m_sys, m_prepare_service):
# Patch command function
m_func = mock.Mock()
cfg.CONF.register_opt(cfg.SubCommandOpt("command"))
cfg.CONF.command.func = m_func
# Only append if the command is not None
m_sys.argv = list(filter(None, ["watcher-db-manage", self.command]))
dbmanage.main()
self.assertEqual(1, m_func.call_count)
m_prepare_service.assert_called_once_with(
["watcher-db-manage", self.expected], cfg.CONF)
示例5: main
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def main():
command_opt = cfg.SubCommandOpt('command',
title='Command',
help=_('Available commands'),
handler=add_command_parsers)
CONF.register_cli_opt(command_opt)
service.prepare_service(sys.argv)
CONF.command.func()
示例6: list_cli_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import SubCommandOpt [as 别名]
def list_cli_opts():
return [
cfg.SubCommandOpt(name="sub_command",
handler=sub_commands,
help=_("Available commands"),
title="syntribos Commands"),
cfg.MultiStrOpt("test-types", dest="test_types", short="t",
default=[""], sample_default=["SQL", "XSS"],
help=_(
"Test types to run against the target API")),
cfg.MultiStrOpt("excluded-types", dest="excluded_types", short="e",
default=[""], sample_default=["SQL", "XSS"],
help=_("Test types to be excluded from "
"current run against the target API")),
cfg.BoolOpt("colorize", dest="colorize", short="cl",
default=True,
help=_("Enable color in syntribos terminal output")),
cfg.StrOpt("outfile", short="o",
sample_default="out.json", help=_("File to print "
"output to")),
cfg.StrOpt("format", dest="output_format", short="f", default="json",
choices=["json"], ignore_case=True,
help=_("The format for outputting results")),
cfg.StrOpt("min-severity", dest="min_severity", short="S",
default="LOW", choices=syntribos.RANKING,
help=_("Select a minimum severity for reported "
"defects")),
cfg.StrOpt("min-confidence", dest="min_confidence", short="C",
default="LOW", choices=syntribos.RANKING,
help=_("Select a minimum confidence for reported "
"defects")),
cfg.BoolOpt("stacktrace", dest="stacktrace", default=True,
help=_("Select if Syntribos outputs a stacktrace "
" if an exception is raised")),
cfg.StrOpt(
"custom_root", dest="custom_root",
help=_("Filesystem location for syntribos root directory, "
"containing logs, templates, payloads, config files. "
"Creates directories and skips interactive prompts when "
"used with 'syntribos init'"),
deprecated_group="init", deprecated_name="custom_install_root")
]