本文整理汇总了Python中oslo_config.cfg.ConfigOpts方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.ConfigOpts方法的具体用法?Python cfg.ConfigOpts怎么用?Python cfg.ConfigOpts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_config.cfg
的用法示例。
在下文中一共展示了cfg.ConfigOpts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_sack_size
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def change_sack_size():
conf = cfg.ConfigOpts()
conf.register_cli_opts([_SACK_NUMBER_OPT])
conf = service.prepare_service(conf=conf, log_to_std=True)
s = incoming.get_driver(conf)
try:
report = s.measures_report(details=False)
except incoming.SackDetectionError:
LOG.error('Unable to detect the number of storage sacks.\n'
'Ensure gnocchi-upgrade has been executed.')
return
remainder = report['summary']['measures']
if remainder:
LOG.error('Cannot change sack when non-empty backlog. Process '
'remaining %s measures and try again', remainder)
return
LOG.info("Removing current %d sacks", s.NUM_SACKS)
s.remove_sacks()
LOG.info("Creating new %d sacks", conf.sacks_number)
s.upgrade(conf.sacks_number)
示例2: main
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [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
示例3: setup_config
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setup_config(config_file=''):
global TEST_CONF
TEST_CONF = cfg.ConfigOpts()
TEST_CONF.register_group(identity_group)
TEST_CONF.register_opts(identity_options, group=identity_group)
config_to_load = []
local_config = './etc/castellan/castellan-functional.conf'
main_config = '/etc/castellan/castellan-functional.conf'
if os.path.isfile(config_file):
config_to_load.append(config_file)
elif os.path.isfile(local_config):
config_to_load.append(local_config)
elif os.path.isfile(main_config):
config_to_load.append(main_config)
TEST_CONF(
(), # Required to load an anonymous configuration
default_config_files=config_to_load
)
示例4: _main
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def _main():
import eventlet
eventlet.monkey_patch(all=True)
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active
from oslo_config import cfg
logging.basicConfig(level=logging.DEBUG)
conf = cfg.ConfigOpts()
conf.register_cli_opts(_options.eventlet_backdoor_opts)
conf(sys.argv[1:])
where_running_thread = _initialize_if_enabled(conf)
if not where_running_thread:
raise RuntimeError(_("Did not create backdoor at requested location"))
else:
_where_running, thread = where_running_thread
thread.wait()
示例5: get_conf
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def get_conf(self, conf=CONF):
"""Convert secret store conf into oslo conf
Returns an oslo.config() object to pass to keymanager.API(conf)
"""
vault_conf = cfg.ConfigOpts()
options.set_defaults(
vault_conf,
backend='vault',
vault_root_token_id=conf.vault_plugin.root_token_id,
vault_approle_role_id=conf.vault_plugin.approle_role_id,
vault_approle_secret_id=conf.vault_plugin.approle_secret_id,
vault_kv_mountpoint=conf.vault_plugin.kv_mountpoint,
vault_url=conf.vault_plugin.vault_url,
vault_ssl_ca_crt_file=conf.vault_plugin.ssl_ca_crt_file,
vault_use_ssl=conf.vault_plugin.use_ssl
)
return vault_conf
示例6: paste_deploy_app
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def paste_deploy_app(paste_config_file, app_name, conf):
"""Load a WSGI app from a PasteDeploy configuration.
Use deploy.loadapp() to load the app from the PasteDeploy configuration,
ensuring that the supplied ConfigOpts object is passed to the app and
filter constructors.
:param paste_config_file: a PasteDeploy config file
:param app_name: the name of the app/pipeline to load from the file
:param conf: a ConfigOpts object to supply to the app and its filters
:returns: the WSGI app
"""
setup_paste_factories(conf)
try:
return deploy.loadapp("config:%s" % paste_config_file, name=app_name)
finally:
teardown_paste_factories()
示例7: create
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def create(context, conf):
config_dir = utils.find_config(CONF.provider_config_dir)
config_file = os.path.abspath(os.path.join(config_dir,
'eisoo.conf'))
config = cfg.ConfigOpts()
config(args=['--config-file=' + config_file])
config.register_opts(eisoo_client_opts,
group=SERVICE + '_client')
LOG.info('Creating eisoo client with url %s.',
config.eisoo_client.eisoo_endpoint)
abclient = client.ABClient(config.eisoo_client.eisoo_endpoint,
config.eisoo_client.eisoo_app_id,
config.eisoo_client.eisoo_app_secret)
return abclient
示例8: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
super(KubernetesClientTest, self).setUp()
self._context = RequestContext(user_id='demo',
project_id='abcd',
auth_token='efgh',
service_catalog=None)
self.conf = cfg.ConfigOpts()
k8s.register_opts(self.conf)
self.host_url = 'https://192.168.98.35:6443'
self.conf.set_default('k8s_host',
self.host_url,
'k8s_client')
self.conf.set_override('k8s_ssl_ca_cert',
'/etc/provider.d/server-ca.crt',
'k8s_client')
self.conf.set_override('k8s_cert_file',
'/etc/provider.d/client-admin.crt',
'k8s_client')
self.conf.set_override('k8s_key_file',
'/etc/provider.d/client-admin.key',
'k8s_client')
示例9: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
super(SwiftClientTest, self).setUp()
service_catalog = [
{
'endpoints': [
{'publicURL': 'http://127.0.0.1:8080/v1/AUTH_abcd', }
],
'type': 'object-store',
'name': 'swift',
},
]
self._context = RequestContext(user_id='demo',
project_id='abcd',
auth_token='efgh',
service_catalog=service_catalog)
self.conf = cfg.ConfigOpts()
swift.register_opts(self.conf)
示例10: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def setUp(self):
super(CinderProtectionPluginTest, self).setUp()
plugin_config = cfg.ConfigOpts()
plugin_config_fixture = self.useFixture(fixture.Config(plugin_config))
plugin_config_fixture.load_raw_values(
group='cinder_backup_protection_plugin',
poll_interval=0,
)
self.plugin = CinderBackupProtectionPlugin(plugin_config)
cfg.CONF.set_default('cinder_endpoint',
'http://127.0.0.1:8776/v2',
'cinder_client')
self.cntxt = RequestContext(user_id='demo',
project_id='abcd',
auth_token='efgh')
self.cinder_client = client_factory.ClientFactory.create_client(
"cinder", self.cntxt)
示例11: __init__
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def __init__(self, application, conf=None):
"""Base middleware constructor
:param conf: a cfg.ConfigOpts object
"""
self.application = application
self.oslo_conf = conf
示例12: prepare_conf
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def prepare_conf():
conf = cfg.ConfigOpts()
opts.set_defaults()
policy_opts.set_defaults(conf)
return conf
示例13: metricd
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def metricd():
conf = cfg.ConfigOpts()
conf.register_cli_opts([
cfg.IntOpt("stop-after-processing-metrics",
default=0,
min=0,
help="Number of metrics to process without workers, "
"for testing purpose"),
])
conf = service.prepare_service(conf=conf)
if conf.stop_after_processing_metrics:
metricd_tester(conf)
else:
MetricdServiceManager(conf).run()
示例14: upgrade
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def upgrade():
conf = cfg.ConfigOpts()
sack_number_opt = copy.copy(_SACK_NUMBER_OPT)
sack_number_opt.default = 128
conf.register_cli_opts([
cfg.BoolOpt("skip-index", default=False,
help="Skip index upgrade."),
cfg.BoolOpt("skip-storage", default=False,
help="Skip storage upgrade."),
cfg.BoolOpt("skip-incoming", default=False,
help="Skip incoming storage upgrade."),
cfg.BoolOpt("skip-archive-policies-creation", default=False,
help="Skip default archive policies creation."),
sack_number_opt,
])
conf = service.prepare_service(conf=conf, log_to_std=True)
if not conf.skip_index:
index = indexer.get_driver(conf)
LOG.info("Upgrading indexer %s", index)
index.upgrade()
if not conf.skip_storage:
s = storage.get_driver(conf)
LOG.info("Upgrading storage %s", s)
s.upgrade()
if not conf.skip_incoming:
i = incoming.get_driver(conf)
LOG.info("Upgrading incoming storage %s", i)
i.upgrade(conf.sacks_number)
if (not conf.skip_archive_policies_creation
and not index.list_archive_policies()
and not index.list_archive_policy_rules()):
if conf.skip_index:
index = indexer.get_driver(conf)
for name, ap in six.iteritems(archive_policy.DEFAULT_ARCHIVE_POLICIES):
index.create_archive_policy(ap)
index.create_archive_policy_rule("default", "*", "low")
示例15: prepare_service
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import ConfigOpts [as 别名]
def prepare_service(conf=None):
if conf is None:
conf = cfg.ConfigOpts()
opts.set_defaults()
policy_opts.set_defaults(conf)
conf = service.prepare_service(conf=conf)
cfg_path = conf.oslo_policy.policy_file
if not os.path.isabs(cfg_path):
cfg_path = conf.find_file(cfg_path)
if cfg_path is None or not os.path.exists(cfg_path):
cfg_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', 'rest', 'policy.json'))
conf.set_default('policy_file', cfg_path, group='oslo_policy')
return conf