Revision 2467e0d3 lib/opcodes.py

b/lib/opcodes.py
73 73
      setattr(self, name, state[name])
74 74

  
75 75

  
76
class Job(BaseJO):
77
  """Job definition structure
78

  
79
  The Job definitions has two sets of parameters:
80
    - the parameters of the job itself (all filled by server):
81
      - job_id,
82
      - status: pending, running, successfull, failed, aborted
83
    - opcode parameters:
84
      - op_list, list of opcodes, clients creates this
85
      - op_status, status for each opcode, server fills in
86
      - op_result, result for each opcode, server fills in
87

  
88
  """
89
  STATUS_PENDING = 1
90
  STATUS_RUNNING = 2
91
  STATUS_SUCCESS = 3
92
  STATUS_FAIL = 4
93
  STATUS_ABORT = 5
94

  
95
  __slots__ = [
96
    "job_id",
97
    "status",
98
    "op_list",
99
    "op_status",
100
    "op_result",
101
    ]
102

  
103
  def __getstate__(self):
104
    """Specialized getstate for jobs
105

  
106
    """
107
    data = BaseJO.__getstate__(self)
108
    if "op_list" in data:
109
      data["op_list"] = [op.__getstate__() for op in data["op_list"]]
110
    return data
111

  
112
  def __setstate__(self, state):
113
    """Specialized setstate for jobs
114

  
115
    """
116
    BaseJO.__setstate__(self, state)
117
    if "op_list" in state:
118
      self.op_list = [OpCode.LoadOpCode(op) for op in state["op_list"]]
119

  
120

  
121 76
class OpCode(BaseJO):
122 77
  """Abstract OpCode"""
123 78
  OP_ID = "OP_ABSTRACT"

Also available in: Unified diff