Revision 0bbe448c lib/luxi.py

b/lib/luxi.py
45 45
KEY_SUCCESS = "success"
46 46
KEY_RESULT = "result"
47 47

  
48
REQ_SUBMIT = 'submit'
49
REQ_ABORT = 'abort'
50
REQ_QUERY = 'query'
48
REQ_SUBMIT_JOB = "SubmitJob"
49
REQ_CANCEL_JOB = "CancelJob"
50
REQ_ARCHIVE_JOB = "ArchiveJob"
51
REQ_QUERY_JOBS = "QueryJobs"
51 52

  
52 53
DEF_CTMO = 10
53 54
DEF_RWTO = 60
......
294 295

  
295 296
    return data[KEY_RESULT]
296 297

  
297
  def SubmitJob(self, job):
298
    """Submit a job"""
299
    return self.CallMethod(REQ_SUBMIT, SerializeJob(job))
300

  
301
  def Query(self, data):
302
    """Make a query"""
303
    result = self.CallMethod(REQ_QUERY, data)
304
    if data["object"] == "jobs":
305
      # custom job processing of query values
306
      for row in result:
307
        for idx, field in enumerate(data["fields"]):
308
          if field == "op_list":
309
            row[idx] = [opcodes.OpCode.LoadOpCode(i) for i in row[idx]]
310
    return result
298
  def SubmitJob(self, ops):
299
    ops_state = map(lambda op: op.__getstate__(), ops)
300
    return self.CallMethod(REQ_SUBMIT_JOB, ops_state)
301

  
302
  def CancelJob(self, job_id):
303
    return self.CallMethod(REQ_CANCEL_JOB, job_id)
304

  
305
  def ArchiveJob(self, job_id):
306
    return self.CallMethod(REQ_ARCHIVE_JOB, job_id)
307

  
308
  def QueryJobs(self, job_ids, fields):
309
    return self.CallMethod(REQ_QUERY_JOBS, (job_ids, fields))
311 310

  
312 311
# TODO: class Server(object)

Also available in: Unified diff