Prepare Ocata election

This change also includes a new tool to automate election preparation

Change-Id: I98049db7c0b665992d408c78e62e99f4a36e3a60
This commit is contained in:
Tristan Cacqueray 2016-06-28 19:17:06 -04:00
parent 9010a495c6
commit be2a3afc4c
66 changed files with 114 additions and 13 deletions

3
.gitignore vendored
View File

@ -11,4 +11,5 @@ ChangeLog
candidates/ptl.rst
candidates/tc.rst
candidates/events.rst
.projects.yaml
.projects*yaml
.projects*.pkl

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -66,8 +66,8 @@ def render_list(list_type, candidates_list):
def build_lists(app):
# TODO: make newton a parameter
election = 'newton'
# TODO: make election a parameter
election = 'ocata'
candidates_list = build_candidates_list(election)
render_list("ptl", candidates_list)
render_list("tc", candidates_list)

View File

@ -2,7 +2,7 @@
OpenStack Election
==================
.. warning:: This is a test for Newton cycle
.. warning:: This is a test for Ocata cycle
.. include:: ./candidates/events.rst
@ -10,7 +10,7 @@ See PTL_details_ and TC_details_.
Below is the official list of candidates for the current round.
.. include:: ./candidates/tc.rst
.. include:: ./candidates/ptl.rst
Election Officials

View File

@ -1,8 +1,8 @@
- {'date': '2016-03-11T00:00', 'name': 'PTL nomination starts'}
- {'date': '2016-03-17T23:59', 'name': 'PTL nomination ends'}
- {'date': '2016-03-18T00:00', 'name': 'PTL elections begins'}
- {'date': '2016-03-24T23:59', 'name': 'PTL elections ends'}
- {'date': '2016-03-25T00:00', 'name': 'TC nomination starts'}
- {'date': '2016-03-31T23:59', 'name': 'TC nomination ends'}
- {'date': '2016-04-01T00:00', 'name': 'TC elections begins'}
- {'date': '2016-04-07T23:59', 'name': 'TC elections ends'}
- {'date': '2016-09-12T00:00', 'name': 'PTL nomination starts'}
- {'date': '2016-09-18T23:45', 'name': 'PTL nomination ends'}
- {'date': '2016-09-19T00:00', 'name': 'PTL elections begins'}
- {'date': '2016-09-25T23:45', 'name': 'PTL elections ends'}
- {'date': '2016-09-26T00:00', 'name': 'TC nomination starts'}
- {'date': '2016-10-01T23:45', 'name': 'TC nomination ends'}
- {'date': '2016-10-03T00:00', 'name': 'TC elections begins'}
- {'date': '2016-10-08T23:45', 'name': 'TC elections ends'}

43
tools/new-election.py Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import os
from utils import get_projects, name2dir
parser = argparse.ArgumentParser()
parser.add_argument('name', help='The release cycle name')
parser.add_argument("--root", help='Election directory', default='.')
options = parser.parse_args()
os.chdir(options.root)
if not os.path.isdir("candidates"):
print "candidates directory not found"
exit(1)
if os.path.exists("candidates/%s" % options.name):
print "candidates/%s: directory already exists" % options.name
exit(1)
projects = get_projects()
project_list = projects.keys()
project_list.sort()
for project in project_list + ["TC"]:
dpath = "candidates/%s/%s" % (options.name, name2dir(project))
os.makedirs(dpath)
open("%s/.placeholder" % dpath, "w").close()
print "[+] Created %s" % dpath
print "Done. Now please manually update events.yaml and doc/source/index.rst substitutions"

57
tools/utils.py Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import time
import urllib
import yaml
import pickle
BASE_URL = 'https://git.openstack.org/cgit'
PROJECTS_URL = ('%s/openstack/governance/plain/reference/projects.yaml' %
(BASE_URL))
def get_projects(tag=None):
url = PROJECTS_URL
cache_file = '.projects.pkl'
if tag:
url += '?%s' % tag
cache_file = '.projects.%s.pkl' % tag
# Refresh the cache if it's not there or if it's older than a week
if (not os.path.isfile(cache_file) or
os.stat(cache_file).st_size < 100 or
os.stat(cache_file).st_mtime + (7*24*3600) < time.time()):
print "[+] Updating %s" % cache_file
data = yaml.safe_load(urllib.urlopen(url).read())
pickle.dump(data, open(cache_file, "w"))
return pickle.load(open(cache_file))
def name2dir(name):
"""Convert project name to directory name: only [a-zA-Z_] in camelcase"""
name = name.replace(' ', '_').replace('-', '_')
return "_".join(map(lambda x: x[0].upper()+x[1:], name.split('_')))
def dir2name(name, projects):
"""Convert directory name to original project name"""
name = name.replace('_', '').lower()
for project_name in projects:
pname = project_name.lower().replace(' ', '').replace('-', '').lower()
if name == pname:
return project_name