blob: 35b1144f478108e62581b786d4baf3a41add59c0 [file] [log] [blame]
Clint Adamsa4136522016-03-10 20:24:34 -05001#! /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
caoyuan349ba752019-04-23 19:40:06 +080022# * network access to the review.opendev.org Gerrit API
Clint Adamsa4136522016-03-10 20:24:34 -050023# working directory
caoyuan349ba752019-04-23 19:40:06 +080024# * network access to https://opendev.org/openstack
Clint Adamsa4136522016-03-10 20:24:34 -050025
26import json
27import re
Masayuki Igawaac8ae642019-05-23 11:39:02 +020028import sys
Masayuki Igawa134d9f72017-02-10 18:05:26 +090029
Masayuki Igawa3e1f3302017-07-03 16:31:40 +090030try:
31 # For Python 3.0 and later
mmkmmk5772956982017-09-15 15:05:43 +090032 from urllib.error import HTTPError
Masayuki Igawa3e1f3302017-07-03 16:31:40 +090033 import urllib.request as urllib
34except ImportError:
35 # Fall back to Python 2's urllib2
36 import urllib2 as urllib
mmkmmk5772956982017-09-15 15:05:43 +090037 from urllib2 import HTTPError
Masayuki Igawa73c33452017-06-19 12:08:58 +090038
Masayuki Igawaac8ae642019-05-23 11:39:02 +020039# List of projects having tempest plugin stale or unmaintained for a long time
40# (6 months or more)
41# TODO(masayukig): Some of these can be removed from BLACKLIST in the future
42# when the patches are merged.
43BLACKLIST = [
44 'barbican-tempest-plugin', # https://review.opendev.org/#/c/634631/
45 'cyborg-tempest-plugin', # https://review.opendev.org/659687
46 'intel-nfv-ci-tests', # https://review.opendev.org/#/c/634640/
47 'networking-ansible', # https://review.opendev.org/#/c/634647/
48 'networking-generic-switch', # https://review.opendev.org/#/c/634846/
49 'networking-l2gw-tempest-plugin', # https://review.opendev.org/#/c/635093/
50 'networking-midonet', # https://review.opendev.org/#/c/635096/
51 'networking-plumgrid', # https://review.opendev.org/#/c/635096/
52 'networking-spp', # https://review.opendev.org/#/c/635098/
53 'neutron-dynamic-routing', # https://review.opendev.org/#/c/637718/
54 'neutron-vpnaas', # https://review.opendev.org/#/c/637719/
55 'nova-lxd', # https://review.opendev.org/#/c/638334/
56 'valet', # https://review.opendev.org/#/c/638339/
57]
Clint Adamsa4136522016-03-10 20:24:34 -050058
caoyuan349ba752019-04-23 19:40:06 +080059url = 'https://review.opendev.org/projects/'
Clint Adamsa4136522016-03-10 20:24:34 -050060
61# This is what a project looks like
62'''
63 "openstack-attic/akanda": {
64 "id": "openstack-attic%2Fakanda",
65 "state": "READ_ONLY"
66 },
67'''
68
69
Clint Adamsa4136522016-03-10 20:24:34 -050070# Rather than returning a 404 for a nonexistent file, cgit delivers a
71# 0-byte response to a GET request. It also does not provide a
72# Content-Length in a HEAD response, so the way we tell if a file exists
73# is to check the length of the entire GET response body.
Clint Adamsa4136522016-03-10 20:24:34 -050074def has_tempest_plugin(proj):
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053075 try:
Masayuki Igawa3e1f3302017-07-03 16:31:40 +090076 r = urllib.urlopen(
caoyuan349ba752019-04-23 19:40:06 +080077 "https://opendev.org/%s/raw/branch/"
78 "master/setup.cfg" % proj)
Masayuki Igawa3e1f3302017-07-03 16:31:40 +090079 except HTTPError as err:
Chandan Kumar1b1e6df2017-06-11 17:07:50 +053080 if err.code == 404:
81 return False
Stephen Finucane7f4a6212018-07-06 13:58:21 +010082 p = re.compile(r'^tempest\.test_plugins', re.M)
Masayuki Igawa73c33452017-06-19 12:08:58 +090083 if p.findall(r.read().decode('utf-8')):
Clint Adamsa4136522016-03-10 20:24:34 -050084 return True
85 else:
86 False
87
Stephen Finucane7f4a6212018-07-06 13:58:21 +010088
Masayuki Igawaac8ae642019-05-23 11:39:02 +020089if len(sys.argv) > 1 and sys.argv[1] == 'blacklist':
90 for black_plugin in BLACKLIST:
91 print(black_plugin)
92 # We just need BLACKLIST when we use this `blacklist` option.
93 # So, this exits here.
94 sys.exit()
95
Masayuki Igawa3e1f3302017-07-03 16:31:40 +090096r = urllib.urlopen(url)
Clint Adamsa4136522016-03-10 20:24:34 -050097# Gerrit prepends 4 garbage octets to the JSON, in order to counter
98# cross-site scripting attacks. Therefore we must discard it so the
99# json library won't choke.
Felipe Monteiroec4c6682018-11-03 18:20:54 -0400100content = r.read().decode('utf-8')[4:]
Masayuki Igawae36fe672019-05-23 13:43:46 +0200101projects = sorted(json.loads(content))
Clint Adamsa4136522016-03-10 20:24:34 -0500102
Masayuki Igawae36fe672019-05-23 13:43:46 +0200103# Retrieve projects having no deployment tool repo (such as deb,
104# puppet, ansible, etc.), infra repos, ui or spec namespace as those
ghanshyam95b68be2018-02-01 02:17:08 +0000105# namespaces do not contains tempest plugins.
106projects_list = [i for i in projects if not (
Masayuki Igawae36fe672019-05-23 13:43:46 +0200107 i.startswith('openstack-dev/') or
108 i.startswith('openstack-infra/') or
109 i.startswith('openstack/ansible-') or
110 i.startswith('openstack/charm-') or
111 i.startswith('openstack/cookbook-openstack-') or
112 i.startswith('openstack/devstack-') or
113 i.startswith('openstack/fuel-') or
ghanshyam95b68be2018-02-01 02:17:08 +0000114 i.startswith('openstack/deb-') or
115 i.startswith('openstack/puppet-') or
Masayuki Igawae36fe672019-05-23 13:43:46 +0200116 i.startswith('openstack/openstack-ansible-') or
117 i.startswith('x/deb-') or
118 i.startswith('x/fuel-') or
119 i.startswith('x/python-') or
120 i.startswith('zuul/') or
ghanshyam95b68be2018-02-01 02:17:08 +0000121 i.endswith('-ui') or
122 i.endswith('-specs'))]
Chandan Kumar3c81b412017-06-13 15:48:20 +0530123
124found_plugins = list(filter(has_tempest_plugin, projects_list))
Clint Adamsa4136522016-03-10 20:24:34 -0500125
Masayuki Igawae36fe672019-05-23 13:43:46 +0200126# We have tempest plugins not only in 'openstack/' namespace but also the
127# other name spaces such as 'airship/', 'x/', etc.
128# So, we print all of them here.
Clint Adamsa4136522016-03-10 20:24:34 -0500129for project in found_plugins:
Masayuki Igawae36fe672019-05-23 13:43:46 +0200130 print(project)