-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathupdate-uc.py
executable file
·129 lines (109 loc) · 4.04 KB
/
update-uc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python
#
# Update OpenStack Oslo and Clients libraries versions in rdoinfo from:
# * master branch (default)
# curl -OJ https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt
# * stable/ocata
# curl -OJ https://opendev.org/openstack/requirements/raw/branch/stable/ocata/upper-constraints.txt
# USAGE
# update-uc.py [branch]
# If branch is not specified, master i.e. currently ocata-uc is assumed.
import copy
import ruamel.yaml as yaml
import sys
RDO = 'rdo.yml'
SOURCE_BRANCH = 'source-branch'
UC = 'upper-constraints.txt'
if len(sys.argv) > 1:
UC_RELEASE = sys.argv[1]
else:
UC_RELEASE = 'wallaby-uc'
# filter for Oslo and clients
def filter_oslo_clients(project):
return project.startswith('oslo') or \
project.endswith('client') or \
project == 'osc-lib'
def filter_all(project):
return True
def filter_all_minus_tripleo(project):
TRIPLEO_PROJECTS = [
'diskimage-builder',
'os-apply-config',
'os-collect-config',
'os-net-config',
'os-refresh-config',
'tripleo-common',
'mistral',
'tempest',
'instack-undercloud',
'paunch',
'directord',
]
return project not in TRIPLEO_PROJECTS
# load and filter upper-constraints.txt
# normalize project name for rdoinfo
def load_uc(projects_filter):
uc = {}
with open(UC, 'rb') as ucfile:
for line in ucfile.readlines():
name, version_spec = line.rstrip().split('===')
if name and projects_filter(name):
version = version_spec.split(';')[0]
if version:
if name.startswith('python-'):
name = name[7:]
uc[name.replace('.', '-')] = version
return uc
def update_uc():
# uc = load_uc(filter_oslo_clients)
uc = load_uc(filter_all_minus_tripleo)
uc_projects = uc.keys()
with open(RDO, 'rb') as infile:
info = yaml.load(infile, Loader=yaml.RoundTripLoader)
DEFAULT_RELEASES = info['package-default']['tags']
RELEASES_PUPPET = info['package-configs']['rpmfactory-puppet']['tags']
for pkg in info['packages']:
project = pkg['project']
if project in uc_projects:
new_version = uc[project]
# "Setting %s to version %s" % (project, new_version)
if 'tags' in pkg:
tags = pkg['tags']
if 'version-locked' in tags or 'under-review' in tags:
print("Not updating %s, it is version-locked or under"
" review" % project)
continue
prev_version = tags.get(UC_RELEASE)
if prev_version:
prev_version = prev_version.get(SOURCE_BRANCH)
else:
if project.startswith('puppet'):
tags = copy.copy(RELEASES_PUPPET)
else:
tags = copy.copy(DEFAULT_RELEASES)
prev_version = None
if 'tags' in pkg and UC_RELEASE not in pkg['tags']:
print("Not updating %s, it is not included in release %s"
% (project, UC_RELEASE))
continue
tags[UC_RELEASE] = {SOURCE_BRANCH: new_version}
if prev_version:
if prev_version != new_version:
print("%s updated from %s to %s" %
(project, prev_version, new_version))
else:
print("%s %s already up to date" %
(project, new_version))
else:
print("%s first time pin to %s" %
(project, new_version))
pkg['tags'] = tags
uc_projects.remove(project)
else:
# "%s not found in upper-constraints" % project
pass
# "Projects not in rdoinfo: %s" % string.join(uc_projects, ' ')
with open(RDO, 'w') as outfile:
outfile.write(yaml.dump(info, Dumper=yaml.RoundTripDumper, indent=2))
if __name__ == '__main__':
update_uc()