本文整理汇总了Python中oslo_config.cfg.DictOpt方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.DictOpt方法的具体用法?Python cfg.DictOpt怎么用?Python cfg.DictOpt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_config.cfg
的用法示例。
在下文中一共展示了cfg.DictOpt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_conf
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setup_conf():
cli_opts = [
cfg.DictOpt('mount_paths',
required=True,
help=_('Dict of paths to bind-mount (source:target) '
'prior to launch subprocess.')),
cfg.ListOpt(
'cmd',
required=True,
help=_('Command line to execute as a subprocess '
'provided as comma-separated list of arguments.')),
cfg.StrOpt('rootwrap_config', default='/etc/neutron/rootwrap.conf',
help=_('Rootwrap configuration file.')),
]
conf = cfg.CONF
conf.register_cli_opts(cli_opts)
return conf
示例2: get_config_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def get_config_opts(cls):
return [
cfg.IntOpt(
'max_workers',
default=processutils.get_worker_count(),
min=1,
required=True,
help='Number of workers for taskflow engine '
'to execute actions.'),
cfg.DictOpt(
'action_execution_rule',
default={},
help='The execution rule for linked actions,'
'the key is strategy name and '
'value ALWAYS means all actions will be executed,'
'value ANY means if previous action executes '
'success, the next action will be ignored.'
'None means ALWAYS.')
]
示例3: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
"""Establish a clean test environment."""
super(TestMultiStore, self).setUp()
self.enabled_backends = {
"file1": "file",
"file2": "file",
}
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=self.enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='file1', group='glance_store')
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.test_dir = self.useFixture(fixtures.TempDir()).path
self.addCleanup(self.conf.reset)
self.store = filesystem.Store(self.conf, backend='file1')
self.config(filesystem_store_datadir=self.test_dir,
filesystem_store_chunk_size=10,
group="file1")
self.store.configure()
self.register_store_backend_schemes(self.store, 'file', 'file1')
示例4: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
super(TestMultiCinderStore, self).setUp()
enabled_backends = {
"cinder1": "cinder",
"cinder2": "cinder"
}
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='cinder1', group='glance_store')
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.test_dir = self.useFixture(fixtures.TempDir()).path
self.addCleanup(self.conf.reset)
self.store = cinder.Store(self.conf, backend="cinder1")
self.store.configure()
self.register_store_backend_schemes(self.store, 'cinder', 'cinder1')
self.store.READ_CHUNKSIZE = 4096
self.store.WRITE_CHUNKSIZE = 4096
fake_sc = [{u'endpoints': [{u'publicURL': u'http://foo/public_url'}],
u'endpoints_links': [],
u'name': u'cinder',
u'type': u'volumev2'}]
self.context = FakeObject(service_catalog=fake_sc,
user='fake_user',
auth_token='fake_token',
tenant='fake_tenant')
示例5: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
"""Establish a clean test environment."""
super(TestMultiStore, self).setUp()
enabled_backends = {
"ceph1": "rbd",
"ceph2": "rbd"
}
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='ceph1', group='glance_store')
# Ensure stores + locations cleared
g_location.SCHEME_TO_CLS_BACKEND_MAP = {}
with mock.patch.object(rbd_store.Store, '_set_url_prefix'):
store.create_multi_stores(self.conf)
self.addCleanup(setattr, g_location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.addCleanup(self.conf.reset)
rbd_store.rados = MockRados
rbd_store.rbd = MockRBD
self.store = rbd_store.Store(self.conf, backend="ceph1")
self.store.configure()
self.store.chunk_size = 2
self.called_commands_actual = []
self.called_commands_expected = []
self.store_specs = {'pool': 'fake_pool',
'image': 'fake_image',
'snapshot': 'fake_snapshot'}
self.location = rbd_store.StoreLocation(self.store_specs,
self.conf)
# Provide enough data to get more than one chunk iteration.
self.data_len = 3 * units.Ki
self.data_iter = six.BytesIO(b'*' * self.data_len)
示例6: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
super(HostMountStateTestCase, self).setUp()
CONF.register_opt(cfg.DictOpt('enabled_backends'))
CONF.set_override('enabled_backends', 'fake:file')
# Since this is mocked in other tests, we unmock it here
if 'glance_store.common.fs_mount' in sys.modules:
sys.modules.pop('glance_store.common.fs_mount')
# Since the _HostMountStateManager class instantiates on its
# import, this import is done here to register the enabled_backends
# config option before it is used during initialization
from glance_store.common import fs_mount as mount # noqa
self.mounted = set()
self.m = mount._HostMountState()
def fake_execute(cmd, *args, **kwargs):
if cmd == 'mount':
path = args[-1]
if path in self.mounted:
raise processutils.ProcessExecutionError('Already mounted')
self.mounted.add(path)
elif cmd == 'umount':
path = args[-1]
if path not in self.mounted:
raise processutils.ProcessExecutionError('Not mounted')
self.mounted.remove(path)
def fake_ismount(path):
return path in self.mounted
mock_execute = mock.MagicMock(side_effect=fake_execute)
self.useFixture(fixtures.MonkeyPatch(
'oslo_concurrency.processutils.execute',
mock_execute))
self.useFixture(fixtures.MonkeyPatch('os.path.ismount', fake_ismount))
示例7: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
super(TestMultiStoreBase, self).setUp()
enabled_backends = {
"fast": "file",
"cheap": "file",
}
self.reserved_stores = {
'consuming_service_reserved_store': 'file'
}
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf,
reserved_stores=self.reserved_stores)
self.config(default_backend='file1', group='glance_store')
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf,
reserved_stores=self.reserved_stores)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.addCleanup(self.conf.reset)
示例8: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
"""Establish a clean test environment."""
super(TestStoreAuthV1, self).setUp()
enabled_backends = {
"swift1": "swift",
"swift2": "swift",
}
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='swift1', group='glance_store')
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.test_dir = self.useFixture(fixtures.TempDir()).path
config = self.getConfig()
conf_file = 'glance-swift.conf'
self.swift_config_file = self.copy_data_file(conf_file, self.test_dir)
config.update({'swift_store_config_file': self.swift_config_file})
self.stub_out_swiftclient(config['swift_store_auth_version'])
self.mock_keystone_client()
self.store = Store(self.conf, backend="swift1")
self.config(group="swift1", **config)
self.store.configure()
self.register_store_backend_schemes(self.store, 'swift', 'swift1')
self.addCleanup(self.conf.reset)
示例9: get_config_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def get_config_opts(cls):
return [
cfg.DictOpt(
'weights',
help="These weights are used to schedule the actions",
default=cls.weights_dict),
]
示例10: get_config_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def get_config_opts(cls):
return [
cfg.DictOpt(
'weights',
help="These weights are used to schedule the actions. "
"Action Plan will be build in accordance with sets of "
"actions ordered by descending weights."
"Two action types cannot have the same weight. ",
default=cls.action_weights),
cfg.DictOpt(
'parallelization',
help="Number of actions to be run in parallel on a per "
"action type basis.",
default=cls.parallelization),
]
示例11: _register_app_opts
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def _register_app_opts():
# Note "host", "port", "allow_origin", "mask_secrets" options are registered as part of
# st2common config since they are also used outside st2api
static_root = os.path.join(cfg.CONF.system.base_path, 'static')
template_path = os.path.join(BASE_DIR, 'templates/')
pecan_opts = [
cfg.StrOpt(
'root', default='st2api.controllers.root.RootController',
help='Action root controller'),
cfg.StrOpt('static_root', default=static_root),
cfg.StrOpt('template_path', default=template_path),
cfg.ListOpt('modules', default=['st2api']),
cfg.BoolOpt('debug', default=False),
cfg.BoolOpt('auth_enable', default=True),
cfg.DictOpt('errors', default={'__force_dict__': True})
]
CONF.register_opts(pecan_opts, group='api_pecan')
logging_opts = [
cfg.BoolOpt('debug', default=False),
cfg.StrOpt(
'logging', default='/etc/st2/logging.api.conf',
help='location of the logging.conf file'),
cfg.IntOpt(
'max_page_size', default=100,
help='Maximum limit (page size) argument which can be '
'specified by the user in a query string.')
]
CONF.register_opts(logging_opts, group='api')
示例12: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self, mock_api_session, mock_get_datastore):
"""Establish a clean test environment."""
super(TestMultiStore, self).setUp()
enabled_backends = {
"vmware1": "vmware",
"vmware2": "vmware"
}
self.hash_algo = 'sha256'
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='vmware1', group='glance_store')
# set vmware related config options
self.config(group='vmware1',
vmware_server_username='admin',
vmware_server_password='admin',
vmware_server_host='127.0.0.1',
vmware_insecure='True',
vmware_datastores=['a:b:0'],
vmware_store_image_dir='/openstack_glance')
self.config(group='vmware2',
vmware_server_username='admin',
vmware_server_password='admin',
vmware_server_host='127.0.0.1',
vmware_insecure='True',
vmware_datastores=['a:b:1'],
vmware_store_image_dir='/openstack_glance_1')
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.addCleanup(self.conf.reset)
vm_store.Store.CHUNKSIZE = 2
mock_get_datastore.side_effect = fake_datastore_obj
self.store = vm_store.Store(self.conf, backend="vmware1")
self.store.configure()
示例13: setUp
# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import DictOpt [as 别名]
def setUp(self):
"""Establish a clean test environment."""
super(TestMultiS3Store, self).setUp()
enabled_backends = {
"s3_region1": "s3",
"s3_region2": "s3"
}
self.hash_algo = 'sha256'
self.conf = self._CONF
self.conf(args=[])
self.conf.register_opt(cfg.DictOpt('enabled_backends'))
self.config(enabled_backends=enabled_backends)
store.register_store_opts(self.conf)
self.config(default_backend='s3_region1', group='glance_store')
# set s3 related config options
self.config(group='s3_region1',
s3_store_access_key='user',
s3_store_secret_key='key',
s3_store_host='https://s3-region1.com',
s3_store_bucket='glance',
s3_store_large_object_size=5,
s3_store_large_object_chunk_size=6)
self.config(group='s3_region2',
s3_store_access_key='user',
s3_store_secret_key='key',
s3_store_host='http://s3-region2.com',
s3_store_bucket='glance',
s3_store_large_object_size=5,
s3_store_large_object_chunk_size=6)
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_BACKEND_MAP = {}
store.create_multi_stores(self.conf)
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP',
dict())
self.addCleanup(self.conf.reset)
self.store = s3.Store(self.conf, backend="s3_region1")
self.store.configure()
self.register_store_backend_schemes(self.store, 's3', 's3_region1')