blob: 1fa550192e7909fec02654dafa06235d5ed9b722 [file] [log] [blame]
Clint Adamse3e80512016-02-18 14:46:35 -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
22# * network access to the review.openstack.org Gerrit API
23# working directory
24# * network access to https://git.openstack.org/cgit
25
26import json
27import requests
28
29url = 'https://review.openstack.org/projects/'
30
31# This is what a project looks like
32'''
33 "openstack-attic/akanda": {
34 "id": "openstack-attic%2Fakanda",
35 "state": "READ_ONLY"
36 },
37'''
38
39def is_in_openstack_namespace(proj):
40 return proj.startswith('openstack/')
41
42# Rather than returning a 404 for a nonexistent file, cgit delivers a
43# 0-byte response to a GET request. It also does not provide a
44# Content-Length in a HEAD response, so the way we tell if a file exists
45# is to check the length of the entire GET response body.
46def has_devstack_plugin(proj):
47 r = requests.get("https://git.openstack.org/cgit/%s/plain/devstack/plugin.sh" % proj)
48 if len(r.text) > 0:
49 return True
50 else:
51 False
52
53r = requests.get(url)
54projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:])))
55
56found_plugins = filter(has_devstack_plugin, projects)
57
58for project in found_plugins:
59 print project[10:]