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: no longer in the source branch.
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
=== modified file 'contrib/preseeds_v2/curtin_userdata'
--- contrib/preseeds_v2/curtin_userdata 2014-04-15 15:18:47 +0000
+++ contrib/preseeds_v2/curtin_userdata 2014-04-23 03:46:12 +0000
@@ -28,7 +28,7 @@
28power_state:28power_state:
29 mode: reboot29 mode: reboot
3030
31{{if node.architecture in {'i386/generic', 'amd64/generic'} }}31{{if node.split_arch()[0] in {'i386', 'amd64'} }}
32apt_mirrors:32apt_mirrors:
33 ubuntu_archive: http://{{main_archive_hostname}}/{{main_archive_directory}}33 ubuntu_archive: http://{{main_archive_hostname}}/{{main_archive_directory}}
34 ubuntu_security: http://{{main_archive_hostname}}/{{main_archive_directory}}34 ubuntu_security: http://{{main_archive_hostname}}/{{main_archive_directory}}
3535
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2014-04-07 14:05:35 +0000
+++ src/maasserver/models/node.py 2014-04-23 03:46:12 +0000
@@ -859,3 +859,8 @@
859 "expression. This expression must instead be updated to set "859 "expression. This expression must instead be updated to set "
860 "this node to install with the fast installer.")860 "this node to install with the fast installer.")
861 self.tags.add(uti_tag)861 self.tags.add(uti_tag)
862
863 def split_arch(self):
864 """Return architecture and subarchitecture, as a tuple."""
865 arch, subarch = self.architecture.split('/')
866 return (arch, subarch)
862867
=== modified file 'src/maasserver/models/tests/test_node.py'
--- src/maasserver/models/tests/test_node.py 2014-04-07 14:05:35 +0000
+++ src/maasserver/models/tests/test_node.py 2014-04-23 03:46:12 +0000
@@ -755,6 +755,13 @@
755 "The use-fastpath-installer tag is defined with an expression",755 "The use-fastpath-installer tag is defined with an expression",
756 unicode(error))756 unicode(error))
757757
758 def test_split_arch_returns_arch_as_tuple(self):
759 main_arch = factory.make_name('arch')
760 sub_arch = factory.make_name('subarch')
761 full_arch = '%s/%s' % (main_arch, sub_arch)
762 node = factory.make_node(architecture=full_arch)
763 self.assertEqual((main_arch, sub_arch), node.split_arch())
764
758765
759class NodeRoutersTest(MAASServerTestCase):766class NodeRoutersTest(MAASServerTestCase):
760767
761768
=== modified file 'src/maasserver/tests/test_preseed.py'
--- src/maasserver/tests/test_preseed.py 2014-04-10 14:02:21 +0000
+++ src/maasserver/tests/test_preseed.py 2014-04-23 03:46:12 +0000
@@ -62,6 +62,7 @@
62 AllMatch,62 AllMatch,
63 Contains,63 Contains,
64 ContainsAll,64 ContainsAll,
65 HasLength,
65 IsInstance,66 IsInstance,
66 MatchesAll,67 MatchesAll,
67 Not,68 Not,
@@ -614,6 +615,60 @@
614 ]615 ]
615 ))616 ))
616617
618 def make_fastpath_node(self, main_arch=None):
619 """Return a `Node`, with FPI enabled, and the given main architecture.
620
621 :param main_arch: A main architecture, such as `i386` or `armhf`. A
622 subarchitecture will be made up.
623 """
624 if main_arch is None:
625 main_arch = factory.make_name('arch')
626 arch = '%s/%s' % (main_arch, factory.make_name('subarch'))
627 node = factory.make_node(architecture=arch)
628 node.use_fastpath_installer()
629 return node
630
631 def extract_archive_setting(self, userdata):
632 """Extract the `ubuntu_archive` setting from `userdata`."""
633 userdata_lines = []
634 for line in userdata.splitlines():
635 line = line.strip()
636 if line.startswith('ubuntu_archive'):
637 userdata_lines.append(line)
638 self.assertThat(userdata_lines, HasLength(1))
639 [userdata_line] = userdata_lines
640 key, value = userdata_line.split(':', 1)
641 return value.strip()
642
643 def summarise_url(self, url):
644 """Return just the hostname and path from `url`, normalised."""
645 # This is needed because the userdata deliberately makes some minor
646 # changes to the archive URLs, making it harder to recognise which
647 # archive they use: slashes are added, schemes are hard-coded.
648 parsed_result = urlparse(url)
649 return parsed_result.netloc, parsed_result.path.strip('/')
650
651 def test_get_curtin_config_uses_main_archive_for_i386(self):
652 node = self.make_fastpath_node('i386')
653 userdata = get_curtin_config(node)
654 self.assertEqual(
655 self.summarise_url(Config.objects.get_config('main_archive')),
656 self.summarise_url(self.extract_archive_setting(userdata)))
657
658 def test_get_curtin_config_uses_main_archive_for_amd64(self):
659 node = self.make_fastpath_node('amd64')
660 userdata = get_curtin_config(node)
661 self.assertEqual(
662 self.summarise_url(Config.objects.get_config('main_archive')),
663 self.summarise_url(self.extract_archive_setting(userdata)))
664
665 def test_get_curtin_config_uses_ports_archive_for_other_arch(self):
666 node = self.make_fastpath_node()
667 userdata = get_curtin_config(node)
668 self.assertEqual(
669 self.summarise_url(Config.objects.get_config('ports_archive')),
670 self.summarise_url(self.extract_archive_setting(userdata)))
671
617 def test_get_curtin_context(self):672 def test_get_curtin_context(self):
618 node = factory.make_node()673 node = factory.make_node()
619 node.use_fastpath_installer()674 node.use_fastpath_installer()

Subscribers

People subscribed via source and target branches

to all changes: