本文整理匯總了Python中ovs.lib.mdsservice.MDSServiceController.get_mds_storagedriver_config_set方法的典型用法代碼示例。如果您正苦於以下問題:Python MDSServiceController.get_mds_storagedriver_config_set方法的具體用法?Python MDSServiceController.get_mds_storagedriver_config_set怎麽用?Python MDSServiceController.get_mds_storagedriver_config_set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ovs.lib.mdsservice.MDSServiceController
的用法示例。
在下文中一共展示了MDSServiceController.get_mds_storagedriver_config_set方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_storagedriver_config_set
# 需要導入模塊: from ovs.lib.mdsservice import MDSServiceController [as 別名]
# 或者: from ovs.lib.mdsservice.MDSServiceController import get_mds_storagedriver_config_set [as 別名]
def test_storagedriver_config_set(self):
"""
Validates whether storagedriver configuration is generated as expected
"""
PersistentFactory.get_client().set('ovs.storagedriver.mds.safety', 3)
vpools, storagerouters, storagedrivers, services, mds_services, _ = self._build_service_structure(
{'vpools': [1, 2],
'storagerouters': [1, 2, 3, 4, 5, 6],
'storagedrivers': [(1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4), (5, 2, 4), (6, 2, 5), (7, 2, 6)], # (<id>, <vpool_id>, <sr_id>)
'mds_services': [(1, 1), (2, 1), (3, 2), (4, 3), (5, 4), (6, 5), (7, 6), (8, 7), (9, 7)]} # (<id>, <sd_id>)
)
vdisks = {}
start_id = 1
for mds_service in mds_services.itervalues():
vdisks.update(self._create_vdisks_for_mds_service(10, start_id, mds_service=mds_service))
start_id += 10
mds_services[1].capacity = 11 # on 1, vpool 1
mds_services[1].save()
mds_services[2].capacity = 20 # on 1, vpool 1
mds_services[2].save()
mds_services[3].capacity = 12 # on 2, vpool 1
mds_services[3].save()
mds_services[4].capacity = 14 # on 3, vpool 1
mds_services[4].save()
mds_services[5].capacity = 16 # on 4, vpool 1
mds_services[5].save()
mds_services[6].capacity = 11 # on 4, vpool 2
mds_services[6].save()
mds_services[7].capacity = 13 # on 5, vpool 2
mds_services[7].save()
mds_services[8].capacity = 19 # on 6, vpool 2
mds_services[8].save()
mds_services[9].capacity = 15 # on 6, vpool 2
mds_services[9].save()
config = MDSServiceController.get_mds_storagedriver_config_set(vpools[1])
expected = {storagerouters[1].guid: [{'host': '10.0.0.1', 'port': 2},
{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.3', 'port': 4}],
storagerouters[2].guid: [{'host': '10.0.0.2', 'port': 3},
{'host': '10.0.0.1', 'port': 2},
{'host': '10.0.0.4', 'port': 5}],
storagerouters[3].guid: [{'host': '10.0.0.3', 'port': 4},
{'host': '10.0.0.1', 'port': 2},
{'host': '10.0.0.4', 'port': 5}],
storagerouters[4].guid: [{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.1', 'port': 2},
{'host': '10.0.0.3', 'port': 4}]}
self.assertDictEqual(config, expected, 'Test 1. Got:\n{0}'.format(json.dumps(config, indent=2)))
mds_services[2].capacity = 10 # on 1, vpool 1
mds_services[2].save()
config = MDSServiceController.get_mds_storagedriver_config_set(vpools[1])
expected = {storagerouters[1].guid: [{'host': '10.0.0.1', 'port': 1},
{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.3', 'port': 4}],
storagerouters[2].guid: [{'host': '10.0.0.2', 'port': 3},
{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.3', 'port': 4}],
storagerouters[3].guid: [{'host': '10.0.0.3', 'port': 4},
{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.2', 'port': 3}],
storagerouters[4].guid: [{'host': '10.0.0.4', 'port': 5},
{'host': '10.0.0.3', 'port': 4},
{'host': '10.0.0.2', 'port': 3}]}
self.assertDictEqual(config, expected, 'Test 2. Got:\n{0}'.format(json.dumps(config, indent=2)))