diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 31f7bc15a6122a59d03e8795237c605849f2871e..8116b9b1de25fac1f58938293533fadb4fbe7f14 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 d2e7cd193b9df4e9fbd9a409edab8820487a7dca..404296879c5f6cc13643d1d855001e8291adc70c 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 05b033172993def822e21dd825fa7f6f2aa011d2..18c07cd8c1cf29f275d0163dc7cf2f5ddace7288 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.