Commit d2fe2bfb authored by René Nussbaumer's avatar René Nussbaumer
Browse files

TLReplaceDisk: Add ipolicy checks


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 7806125e
...@@ -10100,7 +10100,8 @@ class LUInstanceReplaceDisks(LogicalUnit): ...@@ -10100,7 +10100,8 @@ class LUInstanceReplaceDisks(LogicalUnit):
   
self.replacer = TLReplaceDisks(self, self.op.instance_name, self.op.mode, self.replacer = TLReplaceDisks(self, self.op.instance_name, self.op.mode,
self.op.iallocator, self.op.remote_node, self.op.iallocator, self.op.remote_node,
self.op.disks, False, self.op.early_release) self.op.disks, False, self.op.early_release,
self.op.ignore_ipolicy)
   
self.tasklets = [self.replacer] self.tasklets = [self.replacer]
   
...@@ -10182,7 +10183,7 @@ class TLReplaceDisks(Tasklet): ...@@ -10182,7 +10183,7 @@ class TLReplaceDisks(Tasklet):
   
""" """
def __init__(self, lu, instance_name, mode, iallocator_name, remote_node, def __init__(self, lu, instance_name, mode, iallocator_name, remote_node,
disks, delay_iallocator, early_release): disks, delay_iallocator, early_release, ignore_ipolicy):
"""Initializes this class. """Initializes this class.
   
""" """
...@@ -10196,6 +10197,7 @@ class TLReplaceDisks(Tasklet): ...@@ -10196,6 +10197,7 @@ class TLReplaceDisks(Tasklet):
self.disks = disks self.disks = disks
self.delay_iallocator = delay_iallocator self.delay_iallocator = delay_iallocator
self.early_release = early_release self.early_release = early_release
self.ignore_ipolicy = ignore_ipolicy
   
# Runtime data # Runtime data
self.instance = None self.instance = None
...@@ -10418,6 +10420,16 @@ class TLReplaceDisks(Tasklet): ...@@ -10418,6 +10420,16 @@ class TLReplaceDisks(Tasklet):
if not self.disks: if not self.disks:
self.disks = range(len(self.instance.disks)) self.disks = range(len(self.instance.disks))
   
# TODO: This is ugly, but right now we can't distinguish between internal
# submitted opcode and external one. We should fix that.
if self.remote_node_info:
# We change the node, lets verify it still meets instance policy
new_group_info = self.cfg.GetNodeGroup(self.remote_node_info.group)
ipolicy = _CalculateGroupIPolicy(self.cfg.GetClusterInfo(),
new_group_info)
_CheckTargetNodeIPolicy(self, ipolicy, instance, self.remote_node_info,
ignore=self.ignore_ipolicy)
# TODO: compute disk parameters # TODO: compute disk parameters
primary_node_info = self.cfg.GetNodeInfo(instance.primary_node) primary_node_info = self.cfg.GetNodeInfo(instance.primary_node)
secondary_node_info = self.cfg.GetNodeInfo(secondary_node) secondary_node_info = self.cfg.GetNodeInfo(secondary_node)
......
...@@ -1224,6 +1224,7 @@ class OpInstanceReplaceDisks(OpCode): ...@@ -1224,6 +1224,7 @@ class OpInstanceReplaceDisks(OpCode):
OP_PARAMS = [ OP_PARAMS = [
_PInstanceName, _PInstanceName,
_PEarlyRelease, _PEarlyRelease,
_PIgnoreIpolicy,
("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES), ("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES),
"Replacement mode"), "Replacement mode"),
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt), ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt),
......
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