From 5d67298008eea518ef5e1a654f2c2a5f09544306 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 15 Oct 2008 13:13:36 +0000 Subject: [PATCH] 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 --- daemons/ganeti-noded | 9 +++++++++ lib/backend.py | 17 +++++++++++++++++ lib/rpc.py | 19 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 31f7bc15a..8116b9b1d 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -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 diff --git a/lib/backend.py b/lib/backend.py index d2e7cd193..404296879 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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. diff --git a/lib/rpc.py b/lib/rpc.py index 05b033172..18c07cd8c 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -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. -- GitLab