예제 #1
0
 def test_get_vcpu_used(self):
     self.mox.StubOutWithMock(ovz_utils, 'get_cpuunits_capability')
     ovz_utils.get_cpuunits_capability().AndReturn(fakes.CPUUNITSCAPA)
     self.mox.StubOutWithMock(ovz_utils, 'get_vcpu_total')
     ovz_utils.get_vcpu_total().AndReturn(fakes.HOSTSTATS['vcpus'])
     self.mox.ReplayAll()
     used = int(fakes.HOSTSTATS['vcpus'] *
                (float(fakes.CPUUNITSCAPA['subscribed']) /
                 fakes.CPUUNITSCAPA['total']))
     result = ovz_utils.get_vcpu_used()
     self.assertEqual(result, used)
예제 #2
0
 def test_get_vcpu_total_failure(self):
     self.mox.StubOutWithMock(
         ovz_utils.multiprocessing, 'cpu_count')
     ovz_utils.multiprocessing.cpu_count().AndRaise(NotImplementedError)
     self.mox.ReplayAll()
     result = ovz_utils.get_vcpu_total()
     self.assertEqual(result, 0)
예제 #3
0
 def test_get_vcpu_total_success(self):
     self.mox.StubOutWithMock(
         ovz_utils.multiprocessing, 'cpu_count')
     ovz_utils.multiprocessing.cpu_count().AndReturn(
         fakes.HOSTSTATS['vcpus'])
     self.mox.ReplayAll()
     result = ovz_utils.get_vcpu_total()
     self.assertEqual(result, fakes.HOSTSTATS['vcpus'])
예제 #4
0
 def get_cpulimit(self):
     """
     Fetch the total possible cpu processing limit in percentage to be
     divided up across all containers.  This is expressed in percentage
     being added up by logical processor.  If there are 24 logical
     processors then the total cpulimit for the host node will be
     2400.
     """
     self.utility['CPULIMIT'] = ovz_utils.get_vcpu_total() * 100
     LOG.debug(_('Updated cpulimit in utility'))
     LOG.debug(
         _('Current cpulimit in utility: %s') % self.utility['CPULIMIT'])