Commit 5d672980 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a rpc call for changing the drain flag

A new multi-node call is added that sets/resets the drain flag.

Reviewed-by: imsnah
parent 686d7433
......@@ -605,6 +605,15 @@ class NodeHttpServer(http.HttpServer):
return backend.JobQueueRename(old, new)
@staticmethod
def perspective_jobqueue_set_drain(params):
"""Set/unset the queue drain flag.
"""
drain_flag = params[0]
return backend.JobQueueSetDrainFlag(drain_flag)
# hypervisor ---------------
@staticmethod
......
......@@ -1773,6 +1773,23 @@ def JobQueueRename(old, new):
return True
def JobQueueSetDrainFlag(drain_flag):
"""Set the drain flag for the queue.
This will set or unset the queue drain flag.
@type drain_flag: bool
@param drain_flag: if True, will set the drain flag, otherwise reset it.
"""
if drain_flag:
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", close=True)
else:
utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE)
return True
def CloseBlockDevices(disks):
"""Closes the given block devices.
......
......@@ -900,6 +900,25 @@ class RpcRunner(object):
return result
@staticmethod
def call_jobqueue_set_drain(node_list, drain_flag):
"""Set the drain flag on the queue.
This is a multi-node call.
@type node_list: list
@param node_list: the list of nodes to query
@type drain_flag: bool
@param drain_flag: if True, will set the drain flag, otherwise reset it.
"""
c = Client("jobqueue_set_drain", [drain_flag])
c.connect_list(node_list)
c.run()
result = c.getresult()
return result
def call_hypervisor_validate_params(self, node_list, hvname, hvparams):
"""Validate the hypervisor params.
......
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