本文整理汇总了Python中ovs.lib.vdisk.VDiskController.get_config_params方法的典型用法代码示例。如果您正苦于以下问题:Python VDiskController.get_config_params方法的具体用法?Python VDiskController.get_config_params怎么用?Python VDiskController.get_config_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.lib.vdisk.VDiskController
的用法示例。
在下文中一共展示了VDiskController.get_config_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_and_get_config_params
# 需要导入模块: from ovs.lib.vdisk import VDiskController [as 别名]
# 或者: from ovs.lib.vdisk.VDiskController import get_config_params [as 别名]
def test_set_and_get_config_params(self):
"""
Test the set_config_params functionality by validation through the get_config_params functionality
- Verify default configuration for newly created vDisk
- Attempt to set disallowed values
- Attempt to sync and async mode without specifying DTL target
- Set SCO size
"""
structure = Helper.build_service_structure(
{'vpools': [1],
'storagerouters': [1],
'storagedrivers': [(1, 1, 1)], # (<id>, <vpool_id>, <storagerouter_id>)
'mds_services': [(1, 1)]} # (<id>, <storagedriver_id>)
)
storagedrivers = structure['storagedrivers']
# Create vDisk and validate default configuration
vdisk_1 = VDisk(VDiskController.create_new(volume_name='vdisk_1', volume_size=1024 ** 3, storagedriver_guid=storagedrivers[1].guid))
configuration = VDiskController.get_config_params(vdisk_guid=vdisk_1.guid)
expected_keys = {'sco_size', 'dtl_mode', 'write_buffer', 'dtl_target', 'metadata_cache_size'}
self.assertEqual(first=expected_keys,
second=set(configuration.keys()),
msg='Keys returned by get_config_params do not match the expected keys')
tlog_multiplier = vdisk_1.storagedriver_client.get_tlog_multiplier(vdisk_1.volume_id)
default_sco_size = vdisk_1.storagedriver_client.get_sco_multiplier(vdisk_1.volume_id) / 1024 * 4
non_disposable_sco_factor = vdisk_1.storagedriver_client.get_sco_cache_max_non_disposable_factor(vdisk_1.volume_id)
cache_capacity = 4096 # Based on 1GiB size and "metadata_page_capacity" of 64 (6 bits)
default_values = {'sco_size': default_sco_size,
'dtl_mode': StorageDriverClient.FRAMEWORK_DTL_NO_SYNC,
'dtl_target': [],
'write_buffer': int(tlog_multiplier * default_sco_size * non_disposable_sco_factor),
'metadata_cache_size': StorageDriverClient.METADATA_CACHE_PAGE_SIZE * cache_capacity}
for key, value in default_values.iteritems():
self.assertEqual(first=configuration[key],
second=value,
msg='Value for "{0}" does not match expected default value: {1} vs {2}'.format(key, configuration[key], value))
# Attempt to set incorrect values
new_config_params = {'dtl_mode': StorageDriverClient.FRAMEWORK_DTL_NO_SYNC,
'sco_size': 4,
'dtl_target': [],
'write_buffer': 128}
for key, values in {'dtl_mode': ['unknown', StorageDriverClient.VOLDRV_DTL_ASYNC],
'sco_size': list(set(range(257)).difference({4, 8, 16, 32, 64, 128})) + [-1],
'dtl_target': ['', {}, (), 0],
'write_buffer': [-1] + range(128) + range(10241, 10300),
'metadata_cache_size': [-1] + range(256 * 24)}.iteritems():
for value in values:
config_params = copy.deepcopy(new_config_params)
config_params[key] = value
with self.assertRaises(RuntimeError):
VDiskController.set_config_params(vdisk_guid=vdisk_1.guid, new_config_params=config_params)
# Attempt to set DTL mode sync or async without specifying a target
for dtl_mode in [StorageDriverClient.FRAMEWORK_DTL_SYNC, StorageDriverClient.FRAMEWORK_DTL_ASYNC]:
config_params = copy.deepcopy(new_config_params)
config_params['dtl_mode'] = dtl_mode
with self.assertRaises(ValueError):
VDiskController.set_config_params(vdisk_guid=vdisk_1.guid, new_config_params=config_params)
# Set SCO size
set_config = copy.deepcopy(new_config_params)
set_config['sco_size'] = 32
VDiskController.set_config_params(vdisk_guid=vdisk_1.guid, new_config_params=set_config)
get_config = VDiskController.get_config_params(vdisk_guid=vdisk_1.guid)
for key in set_config.iterkeys():
self.assertEqual(first=set_config[key],
second=get_config[key],
msg='Actual value for key "{0}" differs from expected. Expected: {1} - Actual: {2}'.format(key, set_config[key], get_config[key]))