Commit af5ebcb1 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

noded: Add RPC function to rename job queue files

This will be used to archive jobs.

Reviewed-by: iustinp
parent dc31eae3
......@@ -569,6 +569,16 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler):
"""
return backend.JobQueuePurge()
@staticmethod
@_RequireJobQueueLock
def perspective_jobqueue_rename(params):
"""Rename a job queue file.
"""
(old, new) = params
return backend.JobQueueRename(old, new)
class NodeDaemonHttpServer(http.HTTPServer):
def __init__(self, server_address):
......
......@@ -1690,6 +1690,18 @@ def JobQueuePurge():
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
def JobQueueRename(old, new):
"""Renames a job queue file.
"""
if not (_IsJobQueueFile(old) and _IsJobQueueFile(new)):
return False
os.rename(old, new)
return True
def CloseBlockDevices(disks):
"""Closes the given block devices.
......
......@@ -826,3 +826,16 @@ def call_jobqueue_purge(node):
c.connect(node)
c.run()
return c.getresult().get(node, False)
def call_jobqueue_rename(node_list, old, new):
"""Rename a job queue file.
This is a multi-node call.
"""
c = Client("jobqueue_rename", [old, new])
c.connect_list(node_list)
c.run()
result = c.getresult()
return result
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