Merge lp:~ltrager/maas/lp1654450 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: 5629
Proposed branch: lp:~ltrager/maas/lp1654450
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 184 lines (+55/-19)
6 files modified
src/maasserver/models/bootresource.py (+28/-5)
src/maasserver/models/tests/test_bootresource.py (+16/-1)
src/maasserver/tests/test_forms_commissioning.py (+4/-4)
src/maasserver/utils/osystems.py (+4/-6)
src/maasserver/utils/tests/test_osystems.py (+1/-1)
src/maasserver/websockets/handlers/general.py (+2/-2)
To merge this branch: bzr merge lp:~ltrager/maas/lp1654450
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+314195@code.launchpad.net

Commit message

Only include real kernels when listing all usable kernels.

Each kernel lists all the other kernels supported in that release. For example hwe-16.04 lists hwe-{p,q,r,s,t,u,v,w} as it contains the support proved by all of those kernels. MAAS was filtering out the older versions however edge kernels also display the next kernel as they are a preview release.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Looks good, but read my comments before landing.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.6 MiB)

The attempt to merge lp:~ltrager/maas/lp1654450 into lp:maas failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 0s (612 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is a...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/bootresource.py'
--- src/maasserver/models/bootresource.py 2016-10-12 15:26:17 +0000
+++ src/maasserver/models/bootresource.py 2017-01-10 01:10:50 +0000
@@ -1,4 +1,4 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Boot Resource."""4"""Boot Resource."""
@@ -230,9 +230,10 @@
230 return False230 return False
231 return True231 return True
232232
233 def get_usable_hwe_kernels(233 def get_hwe_kernels(
234 self, name=None, architecture=None, kflavor=None):234 self, name=None, architecture=None, kflavor=None,
235 """Return the set of usable kernels for architecture and release."""235 include_subarches=False):
236 """Return the set of kernels."""
236 from maasserver.utils.osystems import get_release_version_from_string237 from maasserver.utils.osystems import get_release_version_from_string
237238
238 if not name:239 if not name:
@@ -257,7 +258,7 @@
257 subarch_parts[1] = 'rolling'258 subarch_parts[1] = 'rolling'
258 kernels.add('-'.join(subarch_parts))259 kernels.add('-'.join(subarch_parts))
259260
260 if "subarches" in resource.extra:261 if include_subarches and "subarches" in resource.extra:
261 for subarch in resource.extra["subarches"].split(","):262 for subarch in resource.extra["subarches"].split(","):
262 if subarch.startswith("hwe-") or subarch.startswith("ga-"):263 if subarch.startswith("hwe-") or subarch.startswith("ga-"):
263 if kflavor is None:264 if kflavor is None:
@@ -277,6 +278,28 @@
277 return sorted(278 return sorted(
278 kernels, key=lambda k: get_release_version_from_string(k))279 kernels, key=lambda k: get_release_version_from_string(k))
279280
281 def get_usable_hwe_kernels(
282 self, name=None, architecture=None, kflavor=None):
283 """Return the set of usable kernels for the given name, arch, kflavor.
284
285 Returns only the list of kernels which MAAS has downloaded. For example
286 if Trusty and Xenial have been downloaded this will return hwe-t,
287 ga-16.04, hwe-16.04, hwe-16.04-edge, hwe-16.04-lowlatency, and
288 hwe-16.04-lowlatency-edge."""
289 return self.get_hwe_kernels(name, architecture, kflavor, False)
290
291 def get_supported_hwe_kernels(
292 self, name=None, architecture=None, kflavor=None):
293 """Return the set of supported kernels for the given name, arch,
294 kflavor.
295
296 Returns the list of kernels downloaded by MAAS and the subarches each
297 of those kernels support. For example if Trusty and Xenial have been
298 downloaded this will return hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u,
299 hwe-v, hwe-w, ga-16.04, hwe-16.04, hwe-16.04-edge,
300 hwe-16.04-lowlatency, and hwe-16.04-lowlatency-edge."""
301 return self.get_hwe_kernels(name, architecture, kflavor, True)
302
280 def get_kpackage_for_node(self, node):303 def get_kpackage_for_node(self, node):
281 """Return the kernel package name for the kernel specified."""304 """Return the kernel package name for the kernel specified."""
282 if not node.hwe_kernel:305 if not node.hwe_kernel:
283306
=== modified file 'src/maasserver/models/tests/test_bootresource.py'
--- src/maasserver/models/tests/test_bootresource.py 2016-10-12 15:26:17 +0000
+++ src/maasserver/models/tests/test_bootresource.py 2017-01-10 01:10:50 +0000
@@ -1,4 +1,4 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for `BootResource`."""4"""Tests for `BootResource`."""
@@ -174,6 +174,21 @@
174 self.assertItemsEqual(174 self.assertItemsEqual(
175 arches, usable_arches)175 arches, usable_arches)
176176
177 def test_get_usable_hwe_kernel_doesnt_include_all_subarches(self):
178 factory.make_usable_boot_resource(
179 architecture='amd64/hwe-16.04',
180 extra={'subarches': 'hwe-p,hwe-t,hwe-16.04,hwe-16.10'})
181 self.assertEquals(
182 ['hwe-16.04'], BootResource.objects.get_usable_hwe_kernels())
183
184 def test_get_supported_hwe_kernel_includes_all_subarches(self):
185 factory.make_usable_boot_resource(
186 architecture='amd64/hwe-16.04',
187 extra={'subarches': 'hwe-p,hwe-t,hwe-16.04,hwe-16.10'})
188 self.assertEquals(
189 ['hwe-p', 'hwe-t', 'hwe-16.04', 'hwe-16.10'],
190 BootResource.objects.get_supported_hwe_kernels())
191
177 def test_get_commissionable_resource_returns_iterable(self):192 def test_get_commissionable_resource_returns_iterable(self):
178 os = factory.make_name('os')193 os = factory.make_name('os')
179 series = factory.make_name('series')194 series = factory.make_name('series')
180195
=== modified file 'src/maasserver/tests/test_forms_commissioning.py'
--- src/maasserver/tests/test_forms_commissioning.py 2016-07-30 01:17:54 +0000
+++ src/maasserver/tests/test_forms_commissioning.py 2017-01-10 01:10:50 +0000
@@ -40,18 +40,18 @@
4040
41 def test_commissioningform_contains_real_and_ui_choice(self):41 def test_commissioningform_contains_real_and_ui_choice(self):
42 release = factory.pick_ubuntu_release()42 release = factory.pick_ubuntu_release()
43 name = "ubuntu/" + release43 name = 'ubuntu/%s' % release
44 arch = factory.make_name('arch')
44 kernel = 'hwe-' + release[0]45 kernel = 'hwe-' + release[0]
45 # Disable boot sources signals otherwise the test fails due to unrun46 # Disable boot sources signals otherwise the test fails due to unrun
46 # post-commit tasks at the end of the test.47 # post-commit tasks at the end of the test.
47 self.useFixture(SignalsDisabled("bootsources"))48 self.useFixture(SignalsDisabled('bootsources'))
48 factory.make_BootSourceCache(49 factory.make_BootSourceCache(
49 os=name,50 os=name,
50 subarch=kernel,51 subarch=kernel,
51 release=release)52 release=release)
52 factory.make_usable_boot_resource(53 factory.make_usable_boot_resource(
53 name=name,54 name=name, architecture='%s/%s' % (arch, kernel),
54 extra={'subarches': kernel},
55 rtype=BOOT_RESOURCE_TYPE.SYNCED)55 rtype=BOOT_RESOURCE_TYPE.SYNCED)
56 Config.objects.set_config(56 Config.objects.set_config(
57 'commissioning_distro_series',57 'commissioning_distro_series',
5858
=== modified file 'src/maasserver/utils/osystems.py'
--- src/maasserver/utils/osystems.py 2016-10-03 16:27:26 +0000
+++ src/maasserver/utils/osystems.py 2017-01-10 01:10:50 +0000
@@ -1,4 +1,4 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
3"""Utilities for working with operating systems."""3"""Utilities for working with operating systems."""
44
@@ -78,10 +78,8 @@
78 for release in osystems:78 for release in osystems:
79 os_release = osystem + '/' + release['name']79 os_release = osystem + '/' + release['name']
80 kernels[osystem][release['name']] = list_hwe_kernel_choices(80 kernels[osystem][release['name']] = list_hwe_kernel_choices(
81 sorted([81 sorted(BootResource.objects.get_usable_hwe_kernels(os_release))
82 i for i in BootResource.objects.get_usable_hwe_kernels(82 )
83 os_release)
84 if release_a_newer_than_b(i, release['name'])]))
85 return kernels83 return kernels
8684
8785
@@ -473,7 +471,7 @@
473 """Check that the min_hwe_kernel is avalible."""471 """Check that the min_hwe_kernel is avalible."""
474 if not min_hwe_kernel or min_hwe_kernel == "":472 if not min_hwe_kernel or min_hwe_kernel == "":
475 return ""473 return ""
476 usable_kernels = BootResource.objects.get_usable_hwe_kernels()474 usable_kernels = BootResource.objects.get_supported_hwe_kernels()
477 if min_hwe_kernel not in usable_kernels:475 if min_hwe_kernel not in usable_kernels:
478 raise ValidationError('%s is not a usable kernel.' % min_hwe_kernel)476 raise ValidationError('%s is not a usable kernel.' % min_hwe_kernel)
479 else:477 else:
480478
=== modified file 'src/maasserver/utils/tests/test_osystems.py'
--- src/maasserver/utils/tests/test_osystems.py 2016-10-03 16:27:26 +0000
+++ src/maasserver/utils/tests/test_osystems.py 2017-01-10 01:10:50 +0000
@@ -588,7 +588,7 @@
588 kernel = factory.make_kernel_string(generic_only=True)588 kernel = factory.make_kernel_string(generic_only=True)
589 self.patch(589 self.patch(
590 BootResource.objects,590 BootResource.objects,
591 'get_usable_hwe_kernels').return_value = (kernel,)591 'get_supported_hwe_kernels').return_value = (kernel,)
592 self.assertEquals(kernel, validate_min_hwe_kernel(kernel))592 self.assertEquals(kernel, validate_min_hwe_kernel(kernel))
593593
594 def test_returns_empty_string_when_none(self):594 def test_returns_empty_string_when_none(self):
595595
=== modified file 'src/maasserver/websockets/handlers/general.py'
--- src/maasserver/websockets/handlers/general.py 2016-12-12 22:07:14 +0000
+++ src/maasserver/websockets/handlers/general.py 2017-01-10 01:10:50 +0000
@@ -1,4 +1,4 @@
1# Copyright 2015-2016 Canonical Ltd. This software is licensed under the1# Copyright 2015-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""The general handler for the WebSocket connection."""4"""The general handler for the WebSocket connection."""
@@ -86,7 +86,7 @@
86 the flavor during deployment.86 the flavor during deployment.
87 """87 """
88 return list_hwe_kernel_choices(88 return list_hwe_kernel_choices(
89 BootResource.objects.get_usable_hwe_kernels()89 BootResource.objects.get_supported_hwe_kernels()
90 )90 )
9191
92 def default_min_hwe_kernel(self, params):92 def default_min_hwe_kernel(self, params):