本文整理匯總了Python中ovs.lib.mdsservice.MDSServiceController.get_mds_load方法的典型用法代碼示例。如果您正苦於以下問題:Python MDSServiceController.get_mds_load方法的具體用法?Python MDSServiceController.get_mds_load怎麽用?Python MDSServiceController.get_mds_load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ovs.lib.mdsservice.MDSServiceController
的用法示例。
在下文中一共展示了MDSServiceController.get_mds_load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_load_calculation
# 需要導入模塊: from ovs.lib.mdsservice import MDSServiceController [as 別名]
# 或者: from ovs.lib.mdsservice.MDSServiceController import get_mds_load [as 別名]
def test_load_calculation(self):
"""
Validates whether the load calculation works
"""
vpools, storagerouters, storagedrivers, services, mds_services, _ = self._build_service_structure(
{'vpools': [1],
'storagerouters': [1],
'storagedrivers': [(1, 1, 1)], # (<id>, <vpool_id>, <sr_id>)
'mds_services': [(1, 1)]} # (<id>, <sd_id>)
)
mds_service = mds_services[1]
self._create_vdisks_for_mds_service(2, 1, mds_service=mds_service)
load, load_plus = MDSServiceController.get_mds_load(mds_service)
self.assertEqual(load, 20, 'There should be a 20% load. {0}'.format(load))
self.assertEqual(load_plus, 30, 'There should be a 30% plus load. {0}'.format(load_plus))
self._create_vdisks_for_mds_service(3, 3, mds_service=mds_service)
load, load_plus = MDSServiceController.get_mds_load(mds_service)
self.assertEqual(load, 50, 'There should be a 50% load. {0}'.format(load))
self.assertEqual(load_plus, 60, 'There should be a 60% plus load. {0}'.format(load_plus))
self._create_vdisks_for_mds_service(5, 6, mds_service=mds_service)
load, load_plus = MDSServiceController.get_mds_load(mds_service)
self.assertEqual(load, 100, 'There should be a 100% load. {0}'.format(load))
self.assertEqual(load_plus, 110, 'There should be a 110% plus load. {0}'.format(load_plus))
mds_service.capacity = -1
mds_service.save()
load, load_plus = MDSServiceController.get_mds_load(mds_service)
self.assertEqual(load, 50, 'There should be a 50% load. {0}'.format(load))
self.assertEqual(load_plus, 50, 'There should be a 50% plus load. {0}'.format(load_plus))
mds_service.capacity = 0
mds_service.save()
load, load_plus = MDSServiceController.get_mds_load(mds_service)
self.assertEqual(load, float('inf'), 'There should be infinite load. {0}'.format(load))
self.assertEqual(load_plus, float('inf'), 'There should be infinite plus load. {0}'.format(load_plus))
示例2: _generate_mds_service_load_repr
# 需要導入模塊: from ovs.lib.mdsservice import MDSServiceController [as 別名]
# 或者: from ovs.lib.mdsservice.MDSServiceController import get_mds_load [as 別名]
def _generate_mds_service_load_repr(_mds_service):
"""
Generates a load representing thing for a given mds_service
"""
masters, slaves = 0, 0
for _junction in _mds_service.vdisks:
if _junction.is_master:
masters += 1
else:
slaves += 1
capacity = _mds_service.capacity
if capacity == -1:
capacity = 'infinite'
_load, _ = MDSServiceController.get_mds_load(_mds_service)
if _load == float('inf'):
_load = 'infinite'
else:
_load = round(_load, 2)
return [_mds_service.service.storagerouter.ip, _mds_service.service.ports[0], masters, slaves, capacity, _load]