Commit ff02b60f authored by René Nussbaumer's avatar René Nussbaumer

_CheckTargetNodeIPolicy: instance.primary_node is not objects.Node

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent c879832c
......@@ -1146,7 +1146,8 @@ def _CheckTargetNodeIPolicy(lu, ipolicy, instance, node, ignore=False,
@see: L{_ComputeIPolicySpecViolation}
"""
res = _compute_fn(ipolicy, instance, instance.primary_node.group, node.group)
primary_node = lu.cfg.GetNodeInfo(instance.primary_node)
res = _compute_fn(ipolicy, instance, primary_node.group, node.group)
if res:
msg = ("Instance does not meet target node group's (%s) instance"
......
......@@ -382,9 +382,10 @@ class TestClusterVerifyFiles(unittest.TestCase):
class _FakeLU:
def __init__(self):
def __init__(self, cfg=NotImplemented):
self.warning_log = []
self.info_log = []
self.cfg = cfg
def LogWarning(self, text, *args):
self.warning_log.append((text, args))
......@@ -678,11 +679,21 @@ class TestComputeIPolicyNodeViolation(unittest.TestCase):
self.assertEqual(ret, [])
class _FakeConfigForTargetNodeIPolicy:
def __init__(self, node_info=NotImplemented):
self._node_info = node_info
def GetNodeInfo(self, _):
return self._node_info
class TestCheckTargetNodeIPolicy(unittest.TestCase):
def setUp(self):
self.instance = objects.Instance(primary_node=objects.Node(group="foo"))
self.instance = objects.Instance(primary_node="blubb")
self.target_node = objects.Node(group="bar")
self.lu = _FakeLU()
node_info = objects.Node(group="foo")
fake_cfg = _FakeConfigForTargetNodeIPolicy(node_info=node_info)
self.lu = _FakeLU(cfg=fake_cfg)
def testNoViolation(self):
compute_recoder = _CallRecorder(return_value=[])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment