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
1=== added symlink 'curtin/centos6/curtin-hooks'
2=== target is u'python_wrapper'
3=== renamed file 'curtin/centos6/curtin-hooks' => 'curtin/centos6/curtin-hooks.real'
4--- curtin/centos6/curtin-hooks 2015-08-31 20:46:57 +0000
5+++ curtin/centos6/curtin-hooks.real 2016-04-15 20:44:25 +0000
6@@ -6,6 +6,7 @@
7 unicode_literals,
8 )
9
10+import codecs
11 import os
12 import re
13 import sys
14@@ -83,8 +84,8 @@
15
16 def read_file(path):
17 """Returns content of a file."""
18- with open(path, 'rb') as stream:
19- return stream.read().encode('utf-8')
20+ with codecs.open(path, encoding='utf-8') as stream:
21+ return stream.read()
22
23
24 def write_fstab(target, curtin_fstab):
25@@ -183,7 +184,7 @@
26 data = '\n'.join([
27 'find /boot/grub/stage1',
28 'quit',
29- ])
30+ ]).encode('utf-8')
31 out, err = in_chroot(['grub', '--batch'],
32 data=data, capture=True)
33 regex = re.search('^\s+(\(.+?\))$', out, re.MULTILINE)
34@@ -198,7 +199,7 @@
35 'root %s' % root,
36 'setup %s' % root_dev,
37 'quit',
38- ])
39+ ]).encode('utf-8')
40 in_chroot(['grub', '--batch'],
41 data=data)
42
43
44=== added symlink 'curtin/centos6/finalize'
45=== target is u'python_wrapper'
46=== renamed file 'curtin/centos6/finalize' => 'curtin/centos6/finalize.real'
47=== added file 'curtin/centos6/python_wrapper'
48--- curtin/centos6/python_wrapper 1970-01-01 00:00:00 +0000
49+++ curtin/centos6/python_wrapper 2016-04-15 20:44:25 +0000
50@@ -0,0 +1,9 @@
51+#!/bin/bash
52+
53+# Ubuntu 16.04 only ships with Python 3 while previous versions only ship
54+# with Python 2.
55+if type -p python > /dev/null; then
56+ exec python "$0.real" "$@"
57+else
58+ exec python3 "$0.real" "$@"
59+fi
60
61=== added symlink 'curtin/centos7/curtin-hooks'
62=== target is u'python_wrapper'
63=== renamed file 'curtin/centos7/curtin-hooks' => 'curtin/centos7/curtin-hooks.real'
64--- curtin/centos7/curtin-hooks 2015-08-31 20:46:57 +0000
65+++ curtin/centos7/curtin-hooks.real 2016-04-15 20:44:25 +0000
66@@ -6,6 +6,7 @@
67 unicode_literals,
68 )
69
70+import codecs
71 import os
72 import re
73 import sys
74@@ -83,8 +84,8 @@
75
76 def read_file(path):
77 """Returns content of a file."""
78- with open(path, 'rb') as stream:
79- return stream.read().encode('utf-8')
80+ with codecs.open(path, encoding='utf-8') as stream:
81+ return stream.read()
82
83
84 def write_fstab(target, curtin_fstab):
85
86=== added symlink 'curtin/centos7/finalize'
87=== target is u'python_wrapper'
88=== renamed file 'curtin/centos7/finalize' => 'curtin/centos7/finalize.real'
89=== added file 'curtin/centos7/python_wrapper'
90--- curtin/centos7/python_wrapper 1970-01-01 00:00:00 +0000
91+++ curtin/centos7/python_wrapper 2016-04-15 20:44:25 +0000
92@@ -0,0 +1,9 @@
93+#!/bin/bash
94+
95+# Ubuntu 16.04 only ships with Python 3 while previous versions only ship
96+# with Python 2.
97+if type -p python > /dev/null; then
98+ exec python "$0.real" "$@"
99+else
100+ exec python3 "$0.real" "$@"
101+fi
102
103=== modified file 'meph2/commands/meph2_util.py'
104--- meph2/commands/meph2_util.py 2016-01-25 18:35:31 +0000
105+++ meph2/commands/meph2_util.py 2016-04-15 20:44:25 +0000
106@@ -332,7 +332,9 @@
107 """
108 ret = dict()
109 content = geturl_text(url)
110- prog = re.compile('[0-9]{8}(_[0-9]+)')
111+ # CentOS has two version strings a long version uses the format YYYYMMDD_XX
112+ # while a short version uses YYMM. Detect both
113+ prog = re.compile('([\d]{8}(_[\d]+))|(\d{4})')
114
115 for i in content.split('\n'):
116 try:
117@@ -347,6 +349,11 @@
118 continue
119 img_version = m.group(0)
120
121+ # Turn the short version string into a long version string so that MAAS
122+ # uses the latest version, not the longest
123+ if len(img_version) == 4:
124+ img_version = "20%s01_01" % img_version
125+
126 # Prefer compressed image over uncompressed
127 if (img_version in ret and
128 ret[img_version]['img_name'].endswith('qcow2.xz')):

Subscribers

People subscribed via source and target branches