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

Proposed by Lee Trager
Status: Merged
Merged at revision: 290
Proposed branch: lp:~ltrager/maas-images/import_all_centos_images
Merge into: lp:maas-images
Prerequisite: lp:~ltrager/maas-images/centos-python23
Diff against target: 29 lines (+11/-1)
1 file modified
meph2/commands/meph2_util.py (+11/-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+292051@code.launchpad.net

Commit message

Download CentOS images with a short version string

http://cloud.centos.org/centos/ now contains images using a shorter version string in the format of YYMM. We know the second format is referencing the year and month by looking at the timestamp of each image. To ensure MAAS chooses the correct version expand the short version into a long version.

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.
Revision history for this message
Scott Moser (smoser) wrote :

ok. please fix with:
a.) clean up the inline comments as to where the YYMM (4 digit string) comes from
b.) improve the commit message to be
    summary
    blank line
    nice description like in your 'description of change' please describe also where YYMM comes from

292. By Lee Trager

Merge centos-python23

293. By Lee Trager

Add better comment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'meph2/commands/meph2_util.py'
2--- meph2/commands/meph2_util.py 2016-01-25 18:35:31 +0000
3+++ meph2/commands/meph2_util.py 2016-04-18 22:40:32 +0000
4@@ -332,7 +332,12 @@
5 """
6 ret = dict()
7 content = geturl_text(url)
8- prog = re.compile('[0-9]{8}(_[0-9]+)')
9+ # http://cloud.centos.org/centos/ contains images using two version
10+ # strings. The first is only used on older images and uses the format
11+ # YYYYMMDD_XX. The second is used on images generated monthly using the
12+ # format YYMM. We know the second format is referencing the year and month
13+ # by looking at the timestamp of each image.
14+ prog = re.compile('([\d]{8}(_[\d]+))|(\d{4})')
15
16 for i in content.split('\n'):
17 try:
18@@ -347,6 +352,11 @@
19 continue
20 img_version = m.group(0)
21
22+ # Turn the short version string into a long version string so that MAAS
23+ # uses the latest version, not the longest
24+ if len(img_version) == 4:
25+ img_version = "20%s01_01" % img_version
26+
27 # Prefer compressed image over uncompressed
28 if (img_version in ret and
29 ret[img_version]['img_name'].endswith('qcow2.xz')):

Subscribers

People subscribed via source and target branches