Merge lp:~jtv/maas/1.5-use-main-archive-for-intel-arches into lp:maas/1.5

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: 2258
Merged at revision: 2259
Proposed branch: lp:~jtv/maas/1.5-use-main-archive-for-intel-arches
Merge into: lp:maas/1.5
Diff against target: 116 lines (+68/-1)
4 files modified
contrib/preseeds_v2/curtin_userdata (+1/-1)
src/maasserver/models/node.py (+5/-0)
src/maasserver/models/tests/test_node.py (+7/-0)
src/maasserver/tests/test_preseed.py (+55/-0)
To merge this branch: bzr merge lp:~jtv/maas/1.5-use-main-archive-for-intel-arches
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+216814@code.launchpad.net

Commit message

Backport trunk r2278: Address one of several problems reported in bug 1310076: Curtin userdata should use the main archive for all i386/amd64 architectures, not just for the ‘generic’ ones. It was accidentally using the ports archive for HWE kernels.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Straight backport. Self-approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/preseeds_v2/curtin_userdata'
2--- contrib/preseeds_v2/curtin_userdata 2014-04-15 15:18:47 +0000
3+++ contrib/preseeds_v2/curtin_userdata 2014-04-23 03:46:12 +0000
4@@ -28,7 +28,7 @@
5 power_state:
6 mode: reboot
7
8-{{if node.architecture in {'i386/generic', 'amd64/generic'} }}
9+{{if node.split_arch()[0] in {'i386', 'amd64'} }}
10 apt_mirrors:
11 ubuntu_archive: http://{{main_archive_hostname}}/{{main_archive_directory}}
12 ubuntu_security: http://{{main_archive_hostname}}/{{main_archive_directory}}
13
14=== modified file 'src/maasserver/models/node.py'
15--- src/maasserver/models/node.py 2014-04-07 14:05:35 +0000
16+++ src/maasserver/models/node.py 2014-04-23 03:46:12 +0000
17@@ -859,3 +859,8 @@
18 "expression. This expression must instead be updated to set "
19 "this node to install with the fast installer.")
20 self.tags.add(uti_tag)
21+
22+ def split_arch(self):
23+ """Return architecture and subarchitecture, as a tuple."""
24+ arch, subarch = self.architecture.split('/')
25+ return (arch, subarch)
26
27=== modified file 'src/maasserver/models/tests/test_node.py'
28--- src/maasserver/models/tests/test_node.py 2014-04-07 14:05:35 +0000
29+++ src/maasserver/models/tests/test_node.py 2014-04-23 03:46:12 +0000
30@@ -755,6 +755,13 @@
31 "The use-fastpath-installer tag is defined with an expression",
32 unicode(error))
33
34+ def test_split_arch_returns_arch_as_tuple(self):
35+ main_arch = factory.make_name('arch')
36+ sub_arch = factory.make_name('subarch')
37+ full_arch = '%s/%s' % (main_arch, sub_arch)
38+ node = factory.make_node(architecture=full_arch)
39+ self.assertEqual((main_arch, sub_arch), node.split_arch())
40+
41
42 class NodeRoutersTest(MAASServerTestCase):
43
44
45=== modified file 'src/maasserver/tests/test_preseed.py'
46--- src/maasserver/tests/test_preseed.py 2014-04-10 14:02:21 +0000
47+++ src/maasserver/tests/test_preseed.py 2014-04-23 03:46:12 +0000
48@@ -62,6 +62,7 @@
49 AllMatch,
50 Contains,
51 ContainsAll,
52+ HasLength,
53 IsInstance,
54 MatchesAll,
55 Not,
56@@ -614,6 +615,60 @@
57 ]
58 ))
59
60+ def make_fastpath_node(self, main_arch=None):
61+ """Return a `Node`, with FPI enabled, and the given main architecture.
62+
63+ :param main_arch: A main architecture, such as `i386` or `armhf`. A
64+ subarchitecture will be made up.
65+ """
66+ if main_arch is None:
67+ main_arch = factory.make_name('arch')
68+ arch = '%s/%s' % (main_arch, factory.make_name('subarch'))
69+ node = factory.make_node(architecture=arch)
70+ node.use_fastpath_installer()
71+ return node
72+
73+ def extract_archive_setting(self, userdata):
74+ """Extract the `ubuntu_archive` setting from `userdata`."""
75+ userdata_lines = []
76+ for line in userdata.splitlines():
77+ line = line.strip()
78+ if line.startswith('ubuntu_archive'):
79+ userdata_lines.append(line)
80+ self.assertThat(userdata_lines, HasLength(1))
81+ [userdata_line] = userdata_lines
82+ key, value = userdata_line.split(':', 1)
83+ return value.strip()
84+
85+ def summarise_url(self, url):
86+ """Return just the hostname and path from `url`, normalised."""
87+ # This is needed because the userdata deliberately makes some minor
88+ # changes to the archive URLs, making it harder to recognise which
89+ # archive they use: slashes are added, schemes are hard-coded.
90+ parsed_result = urlparse(url)
91+ return parsed_result.netloc, parsed_result.path.strip('/')
92+
93+ def test_get_curtin_config_uses_main_archive_for_i386(self):
94+ node = self.make_fastpath_node('i386')
95+ userdata = get_curtin_config(node)
96+ self.assertEqual(
97+ self.summarise_url(Config.objects.get_config('main_archive')),
98+ self.summarise_url(self.extract_archive_setting(userdata)))
99+
100+ def test_get_curtin_config_uses_main_archive_for_amd64(self):
101+ node = self.make_fastpath_node('amd64')
102+ userdata = get_curtin_config(node)
103+ self.assertEqual(
104+ self.summarise_url(Config.objects.get_config('main_archive')),
105+ self.summarise_url(self.extract_archive_setting(userdata)))
106+
107+ def test_get_curtin_config_uses_ports_archive_for_other_arch(self):
108+ node = self.make_fastpath_node()
109+ userdata = get_curtin_config(node)
110+ self.assertEqual(
111+ self.summarise_url(Config.objects.get_config('ports_archive')),
112+ self.summarise_url(self.extract_archive_setting(userdata)))
113+
114 def test_get_curtin_context(self):
115 node = factory.make_node()
116 node.use_fastpath_installer()

Subscribers

People subscribed via source and target branches

to all changes: