From 9df4611c44ac103f29860ad44598b585667210e0 Mon Sep 17 00:00:00 2001 From: ZhuoX Li Date: Tue, 30 Sep 2014 14:06:47 +0800 Subject: [PATCH] Publish 'image_created' event to IRIS. Add 'image_created' event after running image job. Change-Id: I0d347b045c67b19d660a97fb908346b721873cc7 --- job_post_image.py | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/job_post_image.py b/job_post_image.py index 59800d6..bf77b9c 100755 --- a/job_post_image.py +++ b/job_post_image.py @@ -4,9 +4,12 @@ import os import sys +import base64 from common.buildtrigger import trigger_info from common.buildservice import BuildService +from common.prerelease import is_prerelease_project +from common.iris_rest_client import IrisRestClient def main(): """The main body""" @@ -20,16 +23,31 @@ def main(): name = content.get('name') status = content.get('status', '') url = content.get('url', '') - - build = BuildService(obs_api, obs_user, obs_passwd) - - info = {"images": - [{"name": name, - "status": status, - "url": url}] - } - - build.update_info(info, project) + # add image_created log for iris + pub_enabled = os.getenv("IRIS_PUB_ENABLED", "0") != "0" + if pub_enabled: + rest = IrisRestClient( + os.getenv("IRIS_SERVER"), + os.getenv("IRIS_USERNAME"), + base64.b64decode(os.getenv('IRIS_PASSWORDX',''))) + rest.publish_event("image_created", { + "project": project, + "status": status, + "name": name, + "url": url, + }) + + # If the project is prerelease project, trigger the post-image-creation + if is_prerelease_project(project): + build = BuildService(obs_api, obs_user, obs_passwd) + + info = {"images": + [{"name": name, + "status": status, + "url": url}] + } + + build.update_info(info, project) if __name__ == "__main__": sys.exit(main()) -- 2.7.4