Merge lp:~ltrager/maas/lp1490962 into lp:~maas-committers/maas/trunk

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 4232
Proposed branch: lp:~ltrager/maas/lp1490962
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 109 lines (+17/-16)
4 files modified
src/maasserver/models/bootresource.py (+7/-3)
src/maasserver/models/tests/test_bootresource.py (+6/-7)
src/maasserver/tests/test_forms_helpers.py (+3/-3)
src/maasserver/websockets/handlers/tests/test_general.py (+1/-3)
To merge this branch: bzr merge lp:~ltrager/maas/lp1490962
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+269848@code.launchpad.net

Commit message

Revert change from 4180 and list all architecture/subarchitecture combos but filter hwe-.

Description of the change

Before my hwe patch(4180) get_all_usable_architectures returned a list of all architectures and subarchitectures from each bootresource MAAS had. I incorrectly thought there was a kflavor per subarch. This patch reverts to the previous behavior but adds a filter on hwe-.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/bootresource.py'
2--- src/maasserver/models/bootresource.py 2015-08-14 16:33:18 +0000
3+++ src/maasserver/models/bootresource.py 2015-09-02 07:09:30 +0000
4@@ -121,9 +121,13 @@
5 if (resource_set is not None and
6 resource_set.commissionable and
7 resource_set.installable):
8- arch, _ = resource.split_arch()
9- if 'kflavor' in resource.extra:
10- arches.add('%s/%s' % (arch, resource.extra['kflavor']))
11+ if 'hwe-' not in resource.architecture:
12+ arches.add(resource.architecture)
13+ if 'subarches' in resource.extra:
14+ arch, _ = resource.split_arch()
15+ for subarch in resource.extra['subarches'].split(','):
16+ if 'hwe-' not in subarch:
17+ arches.add('%s/%s' % (arch, subarch.strip()))
18 return sorted(arches)
19
20 def get_commissionable_resource(self, osystem, series):
21
22=== modified file 'src/maasserver/models/tests/test_bootresource.py'
23--- src/maasserver/models/tests/test_bootresource.py 2015-08-14 16:33:18 +0000
24+++ src/maasserver/models/tests/test_bootresource.py 2015-09-02 07:09:30 +0000
25@@ -154,7 +154,7 @@
26
27 def test_get_usable_architectures(self):
28 arches = [
29- '%s/generic' % factory.make_name('arch')
30+ '%s/%s' % (factory.make_name('arch'), factory.make_name('subarch'))
31 for _ in range(3)
32 ]
33 for arch in arches:
34@@ -169,24 +169,23 @@
35 for _ in range(3):
36 arch = factory.make_name('arch')
37 subarches = [factory.make_name('subarch') for _ in range(3)]
38- architecture = '%s/%s' % (arch, subarches.pop())
39- arches.add(architecture)
40+ architecture = "%s/%s" % (arch, subarches[0])
41+ for subarch in subarches:
42+ arches.add('%s/%s' % (arch, subarch))
43 factory.make_usable_boot_resource(
44 architecture=architecture,
45 extra={'subarches': ','.join(subarches)})
46 usable_arches = BootResource.objects.get_usable_architectures()
47 self.assertIsInstance(usable_arches, list)
48 self.assertItemsEqual(
49- ['%s/generic' % i.split('/')[0] for i in arches],
50- usable_arches)
51+ arches, usable_arches)
52
53 def test_get_commissionable_resource_returns_iterable(self):
54 os = factory.make_name('os')
55 series = factory.make_name('series')
56 name = '%s/%s' % (os, series)
57 factory.make_usable_boot_resource(
58- rtype=BOOT_RESOURCE_TYPE.SYNCED, name=name,
59- architecture="amd64/generic")
60+ rtype=BOOT_RESOURCE_TYPE.SYNCED, name=name)
61 commissionables = BootResource.objects.get_commissionable_resource(
62 os, series)
63 self.assertIsInstance(commissionables, Iterable)
64
65=== modified file 'src/maasserver/tests/test_forms_helpers.py'
66--- src/maasserver/tests/test_forms_helpers.py 2015-08-12 11:00:04 +0000
67+++ src/maasserver/tests/test_forms_helpers.py 2015-09-02 07:09:30 +0000
68@@ -88,7 +88,7 @@
69 for arch, subarch in arches:
70 self.make_usable_boot_resource(arch=arch, subarch=subarch)
71 expected = [
72- "%s/generic" % arch for arch, subarch in arches]
73+ "%s/%s" % (arch, subarch) for arch, subarch in arches]
74 self.assertItemsEqual(expected, list_all_usable_architectures())
75
76 def test_list_all_usable_architectures_sorts_output(self):
77@@ -98,7 +98,7 @@
78 for arch, subarch in arches:
79 self.make_usable_boot_resource(arch=arch, subarch=subarch)
80 expected = [
81- "%s/generic" % arch for arch, subarch in arches]
82+ "%s/%s" % (arch, subarch) for arch, subarch in arches]
83 self.assertEqual(sorted(expected), list_all_usable_architectures())
84
85 def test_list_all_usable_architectures_returns_no_duplicates(self):
86@@ -107,7 +107,7 @@
87 self.make_usable_boot_resource(arch=arch, subarch=subarch)
88 self.make_usable_boot_resource(arch=arch, subarch=subarch)
89 self.assertEqual(
90- ["%s/generic" % arch], list_all_usable_architectures())
91+ ["%s/%s" % (arch, subarch)], list_all_usable_architectures())
92
93 def test_pick_default_architecture_returns_empty_if_no_options(self):
94 self.assertEqual('', pick_default_architecture([]))
95
96=== modified file 'src/maasserver/websockets/handlers/tests/test_general.py'
97--- src/maasserver/websockets/handlers/tests/test_general.py 2015-08-12 13:07:07 +0000
98+++ src/maasserver/websockets/handlers/tests/test_general.py 2015-09-02 07:09:30 +0000
99@@ -44,9 +44,7 @@
100 for arch in arches:
101 factory.make_usable_boot_resource(architecture=arch)
102 handler = GeneralHandler(factory.make_User(), {})
103- self.assertEquals(
104- sorted(['%s/generic' % arch.split('/')[0] for arch in arches]),
105- handler.architectures({}))
106+ self.assertEquals(sorted(arches), handler.architectures({}))
107
108 def test_osinfo(self):
109 handler = GeneralHandler(factory.make_User(), {})