当前位置: 首页>>代码示例>>Python>>正文


Python MDSServiceController.get_mds_load方法代码示例

本文整理汇总了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))
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:35,代码来源:test_mdsservice.py

示例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]
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:21,代码来源:test_mdsservice.py


注:本文中的ovs.lib.mdsservice.MDSServiceController.get_mds_load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。