Revision e987f166

b/doc/rapi.rst
1015 1015

  
1016 1016
Returns: a dictionary with jobs id and uri.
1017 1017

  
1018
If the optional bool *bulk* argument is provided and set to a true value
1019
(i.e. ``?bulk=1``), the output contains detailed information about jobs
1020
as a list.
1021

  
1018 1022
``/2/jobs/[job_id]``
1019 1023
++++++++++++++++++++
1020 1024

  
b/lib/rapi/rlib2.py
47 47
from ganeti import cli
48 48
from ganeti import rapi
49 49
from ganeti import ht
50
from ganeti import compat
50 51
from ganeti.rapi import baserlib
51 52

  
52 53

  
......
79 80
            "ctime", "mtime", "serial_no",
80 81
            ]  # "tags" is missing to be able to use _COMMON_FIELDS here.
81 82

  
83
J_FIELDS = [
84
  "id", "ops", "status", "summary",
85
  "opstatus", "opresult", "oplog",
86
  "received_ts", "start_ts", "end_ts",
87
  ]
88

  
82 89
_NR_DRAINED = "drained"
83 90
_NR_MASTER_CANDIATE = "master-candidate"
84 91
_NR_MASTER = "master"
......
223 230
  """/2/jobs resource.
224 231

  
225 232
  """
226
  @staticmethod
227
  def GET():
233
  def GET(self):
228 234
    """Returns a dictionary of jobs.
229 235

  
230 236
    @return: a dictionary with jobs id and uri.
231 237

  
232 238
    """
233
    fields = ["id"]
234
    cl = baserlib.GetClient()
235
    # Convert the list of lists to the list of ids
236
    result = [job_id for [job_id] in cl.QueryJobs(None, fields)]
237
    return baserlib.BuildUriList(result, "/2/jobs/%s",
238
                                 uri_fields=("id", "uri"))
239
    client = baserlib.GetClient()
240

  
241
    if self.useBulk():
242
      bulkdata = client.QueryJobs(None, J_FIELDS)
243
      return baserlib.MapBulkFields(bulkdata, J_FIELDS)
244
    else:
245
      jobdata = map(compat.fst, client.QueryJobs(None, ["id"]))
246
      return baserlib.BuildUriList(jobdata, "/2/jobs/%s",
247
                                   uri_fields=("id", "uri"))
239 248

  
240 249

  
241 250
class R_2_jobs_id(baserlib.R_Generic):
......
255 264
            - opresult: OpCodes results as a list of lists
256 265

  
257 266
    """
258
    fields = ["id", "ops", "status", "summary",
259
              "opstatus", "opresult", "oplog",
260
              "received_ts", "start_ts", "end_ts",
261
              ]
262 267
    job_id = self.items[0]
263
    result = baserlib.GetClient().QueryJobs([job_id, ], fields)[0]
268
    result = baserlib.GetClient().QueryJobs([job_id, ], J_FIELDS)[0]
264 269
    if result is None:
265 270
      raise http.HttpNotFound()
266
    return baserlib.MapFields(fields, result)
271
    return baserlib.MapFields(J_FIELDS, result)
267 272

  
268 273
  def DELETE(self):
269 274
    """Cancel not-yet-started job.

Also available in: Unified diff