Merge lp:~ltrager/maas-images/import_all_centos_images into lp:maas-images

Proposed by Lee Trager
Status: Superseded
Proposed branch: lp:~ltrager/maas-images/import_all_centos_images
Merge into: lp:maas-images
Diff against target: 128 lines (+34/-7)
5 files modified
curtin/centos6/curtin-hooks.real (+5/-4)
curtin/centos6/python_wrapper (+9/-0)
curtin/centos7/curtin-hooks.real (+3/-2)
curtin/centos7/python_wrapper (+9/-0)
meph2/commands/meph2_util.py (+8/-1)
To merge this branch: bzr merge lp:~ltrager/maas-images/import_all_centos_images
Reviewer Review Type Date Requested Status
maintainers of maas images Pending
Review via email: mp+292048@code.launchpad.net

Commit message

Download CentOS images with a short version string

Description of the change

Upstream is producing new CentOS images with a short version string. Previously the format YYYYMMDD_XX was used, now they are using YYMM. This modifies CentOS import to capture all images and converts the short version string into a long version string so MAAS uses the latest image, not the one with the longest version string.

To post a comment you must log in.
292. By Lee Trager

Merge centos-python23

293. By Lee Trager

Add better comment

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added symlink 'curtin/centos6/curtin-hooks'
=== target is u'python_wrapper'
=== renamed file 'curtin/centos6/curtin-hooks' => 'curtin/centos6/curtin-hooks.real'
--- curtin/centos6/curtin-hooks 2015-08-31 20:46:57 +0000
+++ curtin/centos6/curtin-hooks.real 2016-04-15 20:44:25 +0000
@@ -6,6 +6,7 @@
6 unicode_literals,6 unicode_literals,
7 )7 )
88
9import codecs
9import os10import os
10import re11import re
11import sys12import sys
@@ -83,8 +84,8 @@
8384
84def read_file(path):85def read_file(path):
85 """Returns content of a file."""86 """Returns content of a file."""
86 with open(path, 'rb') as stream:87 with codecs.open(path, encoding='utf-8') as stream:
87 return stream.read().encode('utf-8')88 return stream.read()
8889
8990
90def write_fstab(target, curtin_fstab):91def write_fstab(target, curtin_fstab):
@@ -183,7 +184,7 @@
183 data = '\n'.join([184 data = '\n'.join([
184 'find /boot/grub/stage1',185 'find /boot/grub/stage1',
185 'quit',186 'quit',
186 ])187 ]).encode('utf-8')
187 out, err = in_chroot(['grub', '--batch'],188 out, err = in_chroot(['grub', '--batch'],
188 data=data, capture=True)189 data=data, capture=True)
189 regex = re.search('^\s+(\(.+?\))$', out, re.MULTILINE)190 regex = re.search('^\s+(\(.+?\))$', out, re.MULTILINE)
@@ -198,7 +199,7 @@
198 'root %s' % root,199 'root %s' % root,
199 'setup %s' % root_dev,200 'setup %s' % root_dev,
200 'quit',201 'quit',
201 ])202 ]).encode('utf-8')
202 in_chroot(['grub', '--batch'],203 in_chroot(['grub', '--batch'],
203 data=data)204 data=data)
204205
205206
=== added symlink 'curtin/centos6/finalize'
=== target is u'python_wrapper'
=== renamed file 'curtin/centos6/finalize' => 'curtin/centos6/finalize.real'
=== added file 'curtin/centos6/python_wrapper'
--- curtin/centos6/python_wrapper 1970-01-01 00:00:00 +0000
+++ curtin/centos6/python_wrapper 2016-04-15 20:44:25 +0000
@@ -0,0 +1,9 @@
1#!/bin/bash
2
3# Ubuntu 16.04 only ships with Python 3 while previous versions only ship
4# with Python 2.
5if type -p python > /dev/null; then
6 exec python "$0.real" "$@"
7else
8 exec python3 "$0.real" "$@"
9fi
010
=== added symlink 'curtin/centos7/curtin-hooks'
=== target is u'python_wrapper'
=== renamed file 'curtin/centos7/curtin-hooks' => 'curtin/centos7/curtin-hooks.real'
--- curtin/centos7/curtin-hooks 2015-08-31 20:46:57 +0000
+++ curtin/centos7/curtin-hooks.real 2016-04-15 20:44:25 +0000
@@ -6,6 +6,7 @@
6 unicode_literals,6 unicode_literals,
7 )7 )
88
9import codecs
9import os10import os
10import re11import re
11import sys12import sys
@@ -83,8 +84,8 @@
8384
84def read_file(path):85def read_file(path):
85 """Returns content of a file."""86 """Returns content of a file."""
86 with open(path, 'rb') as stream:87 with codecs.open(path, encoding='utf-8') as stream:
87 return stream.read().encode('utf-8')88 return stream.read()
8889
8990
90def write_fstab(target, curtin_fstab):91def write_fstab(target, curtin_fstab):
9192
=== added symlink 'curtin/centos7/finalize'
=== target is u'python_wrapper'
=== renamed file 'curtin/centos7/finalize' => 'curtin/centos7/finalize.real'
=== added file 'curtin/centos7/python_wrapper'
--- curtin/centos7/python_wrapper 1970-01-01 00:00:00 +0000
+++ curtin/centos7/python_wrapper 2016-04-15 20:44:25 +0000
@@ -0,0 +1,9 @@
1#!/bin/bash
2
3# Ubuntu 16.04 only ships with Python 3 while previous versions only ship
4# with Python 2.
5if type -p python > /dev/null; then
6 exec python "$0.real" "$@"
7else
8 exec python3 "$0.real" "$@"
9fi
010
=== modified file 'meph2/commands/meph2_util.py'
--- meph2/commands/meph2_util.py 2016-01-25 18:35:31 +0000
+++ meph2/commands/meph2_util.py 2016-04-15 20:44:25 +0000
@@ -332,7 +332,9 @@
332 """332 """
333 ret = dict()333 ret = dict()
334 content = geturl_text(url)334 content = geturl_text(url)
335 prog = re.compile('[0-9]{8}(_[0-9]+)')335 # CentOS has two version strings a long version uses the format YYYYMMDD_XX
336 # while a short version uses YYMM. Detect both
337 prog = re.compile('([\d]{8}(_[\d]+))|(\d{4})')
336338
337 for i in content.split('\n'):339 for i in content.split('\n'):
338 try:340 try:
@@ -347,6 +349,11 @@
347 continue349 continue
348 img_version = m.group(0)350 img_version = m.group(0)
349351
352 # Turn the short version string into a long version string so that MAAS
353 # uses the latest version, not the longest
354 if len(img_version) == 4:
355 img_version = "20%s01_01" % img_version
356
350 # Prefer compressed image over uncompressed357 # Prefer compressed image over uncompressed
351 if (img_version in ret and358 if (img_version in ret and
352 ret[img_version]['img_name'].endswith('qcow2.xz')):359 ret[img_version]['img_name'].endswith('qcow2.xz')):

Subscribers

People subscribed via source and target branches