From: Zack Cerza Date: Tue, 26 May 2015 19:58:50 +0000 (-0600) Subject: ResultsReporter: Add job_id kwarg to get_jobs() X-Git-Tag: 1.1.0~930^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=94362983db4826cdd63a9a125d94057044192b21;p=teuthology.git ResultsReporter: Add job_id kwarg to get_jobs() If one is passed, only fetch a single job's information Signed-off-by: Zack Cerza --- diff --git a/teuthology/report.py b/teuthology/report.py index 3e47917e7d..48fed5cab3 100644 --- a/teuthology/report.py +++ b/teuthology/report.py @@ -349,18 +349,21 @@ class ResultsReporter(object): if os.path.exists(self.last_run_file): os.remove(self.last_run_file) - def get_jobs(self, run_name, fields=None): + def get_jobs(self, run_name, job_id=None, fields=None): """ Query the results server for jobs in a run :param run_name: The name of the run + :param job_id: Optionally get a single job instead of all :param fields: Optional. A list of fields to include in the result. Defaults to returning all fields. """ uri = "{base}/runs/{name}/jobs/".format(base=self.base_uri, name=run_name) + if job_id: + uri = os.path.join(uri, job_id) if fields: - if not 'job_id' in fields: + if 'job_id' not in fields: fields.append('job_id') uri += "?fields=" + ','.join(fields) response = self.session.get(uri)