Ejemplo n.º 1
0
 def test(self):
   beparams = {
     constants.BE_MAXMEM: 2048,
     constants.BE_VCPUS: 2,
     constants.BE_SPINDLE_USE: 4,
     }
   cfg = _FakeConfigForComputeIPolicyInstanceViolation(beparams, False)
   instance = objects.Instance(beparams=beparams, disks=["disk_uuid"],
                               nics=[], primary_node="pnode_uuid",
                               disk_template=constants.DT_PLAIN)
   stub = _StubComputeIPolicySpecViolation(2048, 2, 1, 0, [512], 4,
                                           constants.DT_PLAIN)
   ret = common.ComputeIPolicyInstanceViolation(NotImplemented, instance,
                                                cfg, _compute_fn=stub)
   self.assertEqual(ret, [])
   instance2 = objects.Instance(beparams={}, disks=["disk_uuid"],
                                nics=[], primary_node="pnode_uuid",
                                disk_template=constants.DT_PLAIN)
   ret = common.ComputeIPolicyInstanceViolation(NotImplemented, instance2,
                                                cfg, _compute_fn=stub)
   self.assertEqual(ret, [])
   cfg_es = _FakeConfigForComputeIPolicyInstanceViolation(beparams, True)
   stub_es = _StubComputeIPolicySpecViolation(2048, 2, 1, 0, [512], 13,
                                              constants.DT_PLAIN)
   ret = common.ComputeIPolicyInstanceViolation(NotImplemented, instance,
                                                cfg_es, _compute_fn=stub_es)
   self.assertEqual(ret, [])
   ret = common.ComputeIPolicyInstanceViolation(NotImplemented, instance2,
                                                cfg_es, _compute_fn=stub_es)
   self.assertEqual(ret, [])
Ejemplo n.º 2
0
 def testExclusiveStorageNoBeparams(self):
   instance = objects.Instance(beparams={}, disks=["disk_uuid"],
                                nics=[], primary_node="pnode_uuid",
                                disk_template=constants.DT_PLAIN)
   ret = common.ComputeIPolicyInstanceViolation(
       NotImplemented, instance, self.cfg_exclusive, _compute_fn=self.stub)
   self.assertEqual(ret, [])
   self.stub.assert_called_with(NotImplemented, 2048, 2, 1, 0, [512], 13,
                                [constants.DT_PLAIN])