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

Job queue: Allow more than one file rename per RPC call

Reviewed-by: ultrotter
parent d7fd1f28
...@@ -620,9 +620,8 @@ class NodeHttpServer(http.server.HttpServer): ...@@ -620,9 +620,8 @@ class NodeHttpServer(http.server.HttpServer):
"""Rename a job queue file. """Rename a job queue file.
""" """
(old, new) = params # TODO: What if a file fails to rename?
return [backend.JobQueueRename(old, new) for old, new in params]
return backend.JobQueueRename(old, new)
@staticmethod @staticmethod
def perspective_jobqueue_set_drain(params): def perspective_jobqueue_set_drain(params):
......
...@@ -713,13 +713,14 @@ class JobQueue(object): ...@@ -713,13 +713,14 @@ class JobQueue(object):
@param rename: List containing tuples mapping old to new names @param rename: List containing tuples mapping old to new names
""" """
# Rename them locally
for old, new in rename: for old, new in rename:
utils.RenameFile(old, new, mkdir=True) utils.RenameFile(old, new, mkdir=True)
names, addrs = self._GetNodeIp() # ... and on all nodes
result = rpc.RpcRunner.call_jobqueue_rename(names, addrs, old, new) names, addrs = self._GetNodeIp()
self._CheckRpcResult(result, self._nodes, result = rpc.RpcRunner.call_jobqueue_rename(names, addrs, rename)
"Moving %s to %s" % (old, new)) self._CheckRpcResult(result, self._nodes, "Renaming files (%r)" % rename)
def _FormatJobID(self, job_id): def _FormatJobID(self, job_id):
"""Convert a job ID to string format. """Convert a job ID to string format.
......
...@@ -943,13 +943,13 @@ class RpcRunner(object): ...@@ -943,13 +943,13 @@ class RpcRunner(object):
return cls._StaticSingleNodeCall(node, "jobqueue_purge", []) return cls._StaticSingleNodeCall(node, "jobqueue_purge", [])
@classmethod @classmethod
def call_jobqueue_rename(cls, node_list, address_list, old, new): def call_jobqueue_rename(cls, node_list, address_list, rename):
"""Rename a job queue file. """Rename a job queue file.
This is a multi-node call. This is a multi-node call.
""" """
return cls._StaticMultiNodeCall(node_list, "jobqueue_rename", [old, new], return cls._StaticMultiNodeCall(node_list, "jobqueue_rename", rename,
address_list=address_list) address_list=address_list)
@classmethod @classmethod
......
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