]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
ResultsReporter: Add job_id kwarg to get_jobs() 504/head
authorZack Cerza <zack@redhat.com>
Tue, 26 May 2015 19:58:50 +0000 (13:58 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 29 May 2015 20:23:41 +0000 (14:23 -0600)
If one is passed, only fetch a single job's information

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/report.py

index 3e47917e7d6a83bfc45422519344102c9a8956fb..48fed5cab3f34e043cfb1295a564e8756366f86c 100644 (file)
@@ -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)