Commit 8de8e68d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rapi: Allow auto-promotion on node role change


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 94497dd1
......@@ -1427,7 +1427,7 @@ class GanetiRapiClient(object): # pylint: disable=R0904
("/%s/nodes/%s/role" %
(GANETI_RAPI_VERSION, node)), None, None)
def SetNodeRole(self, node, role, force=False):
def SetNodeRole(self, node, role, force=False, auto_promote=None):
"""Sets the role for a node.
@type node: str
......@@ -1436,6 +1436,9 @@ class GanetiRapiClient(object): # pylint: disable=R0904
@param role: the role to set for the node
@type force: bool
@param force: whether to force the role change
@type auto_promote: bool
@param auto_promote: Whether node(s) should be promoted to master candidate
if necessary
@rtype: string
@return: job id
......@@ -1445,6 +1448,9 @@ class GanetiRapiClient(object): # pylint: disable=R0904
("force", force),
]
if auto_promote is not None:
query.append(("auto-promote", auto_promote))
return self._SendRequest(HTTP_PUT,
("/%s/nodes/%s/role" %
(GANETI_RAPI_VERSION, node)), query, role)
......
......@@ -415,6 +415,8 @@ class R_2_nodes_name_role(baserlib.R_Generic):
node_name = self.items[0]
role = self.request_body
auto_promote = bool(self._checkIntVariable("auto-promote"))
if role == _NR_REGULAR:
candidate = False
offline = False
......@@ -439,6 +441,7 @@ class R_2_nodes_name_role(baserlib.R_Generic):
master_candidate=candidate,
offline=offline,
drained=drained,
auto_promote=auto_promote,
force=bool(self.useForce()))
return baserlib.SubmitJob([op])
......
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