Commit 4ca52046 authored by Iustin Pop's avatar Iustin Pop
Browse files

Yet another rework in LUSetNodeParms



We will need the new role in CheckPrereq, so move its computation there
and save the new role to self.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 877b849b
......@@ -4068,7 +4068,7 @@ class LUSetNodeParams(LogicalUnit):
self.old_flags = old_flags = (node.master_candidate,
node.drained, node.offline)
assert old_flags in self._F2R, "Un-handled old flags %s" % str(old_flags)
self.old_role = self._F2R[old_flags]
self.old_role = old_role = self._F2R[old_flags]
# Check for ineffective changes
for attr in self._FLAGS:
......@@ -4091,16 +4091,8 @@ class LUSetNodeParams(LogicalUnit):
self.LogInfo("Demoting from master candidate")
self.op.master_candidate = False
def Exec(self, feedback_fn):
"""Modifies a node.
"""
node = self.node
old_role = self.old_role
# Compute new role
assert [getattr(self.op, attr) for attr in self._FLAGS].count(True) <= 1
# compute new flags
if self.op.master_candidate:
new_role = self._ROLE_CANDIDATE
elif self.op.drained:
......@@ -4114,6 +4106,16 @@ class LUSetNodeParams(LogicalUnit):
else: # no new flags, nothing, keep old role
new_role = old_role
self.new_role = new_role
def Exec(self, feedback_fn):
"""Modifies a node.
"""
node = self.node
old_role = self.old_role
new_role = self.new_role
result = []
for attr in ["master_capable", "vm_capable"]:
......
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