X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/0f6be82ab3ac8b17358f616831f6bae098efdc0d..944bf54895c1d4491c6d06ad464aa6e97844c366:/lib/jqueue.py?ds=inline diff --git a/lib/jqueue.py b/lib/jqueue.py index 3364a93..90757a5 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -943,9 +943,8 @@ class JobQueue(object): utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE) return True - @utils.LockedMethod @_RequireOpenQueue - def SubmitJob(self, ops): + def _SubmitJobUnlocked(self, ops): """Create and store a new job. This enters the job into our job queue and also puts it on the new @@ -959,7 +958,7 @@ class JobQueue(object): """ if self._IsQueueMarkedDrain(): - raise errors.JobQueueDrainError() + raise errors.JobQueueDrainError("Job queue is drained, refusing job") # Check job queue size size = len(self._ListJobFiles()) @@ -987,6 +986,37 @@ class JobQueue(object): return job.id + @utils.LockedMethod + @_RequireOpenQueue + def SubmitJob(self, ops): + """Create and store a new job. + + @see: L{_SubmitJobUnlocked} + + """ + return self._SubmitJobUnlocked(ops) + + @utils.LockedMethod + @_RequireOpenQueue + def SubmitManyJobs(self, jobs): + """Create and store multiple jobs. + + @see: L{_SubmitJobUnlocked} + + """ + results = [] + for ops in jobs: + try: + data = self._SubmitJobUnlocked(ops) + status = True + except errors.GenericError, err: + data = str(err) + status = False + results.append((status, data)) + + return results + + @_RequireOpenQueue def UpdateJobUnlocked(self, job): """Update a job's on disk storage.