From 5c1d963c62bae66703c058f3074d2f1bfc9a5aeb Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Fri, 10 Feb 2017 21:29:46 +0000 Subject: [PATCH] Added cinder_ci script This script reads the output of the cinder/tools/generate_driver_list.py then reads the CI_WIKI_NAME entries and then runs the cireporter style report. Change-Id: Icb78c28c25e0638f17abf21af820ef935fd12662 --- .../lastcomment-scoreboard/cinder_ci.py | 89 +++++++++++++++++++ monitoring/lastcomment-scoreboard/comment.py | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 monitoring/lastcomment-scoreboard/cinder_ci.py diff --git a/monitoring/lastcomment-scoreboard/cinder_ci.py b/monitoring/lastcomment-scoreboard/cinder_ci.py new file mode 100755 index 0000000..0677073 --- /dev/null +++ b/monitoring/lastcomment-scoreboard/cinder_ci.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +"""Take input from Cinder's generate_driver_list and run the cireporter.""" + +import argparse +import json +import sys + +import cireporter + + +def read_cinder_input(input_file_name): + """Read the input of the cinder/tools/generate_driver_list.py.""" + if input_file_name: + # reading from a file, not stdin + with open(input_file_name, "r") as input_file: + info = json.loads(input_file.read()) + return info + else: + # read json from stdin + return json.loads(sys.stdin.read()) + + +def process_ci_name(name): + """Convert the _ to spaces.""" + if name == "Cinder_Jenkins": + return 'Jenkins' + elif name: + return name.replace('_', ' ') + + +def add_ci_entry(ci_info, entry): + """Make sure every CI NAME is unique in the ci_info.""" + return list(set(ci_info)|set(entry)) + + +def process_cinder_json(cinder_json): + '''Convert the cinder driver list output to something usable.''' + + ci_info = [] + for driver in cinder_json: + if 'ci_wiki_name' in driver and driver['ci_wiki_name']: + if (type(driver['ci_wiki_name']) is list or + type(driver['ci_wiki_name']) is tuple): + + for entry in driver['ci_wiki_name']: + ci_info = add_ci_entry(ci_info, + [process_ci_name(entry)]) + else: + name = process_ci_name(driver['ci_wiki_name']) + ci_info = add_ci_entry(ci_info, [name]) + + # Make Jenkins first in the list + ci_info = sorted(ci_info, key=lambda s: s.lower()) + if 'Jenkins' in ci_info: + ci_info.remove('Jenkins') + ci_info.insert(0, 'Jenkins') + + return ci_info + + +def main(): + parser = argparse.ArgumentParser(description='list most recent comment by ' + 'reviewer') + parser.add_argument('-c', '--count', + default=100, + type=int, + help='unique gerrit name of the reviewer') + parser.add_argument('-i', '--input', + default=None, + help='json file containing output of cinder generate_' + 'driver_list.py output. Defaults to stdin.') + parser.add_argument('-o', '--output', + default=None, + help='Write the output to a file. Defaults to stdout.') + + args = parser.parse_args() + + cinder_json = read_cinder_input(args.input) + ci_names = process_cinder_json(cinder_json) + + print("Cinder 3rd Party CI Report: %s CI systems found" % len(ci_names)) + for name in ci_names: + print("Checking CI: %s" % name) + cireporter.generate_report(name, 250, 'openstack/cinder') + + +if __name__ == "__main__": + main() diff --git a/monitoring/lastcomment-scoreboard/comment.py b/monitoring/lastcomment-scoreboard/comment.py index 7c65d01..ca89dce 100755 --- a/monitoring/lastcomment-scoreboard/comment.py +++ b/monitoring/lastcomment-scoreboard/comment.py @@ -47,7 +47,7 @@ class Job(object): result = job_split[4] time = None if result == 'SUCCESS' or result == 'FAILURE': - if 'in' in job_str and job_split[5] == 'in': + if ' in ' in job_str and job_split[5] == 'in': time = " ".join(job_split[6:]) return Job(job_name, time, url, result, job_str)