Merge lp:~1chb1n/ubuntu-openstack-ci/sharing-dellstack-maas-lab into lp:ubuntu-openstack-ci
- sharing-dellstack-maas-lab
- Merge into trunk
Proposed by
Ryan Beisner
Status: | Merged |
---|---|
Merged at revision: | 148 |
Proposed branch: | lp:~1chb1n/ubuntu-openstack-ci/sharing-dellstack-maas-lab |
Merge into: | lp:ubuntu-openstack-ci |
Diff against target: |
690 lines (+310/-37) 28 files modified
admin/910-bounce-all.sh (+1/-1) admin/912-bounce-slaves.sh (+1/-1) admin/913-shutdown-all.sh (+1/-1) admin/915-shutdown-slaves.sh (+1/-1) admin/920-juju-bootstrap-all.sh (+1/-1) admin/924-check-juju-enviros.sh (+1/-1) admin/925-juju-destroy-all.sh (+1/-1) admin/926-juju-delete-enviro-files-all.sh (+1/-1) admin/930-images-delete.sh (+1/-1) admin/940-jenkins-master-info.sh (+1/-1) admin/945-juju-gui-info.sh (+1/-1) admin/946-units-meminfo.sh (+1/-1) admin/991-restart-jenkins-slaves-services.sh (+1/-1) common/osci_utils.py (+3/-2) deployment/bin/120-install-plugins.sh (+1/-1) deployment/bin/220-master-floating-ip.sh (+3/-3) deployment/bin/225-juju-gui-float.sh (+2/-2) env-common (+1/-1) job-parts/README (+1/-0) job-parts/juju_deploy_ok.sh (+1/-1) job-parts/osci_job_common.sh (+7/-7) job-parts/osci_openstack_common.sh (+5/-5) tools/README (+25/-0) tools/__init__.py (+1/-0) tools/bundle_constrainer.py (+196/-0) tools/dummy-bundle.yaml (+48/-0) tools/find_replace.py (+2/-1) tox.ini (+1/-1) |
To merge this branch: | bzr merge lp:~1chb1n/ubuntu-openstack-ci/sharing-dellstack-maas-lab |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ryan Beisner | Pending | ||
Review via email: mp+264457@code.launchpad.net |
Commit message
Description of the change
Adjustments related to sharing the dellstack maas lab. Jobs need to inject maas tags into the bundles used for bare metal testing.
* Add a bundle_
* Relocate other existing tools into ./tools/
* Update job scripts
* Update juju status usage re: eventual default output format change
* Disable flake8 ignores
To post a comment you must log in.
- 146. By Ryan Beisner
-
Relocate existing tools to the new tools dir, update affected scripts.
- 147. By Ryan Beisner
-
update juju status usage re: eventual default output format change; disable flake8 ignores
- 148. By Ryan Beisner
-
update readme
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'admin/910-bounce-all.sh' |
2 | --- admin/910-bounce-all.sh 2014-10-02 15:18:00 +0000 |
3 | +++ admin/910-bounce-all.sh 2015-07-10 21:48:32 +0000 |
4 | @@ -13,7 +13,7 @@ |
5 | |
6 | if [ "$param" == "YES" ]; then |
7 | # Get jenkins units |
8 | - units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
9 | + units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
10 | | cut -d ":" -f 1 | sed 's/^ *//') |
11 | for unit in $units; do |
12 | echo "rebooting ${unit}!" |
13 | |
14 | === modified file 'admin/912-bounce-slaves.sh' |
15 | --- admin/912-bounce-slaves.sh 2014-10-02 15:18:00 +0000 |
16 | +++ admin/912-bounce-slaves.sh 2015-07-10 21:48:32 +0000 |
17 | @@ -13,7 +13,7 @@ |
18 | |
19 | if [ "$param" == "YES" ]; then |
20 | # Get jenkins units |
21 | - units=$(juju status | egrep "osci-slave/" \ |
22 | + units=$(juju status --format=yaml | egrep "osci-slave/" \ |
23 | | cut -d ":" -f 1 | sed 's/^ *//') |
24 | for unit in $units; do |
25 | echo "rebooting ${unit}!" |
26 | |
27 | === modified file 'admin/913-shutdown-all.sh' |
28 | --- admin/913-shutdown-all.sh 2014-11-22 16:16:10 +0000 |
29 | +++ admin/913-shutdown-all.sh 2015-07-10 21:48:32 +0000 |
30 | @@ -13,7 +13,7 @@ |
31 | |
32 | if [ "$param" == "YES" ]; then |
33 | # Get jenkins units |
34 | - units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
35 | + units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
36 | | cut -d ":" -f 1 | sed 's/^ *//') |
37 | for unit in $units; do |
38 | echo "shutting down ${unit}!" |
39 | |
40 | === modified file 'admin/915-shutdown-slaves.sh' |
41 | --- admin/915-shutdown-slaves.sh 2014-11-22 16:16:10 +0000 |
42 | +++ admin/915-shutdown-slaves.sh 2015-07-10 21:48:32 +0000 |
43 | @@ -13,7 +13,7 @@ |
44 | |
45 | if [ "$param" == "YES" ]; then |
46 | # Get jenkins units |
47 | - units=$(juju status | egrep "osci-slave/" \ |
48 | + units=$(juju status --format=yaml | egrep "osci-slave/" \ |
49 | | cut -d ":" -f 1 | sed 's/^ *//') |
50 | for unit in $units; do |
51 | echo "shutting down ${unit}!" |
52 | |
53 | === modified file 'admin/920-juju-bootstrap-all.sh' |
54 | --- admin/920-juju-bootstrap-all.sh 2014-10-02 15:18:00 +0000 |
55 | +++ admin/920-juju-bootstrap-all.sh 2015-07-10 21:48:32 +0000 |
56 | @@ -5,7 +5,7 @@ |
57 | # useful for verifying juju environments and networks |
58 | |
59 | # Get jenkins units |
60 | -units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
61 | +units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
62 | | cut -d ":" -f 1 | sed 's/^ *//') |
63 | |
64 | for unit in $units; do |
65 | |
66 | === modified file 'admin/924-check-juju-enviros.sh' |
67 | --- admin/924-check-juju-enviros.sh 2014-10-02 15:18:00 +0000 |
68 | +++ admin/924-check-juju-enviros.sh 2015-07-10 21:48:32 +0000 |
69 | @@ -4,7 +4,7 @@ |
70 | # look at juju enviro yamls |
71 | |
72 | # Get jenkins units |
73 | -units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
74 | +units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
75 | | cut -d ":" -f 1 | sed 's/^ *//') |
76 | |
77 | for unit in $units; do |
78 | |
79 | === modified file 'admin/925-juju-destroy-all.sh' |
80 | --- admin/925-juju-destroy-all.sh 2014-10-02 15:18:00 +0000 |
81 | +++ admin/925-juju-destroy-all.sh 2015-07-10 21:48:32 +0000 |
82 | @@ -15,7 +15,7 @@ |
83 | |
84 | if [ "$param" == "YES" ]; then |
85 | # Get jenkins units |
86 | - units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
87 | + units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
88 | | cut -d ":" -f 1 | sed 's/^ *//') |
89 | |
90 | for unit in $units; do |
91 | |
92 | === modified file 'admin/926-juju-delete-enviro-files-all.sh' |
93 | --- admin/926-juju-delete-enviro-files-all.sh 2014-10-02 15:18:00 +0000 |
94 | +++ admin/926-juju-delete-enviro-files-all.sh 2015-07-10 21:48:32 +0000 |
95 | @@ -17,7 +17,7 @@ |
96 | |
97 | if [ "$param" == "YES" ]; then |
98 | # Get jenkins units |
99 | - units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
100 | + units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
101 | | cut -d ":" -f 1 | sed 's/^ *//') |
102 | |
103 | if [ -z "$units" ]; then |
104 | |
105 | === modified file 'admin/930-images-delete.sh' |
106 | --- admin/930-images-delete.sh 2014-12-08 22:02:26 +0000 |
107 | +++ admin/930-images-delete.sh 2015-07-10 21:48:32 +0000 |
108 | @@ -13,7 +13,7 @@ |
109 | fi |
110 | |
111 | # Get jenkins units |
112 | -units=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
113 | +units=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
114 | | cut -d ":" -f 1 | sed 's/^ *//') |
115 | for unit in $units; do |
116 | echo "----- ${unit} -----" |
117 | |
118 | === modified file 'admin/940-jenkins-master-info.sh' |
119 | --- admin/940-jenkins-master-info.sh 2014-10-02 15:18:00 +0000 |
120 | +++ admin/940-jenkins-master-info.sh 2015-07-10 21:48:32 +0000 |
121 | @@ -8,7 +8,7 @@ |
122 | . ~/novarc |
123 | |
124 | # Get UUID of jenkins instance |
125 | -master_uuid=$(juju status ${MASTER} | grep instance-id | awk '{ print $2 }' |\ |
126 | +master_uuid=$(juju status --format=yaml ${MASTER} | grep instance-id | awk '{ print $2 }' |\ |
127 | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
128 | if [ -z "$master_uuid" ]; then |
129 | echo "Couldn't get UUID for jenkins master instance." |
130 | |
131 | === modified file 'admin/945-juju-gui-info.sh' |
132 | --- admin/945-juju-gui-info.sh 2014-10-03 14:43:06 +0000 |
133 | +++ admin/945-juju-gui-info.sh 2015-07-10 21:48:32 +0000 |
134 | @@ -8,7 +8,7 @@ |
135 | . ~/novarc |
136 | |
137 | # Get UUID of jenkins instance |
138 | -unit_uuid=$(juju status juju-gui | grep instance-id | awk '{ print $2 }' |\ |
139 | +unit_uuid=$(juju status --format=yaml juju-gui | grep instance-id | awk '{ print $2 }' |\ |
140 | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
141 | if [ -z "$unit_uuid" ]; then |
142 | echo "Couldn't get UUID for jenkins master instance." |
143 | |
144 | === modified file 'admin/946-units-meminfo.sh' |
145 | --- admin/946-units-meminfo.sh 2014-11-22 16:16:10 +0000 |
146 | +++ admin/946-units-meminfo.sh 2015-07-10 21:48:32 +0000 |
147 | @@ -3,7 +3,7 @@ |
148 | |
149 | # Show memory usage of each juju unit |
150 | |
151 | -units=$(juju status | grep '":' | tr -d : | tr -d \") |
152 | +units=$(juju status --format=yaml | grep '":' | tr -d : | tr -d \") |
153 | |
154 | for unit in $units; do |
155 | echo "---------- unit ${unit} mem: ----------" |
156 | |
157 | === modified file 'admin/991-restart-jenkins-slaves-services.sh' |
158 | --- admin/991-restart-jenkins-slaves-services.sh 2014-10-03 14:43:06 +0000 |
159 | +++ admin/991-restart-jenkins-slaves-services.sh 2015-07-10 21:48:32 +0000 |
160 | @@ -3,7 +3,7 @@ |
161 | |
162 | # Restart the jenkins service on all slave units |
163 | |
164 | -units=$(juju status | egrep "osci-slave/" \ |
165 | +units=$(juju status --format=yaml | egrep "osci-slave/" \ |
166 | | cut -d ":" -f 1 | sed 's/^ *//') |
167 | |
168 | for unit in $units; do |
169 | |
170 | === modified file 'common/osci_utils.py' |
171 | --- common/osci_utils.py 2015-03-12 04:38:42 +0000 |
172 | +++ common/osci_utils.py 2015-07-10 21:48:32 +0000 |
173 | @@ -97,9 +97,10 @@ |
174 | ''' |
175 | try: |
176 | if jenv_name: |
177 | - cmd = 'timeout {} juju status -e {}'.format(timeout, jenv_name) |
178 | + cmd = ('timeout {} juju status --format=yaml -e ' |
179 | + '{}'.format(timeout, jenv_name)) |
180 | else: |
181 | - cmd = 'timeout {} juju status'.format(timeout) |
182 | + cmd = 'timeout {} juju status --format=yaml'.format(timeout) |
183 | j_stat = yaml.load(subprocess.check_output(cmd.split())) |
184 | except subprocess.CalledProcessError: |
185 | logging.warning(' ! Juju status attempt returned non-zero, ' |
186 | |
187 | === modified file 'deployment/bin/120-install-plugins.sh' |
188 | --- deployment/bin/120-install-plugins.sh 2014-10-03 21:52:24 +0000 |
189 | +++ deployment/bin/120-install-plugins.sh 2015-07-10 21:48:32 +0000 |
190 | @@ -10,7 +10,7 @@ |
191 | plugins="deploy-files/plugins" |
192 | |
193 | # Get jenkins master ip and url |
194 | -master_ip=$(juju status ${MASTER} | grep public-address | awk '{ print $2 }') |
195 | +master_ip=$(juju status --format=yaml ${MASTER} | grep public-address | awk '{ print $2 }') |
196 | master_url="http://${master_ip}:8080" |
197 | clijar_path="/jnlpJars/jenkins-cli.jar" |
198 | |
199 | |
200 | === modified file 'deployment/bin/220-master-floating-ip.sh' |
201 | --- deployment/bin/220-master-floating-ip.sh 2014-10-02 15:18:00 +0000 |
202 | +++ deployment/bin/220-master-floating-ip.sh 2015-07-10 21:48:32 +0000 |
203 | @@ -9,7 +9,7 @@ |
204 | |
205 | . $(dirname $0)/../../env-common |
206 | |
207 | -nova list |
208 | +nova list |
209 | |
210 | ip_f_str="10.98." |
211 | |
212 | @@ -20,7 +20,7 @@ |
213 | } |
214 | |
215 | # Get UUID of jenkins instance |
216 | -master_uuid=$(juju status ${MASTER} | grep instance-id | awk '{ print $2 }' |\ |
217 | +master_uuid=$(juju status --format=yaml ${MASTER} | grep instance-id | awk '{ print $2 }' |\ |
218 | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
219 | if [ -z "$master_uuid" ]; then |
220 | echo "Couldn't get UUID for jenkins master instance." |
221 | @@ -49,7 +49,7 @@ |
222 | # Associate the floating IP |
223 | nova floating-ip-associate $master_uuid $ip_f |
224 | echo "===================jenkins master info ===================" |
225 | -juju status ${MASTER} |
226 | +juju status --format=yaml ${MASTER} |
227 | nova list | grep $master_uuid |
228 | curl http://${ip_f}:8080 -I 2> /dev/null | egrep 'X-Jenkins:|HTTP' |
229 | echo "Jenkins master floating IP: ${ip_f}" |
230 | |
231 | === modified file 'deployment/bin/225-juju-gui-float.sh' |
232 | --- deployment/bin/225-juju-gui-float.sh 2014-11-22 16:16:10 +0000 |
233 | +++ deployment/bin/225-juju-gui-float.sh 2015-07-10 21:48:32 +0000 |
234 | @@ -14,7 +14,7 @@ |
235 | } |
236 | |
237 | # Get UUID of jenkins instance |
238 | -unit_uuid=$(juju status juju-gui | grep instance-id | awk '{ print $2 }' |\ |
239 | +unit_uuid=$(juju status --format=yaml juju-gui | grep instance-id | awk '{ print $2 }' |\ |
240 | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
241 | if [ -z "$unit_uuid" ]; then |
242 | echo "Couldn't get UUID for juju gui instance." |
243 | @@ -43,7 +43,7 @@ |
244 | # Associate the floating IP |
245 | nova floating-ip-associate $unit_uuid $ip_f |
246 | echo "===================juju gui info ===================" |
247 | -juju status juju-gui |
248 | +juju status --format=yaml juju-gui |
249 | nova list | grep $unit_uuid |
250 | echo "Juju GUI floating IP: ${ip_f}" |
251 | |
252 | |
253 | === modified file 'env-common' |
254 | --- env-common 2015-02-18 04:49:11 +0000 |
255 | +++ env-common 2015-07-10 21:48:32 +0000 |
256 | @@ -16,7 +16,7 @@ |
257 | FILE_TRIGGER_DIR="${JENKINS_HOME}/file-triggers" |
258 | |
259 | # master and all slaves |
260 | -UNITS=$(juju status | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
261 | +UNITS=$(juju status --format=yaml | egrep "osci[-]?(slave)?/[0-9]{1,10}:" \ |
262 | | cut -d ":" -f 1 | sed 's/^ *//') |
263 | |
264 | LP_ID="openstack-ubuntu-testing-bot" |
265 | |
266 | === modified file 'job-parts/README' |
267 | --- job-parts/README 2015-01-21 05:31:11 +0000 |
268 | +++ job-parts/README 2015-07-10 21:48:32 +0000 |
269 | @@ -47,4 +47,5 @@ |
270 | |
271 | Other |
272 | ===== |
273 | + * Also see the ../tools/ dir. |
274 | * Also see the main README. |
275 | |
276 | === modified file 'job-parts/juju_deploy_ok.sh' |
277 | --- job-parts/juju_deploy_ok.sh 2015-01-22 02:35:31 +0000 |
278 | +++ job-parts/juju_deploy_ok.sh 2015-07-10 21:48:32 +0000 |
279 | @@ -12,7 +12,7 @@ |
280 | . ${OSCI_ROOT}/job-parts/osci_job_common.sh |
281 | . ~/novarc |
282 | |
283 | -bad_states="$(juju stat 2>&1 | egrep 'agent\-state:|instance\-state:' | egrep -v 'ACTIVE|started' || true)" |
284 | +bad_states="$(juju stat --format=yaml 2>&1 | egrep 'agent\-state:|instance\-state:' | egrep -v 'ACTIVE|started' || true)" |
285 | jenvs="$(ls ${HOME}/.juju/environments/*jenv -alh 2> /dev/null || true)" |
286 | good_instances=$(timeout 30 nova list | grep "\-${JENV_NAME}\-machine" | grep 'ACTIVE' || true) |
287 | bad_instances=$(timeout 30 nova list | grep "\-${JENV_NAME}\-machine" | grep -v 'ACTIVE' || true) |
288 | |
289 | === modified file 'job-parts/osci_job_common.sh' |
290 | --- job-parts/osci_job_common.sh 2015-07-08 19:54:32 +0000 |
291 | +++ job-parts/osci_job_common.sh 2015-07-10 21:48:32 +0000 |
292 | @@ -47,7 +47,7 @@ |
293 | [[ -n "$1" ]] && PARAM1="$1" || PARAM1="" |
294 | f_line "Checking juju stat health: $PARAM1" |
295 | |
296 | - ${OSCI_ROOT}/job-parts/juju_status_health_check.py 2>&1 | tee $WORKSPACE/deploy-health${PARAM1}.$BUILD_NUMBER; ret_code=${PIPESTATUS[0]} |
297 | + ${OSCI_ROOT}/tools/juju_status_health_check.py 2>&1 | tee $WORKSPACE/deploy-health${PARAM1}.$BUILD_NUMBER; ret_code=${PIPESTATUS[0]} |
298 | echo "Returned: ${ret_code}" |
299 | case "$ret_code" in |
300 | 0) |
301 | @@ -295,14 +295,14 @@ |
302 | f_juju_stat "-collect" || true |
303 | |
304 | . $JENKINS_HOME/novarc |
305 | - ${OSCI_ROOT}/job-parts/nova_instances_summarize.py || true |
306 | + ${OSCI_ROOT}/tools/nova_instances_summarize.py || true |
307 | ${OSCI_ROOT}/job-parts/collect_charm_revno_info.sh || true |
308 | - ${OSCI_ROOT}/job-parts/juju_pull_logs.py || true |
309 | + ${OSCI_ROOT}/tools/juju_pull_logs.py || true |
310 | } |
311 | |
312 | |
313 | function f_juju_stat() { |
314 | - juju stat &> $WORKSPACE/juju-stat${1}.$BUILD_NUMBER || true |
315 | + juju stat --format=yaml &> $WORKSPACE/juju-stat${1}.$BUILD_NUMBER || true |
316 | juju stat --format=tabular &> $WORKSPACE/juju-stat-tab${1}.$BUILD_NUMBER || true |
317 | } |
318 | |
319 | @@ -344,13 +344,13 @@ |
320 | function f_amulet_no_teardown() { |
321 | # Hack up the makefile to prevent amulet from tearing down enviro |
322 | cd $CO_DIR |
323 | - $OSCI_ROOT/job-parts/find_replace.py -yd -i Makefile -o Makefile -f "juju test -v" -r "juju test --set-e -v" || true |
324 | + $OSCI_ROOT/tools/find_replace.py -yd -i Makefile -o Makefile -f "juju test -v" -r "juju test --set-e -v" || true |
325 | } |
326 | |
327 | |
328 | function f_amulet_set_timeout() { |
329 | - $OSCI_ROOT/job-parts/find_replace.py -yd -i Makefile -o Makefile -f "--timeout 900" -r "--timeout 2700" || true |
330 | - $OSCI_ROOT/job-parts/find_replace.py -yd -i Makefile -o Makefile -f "--timeout 1200" -r "--timeout 2700" || true |
331 | + $OSCI_ROOT/tools/find_replace.py -yd -i Makefile -o Makefile -f "--timeout 900" -r "--timeout 2700" || true |
332 | + $OSCI_ROOT/tools/find_replace.py -yd -i Makefile -o Makefile -f "--timeout 1200" -r "--timeout 2700" || true |
333 | } |
334 | |
335 | |
336 | |
337 | === modified file 'job-parts/osci_openstack_common.sh' |
338 | --- job-parts/osci_openstack_common.sh 2015-05-14 15:56:01 +0000 |
339 | +++ job-parts/osci_openstack_common.sh 2015-07-10 21:48:32 +0000 |
340 | @@ -9,7 +9,7 @@ |
341 | # Undercloud should have a flavor which exactly matches mem, otherwise |
342 | # the next largest flavor (probably 8G) will be chosen. |
343 | echo "Modifying bundle constraints (4G:4160M)." |
344 | - $OSCI_ROOT/job-parts/find_replace.py -yd -i "$BUNDLE_FILE" -o "$BUNDLE_FILE" -f "mem=4G" -r "mem=4160M" || touch $WORKSPACE/fyi-${test:0:4}.bundle-constraint-mod.failed |
345 | + $OSCI_ROOT/tools/find_replace.py -yd -i "$BUNDLE_FILE" -o "$BUNDLE_FILE" -f "mem=4G" -r "mem=4160M" || touch $WORKSPACE/fyi-${test:0:4}.bundle-constraint-mod.failed |
346 | } |
347 | |
348 | |
349 | @@ -19,7 +19,7 @@ |
350 | echo "Triggered by merge proposal: ${MP_TRIGGER}" |
351 | echo "Substituting proposed branch in deployer bundle..." |
352 | echo '' > $WORKSPACE/custom-other.yaml || true |
353 | - $OSCI_ROOT/job-parts/find_replace.py -yd -i "$OPENSTACK_CHARM_TESTING_ROOT/$CHARM_SET" -o "$WORKSPACE/custom-other.yaml" -f "$MP_TGT_BR" -r "$MP_SRC_BR" || touch $WORKSPACE/fyi-${test:0:4}.mp-branch-replace.failed |
354 | + $OSCI_ROOT/tools/find_replace.py -yd -i "$OPENSTACK_CHARM_TESTING_ROOT/$CHARM_SET" -o "$WORKSPACE/custom-other.yaml" -f "$MP_TGT_BR" -r "$MP_SRC_BR" || touch $WORKSPACE/fyi-${test:0:4}.mp-branch-replace.failed |
355 | export CHARM_SET="custom-other.yaml" |
356 | fi |
357 | } |
358 | @@ -325,9 +325,9 @@ |
359 | # Display juju gui and openstack dashboard URLs if they exist. |
360 | # Also announce ubuntu/0 floating IP for debug purposes, if exists. |
361 | f_line "GUI info, if available" |
362 | - jgui_fip=$(juju stat juju-gui/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
363 | - dash_fip=$(juju stat openstack-dashboard/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
364 | - ubnt_fip=$(juju stat ubuntu/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
365 | + jgui_fip=$(juju stat --format=yaml juju-gui/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
366 | + dash_fip=$(juju stat --format=yaml openstack-dashboard/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
367 | + ubnt_fip=$(juju stat --format=yaml ubuntu/0 | grep public-address | cut -f 2 -d ":" | xargs || true) |
368 | [[ -n "$jgui_fip" ]] && echo "Juju GUI URL: https://${jgui_fip}" || true |
369 | [[ -n "$dash_fip" ]] && echo "OpenStack Dashboard URL: http://${dash_fip}/horizon" || true |
370 | [[ -n "$ubnt_fip" ]] && echo "Ubuntu Floating IP: ${ubnt_fip}" || true |
371 | |
372 | === added directory 'tools' |
373 | === added file 'tools/README' |
374 | --- tools/README 1970-01-01 00:00:00 +0000 |
375 | +++ tools/README 2015-07-10 21:48:32 +0000 |
376 | @@ -0,0 +1,25 @@ |
377 | +UOSCI TOOLS |
378 | +=========== |
379 | + |
380 | +This tools directory contains command-line tools, used by various UOSCI |
381 | +jobs and test runners. But these are also usable as stand-alone utilities. |
382 | + |
383 | +bundle_constrainer.py A tool to add or remove service constraints in a |
384 | + Juju bundle yaml file. |
385 | + |
386 | +dummy_bundle.yaml A sample bundle with bogus charm references, useful |
387 | + in exercising various yaml tools. |
388 | + |
389 | +find_replace.py Basically, "s/find/replace/g" -i but prettier. |
390 | + |
391 | +juju_pull_logs.py Pull /var/log from all juju units. |
392 | + |
393 | +juju_status_health_check.py A basic juju status check based on juju unit status, |
394 | + agent states, SSH, ICMP and TCP connection checks. |
395 | + |
396 | +nova_instances_summarize.py Create a yaml summary file, containing nova instance |
397 | + info, filtered based on default juju environment name. |
398 | + |
399 | +yaml_spit.py Read a bundle or any yaml and spit it back out, using |
400 | + python-yaml to standardize the syntax. Useful for |
401 | + checking hand-generated yaml data. |
402 | |
403 | === added file 'tools/__init__.py' |
404 | --- tools/__init__.py 1970-01-01 00:00:00 +0000 |
405 | +++ tools/__init__.py 2015-07-10 21:48:32 +0000 |
406 | @@ -0,0 +1,1 @@ |
407 | +# |
408 | |
409 | === added file 'tools/bundle_constrainer.py' |
410 | --- tools/bundle_constrainer.py 1970-01-01 00:00:00 +0000 |
411 | +++ tools/bundle_constrainer.py 2015-07-10 21:48:32 +0000 |
412 | @@ -0,0 +1,196 @@ |
413 | +#!/usr/bin/env python |
414 | +''' |
415 | +A tool to add or remove constraints in a Juju bundle YAML file. Useful to |
416 | +inject MAAS tags, mem, arch or other constraints. |
417 | +''' |
418 | + |
419 | +import logging |
420 | +import optparse |
421 | +import os |
422 | +import sys |
423 | +import yaml |
424 | + |
425 | +sys.path.insert(1, os.path.join(sys.path[0], '..')) |
426 | +from common import osci_utils |
427 | + |
428 | +USAGE = '''Usage: %prog [options] |
429 | + |
430 | +bundle_constrainer |
431 | +============================================================================== |
432 | +A tool to add or remove constraints in a Juju bundle YAML file. Useful to |
433 | +inject MAAS tags, mem, arch or other constraints. |
434 | + |
435 | +Default behavior: |
436 | + The specified constraint key-value pairs override existing pairs |
437 | + when the keys are identical. If the specified constraints contain |
438 | + keys which do not already exist in the bundle, the new ones are |
439 | + added and the existing constraint key pairs remain. |
440 | + |
441 | + Services with placement ("to:") are ignored altogether. |
442 | + |
443 | + Will not overwrite an existing file without -y. |
444 | + |
445 | +Usage examples: |
446 | + Add constraints and overwrite the original file, with debug output: |
447 | + %prog -yd -i my.yaml -o my.yaml --constraints "mem=1G tags=dell,intel" |
448 | + |
449 | + Remove existing constraints, add new constraints, and overwrite: |
450 | + %prog -yr -i my.yaml -o my.yaml --constraints "mem=1G tags=dell" |
451 | + |
452 | + Remove all constraints and write to a new bundle yaml file: |
453 | + %prog -i old.yaml -o new.yaml --remove-all |
454 | + |
455 | + Remove all constraints, excluding the listed services, and overwrite: |
456 | + %prog -yr -i my.yaml -o my.yaml -e "ceilometer-agent,neutron-api" |
457 | +''' |
458 | + |
459 | +CNSTR = 'constraints' |
460 | + |
461 | + |
462 | +def constraint_str_dict(constraint_string): |
463 | + '''Convert a juju constraint string into a dictionary.''' |
464 | + _constraints = {} |
465 | + for pair in constraint_string.split(): |
466 | + key, val = pair.split('=') |
467 | + _constraints[key] = val |
468 | + return _constraints |
469 | + |
470 | + |
471 | +def constraint_dict_str(constraint_dict): |
472 | + '''Convert a dictionary into a juju constraint string.''' |
473 | + _constraint_string = '' |
474 | + for key, val in constraint_dict.items(): |
475 | + _constraint_string = '{} {}={}'.format(_constraint_string, key, val) |
476 | + return _constraint_string.strip() |
477 | + |
478 | + |
479 | +def merge_constraints(org_constraints, new_constraints): |
480 | + '''Merge new constraints with original constraints, where new wins.''' |
481 | + _constraints = org_constraints.copy() |
482 | + _constraints.update(new_constraints) |
483 | + return _constraints |
484 | + |
485 | + |
486 | +def update_constraints(bundle_dict, opts): |
487 | + '''Use command line options to mangle the bundle's dictionary data.''' |
488 | + if opts.exclude_services: |
489 | + exclude_services = opts.exclude_services.split(',') |
490 | + logging.info('Excluding services: {}'.format(exclude_services)) |
491 | + else: |
492 | + exclude_services = [] |
493 | + |
494 | + for target, t_v in bundle_dict.items(): |
495 | + logging.debug('Target: {}'.format(target)) |
496 | + for operation, o_v in t_v.items(): |
497 | + logging.debug('Operation: {}'.format(operation)) |
498 | + if operation == 'services': |
499 | + # NOTE: operation may commonly be: relation, services, |
500 | + # overrides or inherits. |
501 | + for service, s_v in o_v.items(): |
502 | + logging.debug('Service: {}'.format(service)) |
503 | + |
504 | + if 'to' in s_v.keys(): |
505 | + logging.info('Skipping {} as it uses placement ' |
506 | + '({}).'.format(service, s_v['to'])) |
507 | + continue |
508 | + |
509 | + if CNSTR in s_v.keys(): |
510 | + org_constraints = \ |
511 | + constraint_str_dict(s_v[CNSTR]) |
512 | + logging.info('{} has existing constraints ' |
513 | + '({}).'.format(service, org_constraints)) |
514 | + |
515 | + if opts.remove_all and service not in exclude_services: |
516 | + logging.info('Removing existing constraints for ' |
517 | + '{}'.format(service)) |
518 | + del bundle_dict[target][operation][service][CNSTR] |
519 | + else: |
520 | + org_constraints = {} |
521 | + |
522 | + if opts.constraints and service not in exclude_services: |
523 | + new_constraints = constraint_str_dict(opts.constraints) |
524 | + merged_constraints = merge_constraints(org_constraints, |
525 | + new_constraints) |
526 | + |
527 | + bundle_dict[target][operation][service][CNSTR] = \ |
528 | + constraint_dict_str(merged_constraints) |
529 | + |
530 | + return bundle_dict |
531 | + |
532 | + |
533 | +def main(): |
534 | + '''Define and handle command line parameters |
535 | + ''' |
536 | + # Define command line options |
537 | + parser = optparse.OptionParser(USAGE) |
538 | + parser.add_option("-d", "--debug", |
539 | + help="Enable debug logging", |
540 | + dest="debug", action="store_true", default=False) |
541 | + parser.add_option('-y', '--yes-overwrite', |
542 | + help='Overwrite the output file', |
543 | + dest='overwrite', action='store_true', default=False) |
544 | + parser.add_option("-i", "--in-file", |
545 | + help="YAML input (source) file", |
546 | + action="store", type="string", dest="in_file") |
547 | + parser.add_option("-o", "--out-file", |
548 | + help="YAML output (destination) file", |
549 | + action="store", type="string", dest="out_file") |
550 | + parser.add_option("--constraints", |
551 | + help="Constraints string to force onto service units.", |
552 | + action="store", type="string", dest="constraints") |
553 | + parser.add_option("-e", "--exclude-services", |
554 | + help="Comma-separated list of service names to exclude", |
555 | + action="store", type="string", dest="exclude_services") |
556 | + parser.add_option("-r", "--remove-all", |
557 | + help="Remove all constraints.", |
558 | + dest="remove_all", action="store_true", default=False) |
559 | + |
560 | + params = parser.parse_args() |
561 | + (opts, args) = params |
562 | + |
563 | + # Handle parameters, inform user |
564 | + if opts.debug: |
565 | + logging.basicConfig(level=logging.DEBUG) |
566 | + logging.info('Logging level set to DEBUG!') |
567 | + logging.debug('parse opts: \n{}'.format( |
568 | + yaml.dump(vars(opts), default_flow_style=False))) |
569 | + logging.debug('arg count: {}'.format(len(args))) |
570 | + logging.debug('parse args: {}'.format(args)) |
571 | + else: |
572 | + logging.basicConfig(level=logging.INFO) |
573 | + |
574 | + # Validate options |
575 | + if not opts.in_file or not opts.out_file: |
576 | + parser.print_help() |
577 | + sys.exit(1) |
578 | + |
579 | + # Validate and process files |
580 | + if os.path.isfile(opts.out_file) and opts.overwrite: |
581 | + logging.warning('Output file exists and will be ' |
582 | + 'overwritten: {}'.format(opts.out_file)) |
583 | + elif os.path.isfile(opts.out_file) and not opts.overwrite: |
584 | + logging.warning('Output file exists and will NOT ' |
585 | + 'be overwritten: {}'.format(opts.out_file)) |
586 | + raise ValueError('Output file exists, overwrite option not set.') |
587 | + |
588 | + if not os.path.isfile(opts.in_file): |
589 | + raise ValueError('Input file not found.') |
590 | + |
591 | + if not opts.constraints and not opts.remove_all: |
592 | + raise ValueError('No action taken. Specify new constraints ' |
593 | + 'and/or existing constraint removal.') |
594 | + |
595 | + # Read the infile |
596 | + logging.info('Reading input file: {}'.format(opts.in_file)) |
597 | + org_bundle_dict = osci_utils.read_yaml(opts.in_file) |
598 | + |
599 | + # Mangle dict data |
600 | + new_bundle_dict = update_constraints(org_bundle_dict, opts) |
601 | + |
602 | + # Write the outfile |
603 | + logging.info('Writing out file: {}'.format(opts.out_file)) |
604 | + osci_utils.write_yaml(new_bundle_dict, opts.out_file) |
605 | + |
606 | + |
607 | +if __name__ == '__main__': |
608 | + main() |
609 | |
610 | === added file 'tools/dummy-bundle.yaml' |
611 | --- tools/dummy-bundle.yaml 1970-01-01 00:00:00 +0000 |
612 | +++ tools/dummy-bundle.yaml 2015-07-10 21:48:32 +0000 |
613 | @@ -0,0 +1,48 @@ |
614 | +# A dummy bundle for testing various yaml-mangling tools. |
615 | +# |
616 | +your-target: |
617 | + services: |
618 | + white-service: |
619 | + branch: lp:some/white/charm/branch |
620 | + options: |
621 | + shade: "white is white" |
622 | + to: |
623 | + - "lxc:0" |
624 | + blue-service: |
625 | + branch: lp:some/blue/charm/branch |
626 | + num_units: 3 |
627 | + constraints: "arch=ppc64el" |
628 | + options: |
629 | + shade: light |
630 | + relations: |
631 | + - [ white-service, blue-service ] |
632 | +# Variation on that first target. |
633 | +modified-target: |
634 | + inherits: your-target |
635 | + series: p-past |
636 | + services: |
637 | + red-service: |
638 | + branch: lp:some/red/charm/branch |
639 | + constraints: "mem=1G tags=x86,sales arch=amd64" |
640 | + options: |
641 | + shade: dark |
642 | + green-service: |
643 | + branch: lp:some/green/charm/branch |
644 | + constraints: "mem=4G tags=ppc64el,support" |
645 | + options: |
646 | + shade: dark |
647 | + relations: |
648 | + - [ green-service, red-service ] |
649 | + - [ green-service, white-service ] |
650 | + - - blue-service:dummy |
651 | + - blue-service:dummy |
652 | + overrides: |
653 | + shade: dark |
654 | +# Comments will disappear if parsed with python-yaml. |
655 | +really-modified-target: |
656 | + inherits: modified-target |
657 | + series: x-future |
658 | + relations: |
659 | + - [ "green-service:dummy", white-service ] |
660 | + overrides: |
661 | + shade: bright |
662 | |
663 | === renamed file 'job-parts/find_replace.py' => 'tools/find_replace.py' |
664 | --- job-parts/find_replace.py 2015-01-07 19:32:26 +0000 |
665 | +++ tools/find_replace.py 2015-07-10 21:48:32 +0000 |
666 | @@ -13,7 +13,8 @@ |
667 | USAGE = '''Usage: %prog [options] |
668 | |
669 | Default behavior: |
670 | - Find string matches in a file, replace with text, write to a different file. |
671 | + Find string matches in a file, replace with text, write to a different file, |
672 | + with optional debug output. |
673 | |
674 | For example: |
675 | |
676 | |
677 | === renamed file 'job-parts/juju_pull_logs.py' => 'tools/juju_pull_logs.py' |
678 | === renamed file 'job-parts/juju_status_health_check.py' => 'tools/juju_status_health_check.py' |
679 | === renamed file 'job-parts/nova_instances_summarize.py' => 'tools/nova_instances_summarize.py' |
680 | === renamed file 'job-parts/yaml_spit.py' => 'tools/yaml_spit.py' |
681 | === modified file 'tox.ini' |
682 | --- tox.ini 2015-01-09 20:09:53 +0000 |
683 | +++ tox.ini 2015-07-10 21:48:32 +0000 |
684 | @@ -2,5 +2,5 @@ |
685 | # The following checks should be re-enabled in the future |
686 | # for python3 syntax correctness and sanity. |
687 | # |
688 | -ignore = H233,H301,H302,H305,H306,H402,H403,H405,H904 |
689 | +#ignore = H233,H301,H302,H305,H306,H402,H403,H405,H904 |
690 | #show-source = True |