James E. Blair | c3b8eff | 2013-03-06 19:38:55 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2013 OpenStack Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | # Print commands to leave gerrit comments for every change in one of |
| 17 | # Zuul's pipelines. |
| 18 | |
| 19 | import urllib2 |
| 20 | import json |
James E. Blair | c3b8eff | 2013-03-06 19:38:55 -0800 | [diff] [blame] | 21 | import argparse |
| 22 | |
| 23 | parser = argparse.ArgumentParser() |
| 24 | parser.add_argument('url', help='The URL of the running Zuul instance') |
| 25 | parser.add_argument('pipeline_name', help='The name of the Zuul pipeline') |
| 26 | parser.add_argument('comment', help='The text of the Gerrit comment') |
| 27 | parser.add_argument('--review-host', default='review', |
| 28 | help='The Gerrit hostname') |
| 29 | options = parser.parse_args() |
| 30 | |
| 31 | data = urllib2.urlopen('%s/status.json' % options.url).read() |
| 32 | data = json.loads(data) |
| 33 | |
| 34 | for pipeline in data['pipelines']: |
| 35 | if pipeline['name'] != options.pipeline_name: |
| 36 | continue |
| 37 | for queue in pipeline['change_queues']: |
| 38 | for head in queue['heads']: |
| 39 | for change in head: |
| 40 | print 'ssh %s gerrit review %s --message \\"%s\\"' % ( |
| 41 | options.review_host, |
| 42 | change['id'], |
| 43 | options.comment) |