Revision 346c3037

b/lib/cli.py
233 233
  "ParseTimespec",
234 234
  "RunWhileClusterStopped",
235 235
  "SubmitOpCode",
236
  "SubmitOpCodeToDrainedQueue",
236 237
  "SubmitOrSend",
237 238
  "UsesRPC",
238 239
  # Formatting functions
......
2274 2275
  return op_results[0]
2275 2276

  
2276 2277

  
2278
def SubmitOpCodeToDrainedQueue(op):
2279
  """Forcefully insert a job in the queue, even if it is drained.
2280

  
2281
  """
2282
  cl = GetClient()
2283
  job_id = cl.SubmitJobToDrainedQueue([op])
2284
  op_results = PollJob(job_id, cl=cl)
2285
  return op_results[0]
2286

  
2287

  
2277 2288
def SubmitOrSend(op, opts, cl=None, feedback_fn=None):
2278 2289
  """Wrapper around SubmitOpCode or SendJob.
2279 2290

  
b/lib/jqueue.py
2229 2229

  
2230 2230
  @locking.ssynchronized(_LOCK)
2231 2231
  @_RequireOpenQueue
2232
  def SubmitJobToDrainedQueue(self, ops):
2233
    """Forcefully create and store a new job.
2234

  
2235
    Do so, even if the job queue is drained.
2236
    @see: L{_SubmitJobUnlocked}
2237

  
2238
    """
2239
    (job_id, ) = self._NewSerialsUnlocked(1)
2240
    self._EnqueueJobsUnlocked([self._SubmitJobUnlocked(job_id, ops)])
2241
    return job_id
2242

  
2243
  @locking.ssynchronized(_LOCK)
2244
  @_RequireOpenQueue
2232 2245
  @_RequireNonDrainedQueue
2233 2246
  def SubmitManyJobs(self, jobs):
2234 2247
    """Create and store multiple jobs.
b/lib/luxi.py
51 51
KEY_VERSION = "version"
52 52

  
53 53
REQ_SUBMIT_JOB = "SubmitJob"
54
REQ_SUBMIT_JOB_TO_DRAINED_QUEUE = "SubmitJobToDrainedQueue"
54 55
REQ_SUBMIT_MANY_JOBS = "SubmitManyJobs"
55 56
REQ_WAIT_FOR_JOB_CHANGE = "WaitForJobChange"
56 57
REQ_CANCEL_JOB = "CancelJob"
......
91 92
  REQ_SET_DRAIN_FLAG,
92 93
  REQ_SET_WATCHER_PAUSE,
93 94
  REQ_SUBMIT_JOB,
95
  REQ_SUBMIT_JOB_TO_DRAINED_QUEUE,
94 96
  REQ_SUBMIT_MANY_JOBS,
95 97
  REQ_WAIT_FOR_JOB_CHANGE,
96 98
  ])
......
481 483
    ops_state = map(lambda op: op.__getstate__(), ops)
482 484
    return self.CallMethod(REQ_SUBMIT_JOB, (ops_state, ))
483 485

  
486
  def SubmitJobToDrainedQueue(self, ops):
487
    ops_state = map(lambda op: op.__getstate__(), ops)
488
    return self.CallMethod(REQ_SUBMIT_JOB_TO_DRAINED_QUEUE, (ops_state, ))
489

  
484 490
  def SubmitManyJobs(self, jobs):
485 491
    jobs_state = []
486 492
    for ops in jobs:
b/lib/server/masterd.py
295 295
      _LogNewJob(True, job_id, ops)
296 296
      return job_id
297 297

  
298
    elif method == luxi.REQ_SUBMIT_JOB_TO_DRAINED_QUEUE:
299
      logging.info("Forcefully receiving new job")
300
      (job_def, ) = args
301
      ops = [opcodes.OpCode.LoadOpCode(state) for state in job_def]
302
      job_id = queue.SubmitJobToDrainedQueue(ops)
303
      _LogNewJob(True, job_id, ops)
304
      return job_id
305

  
298 306
    elif method == luxi.REQ_SUBMIT_MANY_JOBS:
299 307
      logging.info("Receiving multiple jobs")
300 308
      (job_defs, ) = args
b/src/Ganeti/Luxi.hs
150 150
  , (luxiReqSubmitJob,
151 151
     [ simpleField "job" [t| [MetaOpCode] |] ]
152 152
    )
153
  , (luxiReqSubmitJobToDrainedQueue,
154
     [ simpleField "job" [t| [MetaOpCode] |] ]
155
    )
153 156
  , (luxiReqSubmitManyJobs,
154 157
     [ simpleField "ops" [t| [[MetaOpCode]] |] ]
155 158
    )
......
368 371
              [ops1] <- fromJVal args
369 372
              ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
370 373
              return $ SubmitJob ops2
374
    ReqSubmitJobToDrainedQueue -> do
375
              [ops1] <- fromJVal args
376
              ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
377
              return $ SubmitJobToDrainedQueue ops2
371 378
    ReqSubmitManyJobs -> do
372 379
              [ops1] <- fromJVal args
373 380
              ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
b/test/hs/Test/Ganeti/Luxi.hs
77 77
        kind <- arbitrary
78 78
        Luxi.QueryTags kind <$> genLuxiTagName kind
79 79
      Luxi.ReqSubmitJob -> Luxi.SubmitJob <$> resize maxOpCodes arbitrary
80
      Luxi.ReqSubmitJobToDrainedQueue -> Luxi.SubmitJobToDrainedQueue <$>
81
                                         resize maxOpCodes arbitrary
80 82
      Luxi.ReqSubmitManyJobs -> Luxi.SubmitManyJobs <$>
81 83
                                resize maxOpCodes arbitrary
82 84
      Luxi.ReqWaitForJobChange -> Luxi.WaitForJobChange <$> arbitrary <*>
b/test/py/ganeti.rapi.testutils_unittest.py
39 39

  
40 40
KNOWN_UNUSED_LUXI = compat.UniqueFrozenset([
41 41
  luxi.REQ_SUBMIT_MANY_JOBS,
42
  luxi.REQ_SUBMIT_JOB_TO_DRAINED_QUEUE,
42 43
  luxi.REQ_ARCHIVE_JOB,
43 44
  luxi.REQ_AUTO_ARCHIVE_JOBS,
44 45
  luxi.REQ_CHANGE_JOB_PRIORITY,

Also available in: Unified diff