Commit 3312709d authored by Leon Handreke's avatar Leon Handreke Committed by Klaus Aehlig
Browse files

Expose bulk parameter for GetJobs in RAPI client

This patch exposes the bulk argument of the jobs resource on
the RAPI python wrapper, making it possible to retrieve status
information about all jobs with a single call.
Signed-off-by: default avatarLeon Handreke <>
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarKlaus Aehlig <>
parent c4101ab5
......@@ -1294,17 +1294,28 @@ class GanetiRapiClient(object): # pylint: disable=R0904
("/%s/instances/%s/console" %
(GANETI_RAPI_VERSION, instance)), None, None)
def GetJobs(self):
def GetJobs(self, bulk=False):
"""Gets all jobs for the cluster.
@type bulk: bool
@param bulk: Whether to return detailed information about jobs.
@rtype: list of int
@return: job ids for the cluster
@return: List of job ids for the cluster or list of dicts with detailed
information about the jobs if bulk parameter was true.
return [int(j["id"])
for j in self._SendRequest(HTTP_GET,
None, None)]
query = []
_AppendIf(query, bulk, ("bulk", 1))
if bulk:
return self._SendRequest(HTTP_GET,
query, None)
return [int(j["id"])
for j in self._SendRequest(HTTP_GET,
None, None)]
def GetJobStatus(self, job_id):
"""Gets the status of a job.
......@@ -837,6 +837,14 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertEqual([123, 124], self.client.GetJobs())
self.rapi.AddResponse('[ { "id": "123", "uri": "\\/2\\/jobs\\/123" },'
' { "id": "124", "uri": "\\/2\\/jobs\\/124" } ]')
self.assertEqual([{"id": "123", "uri": "/2/jobs/123"},
{"id": "124", "uri": "/2/jobs/124"}],
def testGetJobStatus(self):
self.rapi.AddResponse("{\"foo\": \"bar\"}")
self.assertEqual({"foo": "bar"}, self.client.GetJobStatus(1234))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment