]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add create_run() and push_job_info() with docs.
authorZack Cerza <zack@cerza.org>
Wed, 2 Oct 2013 22:57:07 +0000 (17:57 -0500)
committerZack Cerza <zack@cerza.org>
Wed, 2 Oct 2013 23:34:04 +0000 (18:34 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/report.py

index 1691af4745dfe609785443ddf97c2f81109bcf0c..8d1420e754a26ad6e8435f737234568ac308efff 100755 (executable)
@@ -224,6 +224,41 @@ class ResultsReporter(object):
         return self.__http
 
 
+def create_run(run_name, base_uri=None):
+    """
+    Create a run on the results server. If it already exists, just smile and be
+    happy.
+
+    :param run_name: The name of the run.
+    :param base_uri: The endpoint of the results server. If you leave it out
+                     ResultsReporter will ask teuthology.config.
+    :return:         True if the run was successfully created.
+    """
+    # We are using archive_base='' here because we KNOW the serializer isn't
+    # needed for this codepath.
+    reporter = ResultsReporter(archive_base='', base_uri=base_uri)
+    status, msg, content = reporter.create_run(run_name)
+    return (status == 200 or msg.endswith('already exists'))
+
+
+def push_job_info(run_name, job_id, job_info, base_uri=None):
+    """
+    Push a job's info (example: ctx.config) to the results server.
+
+    :param run_name: The name of the run.
+    :param job_id:   The job's id
+    :param job_info: A dict containing the job's information.
+    :param base_uri: The endpoint of the results server. If you leave it out
+                     ResultsReporter will ask teuthology.config.
+    :return:         True if the run was successfully created.
+    """
+    # We are using archive_base='' here because we KNOW the serializer isn't
+    # needed for this codepath.
+    job_json = json.dumps(job_info)
+    reporter = ResultsReporter(archive_base='')
+    reporter.report_job(run_name, job_id, job_json)
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Submit test results to a web service")