Revision be6cdf67

b/lib/jqueue.py
224 224
               "received_timestamp", "start_timestamp", "end_timestamp",
225 225
               "__weakref__", "processor_lock", "writable", "archived"]
226 226

  
227
  def AddReasons(self):
227
  def AddReasons(self, pickup=False):
228 228
    """Extend the reason trail
229 229

  
230 230
    Add the reason for all the opcodes of this job to be executed.
......
233 233
    count = 0
234 234
    for queued_op in self.ops:
235 235
      op = queued_op.input
236
      reason_src = opcodes_base.NameToReasonSrc(op.__class__.__name__)
236
      if pickup:
237
        reason_src_prefix = constants.OPCODE_REASON_SRC_PICKUP
238
      else:
239
        reason_src_prefix = constants.OPCODE_REASON_SRC_OPCODE
240
      reason_src = opcodes_base.NameToReasonSrc(op.__class__.__name__,
241
                                                reason_src_prefix)
237 242
      reason_text = "job=%d;index=%d" % (self.id, count)
238 243
      reason = getattr(op, "reason", [])
239 244
      reason.append((reason_src, reason_text, utils.EpochNano()))
......
1725 1730
      logging.warning("Job %s could not be read", job_id)
1726 1731
      return
1727 1732

  
1733
    job.AddReasons(pickup=True)
1734

  
1728 1735
    status = job.CalcStatus()
1729 1736
    if status == constants.JOB_STATUS_QUEUED:
1730 1737
      self._EnqueueJobsUnlocked([job])
b/lib/opcodes_base.py
94 94
  return "_".join(n.upper() for n in _NameComponents(name))
95 95

  
96 96

  
97
def NameToReasonSrc(name):
97
def NameToReasonSrc(name, prefix):
98 98
  """Convert an opcode class name to a source string for the reason trail
99 99

  
100 100
  @type name: string
101 101
  @param name: the class name, as OpXxxYyy
102
  @type prefix: string
103
  @param prefix: the prefix that will be prepended to the opcode name
102 104
  @rtype: string
103 105
  @return: the name in the OP_XXXX_YYYY format
104 106

  
105 107
  """
106 108
  if not name.startswith("Op"):
107 109
    return None
108
  return "%s:%s" % (constants.OPCODE_REASON_SRC_OPCODE,
110
  return "%s:%s" % (prefix,
109 111
                    "_".join(n.lower() for n in _NameComponents(name)))
110 112

  
111 113

  

Also available in: Unified diff