30 |
30 |
import mock
|
31 |
31 |
import operator
|
32 |
32 |
|
|
33 |
from ganeti import backend
|
33 |
34 |
from ganeti import compat
|
34 |
35 |
from ganeti import constants
|
35 |
36 |
from ganeti import errors
|
... | ... | |
76 |
77 |
self.node1 = self.cfg.AddNewNode()
|
77 |
78 |
self.node2 = self.cfg.AddNewNode()
|
78 |
79 |
|
79 |
|
self.rpc.call_os_get.side_effect = \
|
80 |
|
lambda node, _: self.RpcResultsBuilder() \
|
81 |
|
.CreateSuccessfulNodeResult(node, self.os)
|
82 |
|
|
83 |
80 |
hv_info = ("bootid",
|
84 |
81 |
[{
|
85 |
82 |
"type": constants.ST_LVM_VG,
|
... | ... | |
744 |
741 |
class TestCheckOSVariant(CmdlibTestCase):
|
745 |
742 |
def testNoVariantsSupported(self):
|
746 |
743 |
os = self.cfg.CreateOs(supported_variants=[])
|
747 |
|
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant,
|
|
744 |
self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
|
748 |
745 |
os, "os+variant")
|
749 |
746 |
|
750 |
747 |
def testNoVariantGiven(self):
|
751 |
748 |
os = self.cfg.CreateOs(supported_variants=["default"])
|
752 |
|
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant,
|
|
749 |
self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
|
753 |
750 |
os, "os")
|
754 |
751 |
|
755 |
752 |
def testWrongVariantGiven(self):
|
756 |
753 |
os = self.cfg.CreateOs(supported_variants=["default"])
|
757 |
|
self.assertRaises(errors.OpPrereqError, instance_utils._CheckOSVariant,
|
|
754 |
self.assertRaises(backend.RPCFail, backend._CheckOSVariant,
|
758 |
755 |
os, "os+wrong_variant")
|
759 |
756 |
|
760 |
757 |
def testOkWithVariant(self):
|
761 |
758 |
os = self.cfg.CreateOs(supported_variants=["default"])
|
762 |
|
instance_utils._CheckOSVariant(os, "os+default")
|
|
759 |
backend._CheckOSVariant(os, "os+default")
|
763 |
760 |
|
764 |
761 |
def testOkWithoutVariant(self):
|
765 |
762 |
os = self.cfg.CreateOs(supported_variants=[])
|
766 |
|
instance_utils._CheckOSVariant(os, "os")
|
|
763 |
backend._CheckOSVariant(os, "os")
|
767 |
764 |
|
768 |
765 |
|
769 |
766 |
class TestCheckTargetNodeIPolicy(TestLUInstanceCreate):
|
... | ... | |
1864 |
1861 |
|
1865 |
1862 |
def testOsChange(self):
|
1866 |
1863 |
os = self.cfg.CreateOs(supported_variants=[])
|
1867 |
|
self.rpc.call_os_get.return_value = \
|
1868 |
|
self.RpcResultsBuilder() \
|
1869 |
|
.CreateSuccessfulNodeResult(self.master, os)
|
|
1864 |
self.rpc.call_os_validate.return_value = True
|
1870 |
1865 |
op = self.CopyOpCode(self.op,
|
1871 |
1866 |
os_name=os.name)
|
1872 |
1867 |
self.ExecOpCode(op)
|