Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | # Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | # This script is intended to be run as part of a periodic proposal bot |
| 18 | # job in OpenStack infrastructure. |
| 19 | # |
| 20 | # In order to function correctly, the environment in which the |
| 21 | # script runs must have |
| 22 | # * network access to the review.openstack.org Gerrit API |
| 23 | # working directory |
| 24 | # * network access to https://git.openstack.org/cgit |
| 25 | |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 26 | import logging |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 27 | import json |
| 28 | import requests |
| 29 | |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 30 | logging.basicConfig(level=logging.DEBUG) |
| 31 | |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 32 | url = 'https://review.openstack.org/projects/' |
| 33 | |
| 34 | # This is what a project looks like |
| 35 | ''' |
| 36 | "openstack-attic/akanda": { |
| 37 | "id": "openstack-attic%2Fakanda", |
| 38 | "state": "READ_ONLY" |
| 39 | }, |
| 40 | ''' |
| 41 | |
| 42 | def is_in_openstack_namespace(proj): |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 43 | # only interested in openstack namespace (e.g. not retired |
| 44 | # stackforge, etc) |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 45 | return proj.startswith('openstack/') |
| 46 | |
Ian Wienand | db01ca6 | 2016-05-09 13:19:09 +1000 | [diff] [blame] | 47 | # Check if this project has a plugin file |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 48 | def has_devstack_plugin(proj): |
Ian Wienand | 9c69eac | 2016-09-12 14:58:20 +1000 | [diff] [blame] | 49 | # Don't link in the deb packaging repos |
| 50 | if "openstack/deb-" in proj: |
| 51 | return False |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 52 | r = requests.get("https://git.openstack.org/cgit/%s/plain/devstack/plugin.sh" % proj) |
Ian Wienand | db01ca6 | 2016-05-09 13:19:09 +1000 | [diff] [blame] | 53 | return r.status_code == 200 |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 54 | |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 55 | logging.debug("Getting project list from %s" % url) |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 56 | r = requests.get(url) |
| 57 | projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:]))) |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 58 | logging.debug("Found %d projects" % len(projects)) |
Clint Adams | e3e8051 | 2016-02-18 14:46:35 -0500 | [diff] [blame] | 59 | |
| 60 | found_plugins = filter(has_devstack_plugin, projects) |
| 61 | |
| 62 | for project in found_plugins: |
Ian Wienand | c10989b | 2016-03-21 13:03:34 +1100 | [diff] [blame] | 63 | # strip of openstack/ |
Eyal | e736177 | 2016-04-05 16:18:56 +0300 | [diff] [blame] | 64 | print(project[10:]) |