sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #07249
[Merge] ~igor-brovtsin/maas:dgx-clarity-renames into maas:master
Igor Brovtsin has proposed merging ~igor-brovtsin/maas:dgx-clarity-renames into maas:master.
Commit message:
Clarity renames for kernel-related methods
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~igor-brovtsin/maas/+git/maas/+merge/441474
Previously there were two methods, `get_usable_hwe_kernels` and
`get_supported_hwe_kernels`. Because of the naming, these were
somewhat confusing (usable kernels are not supported? supported kernels
are not usable?). As it turns out, the former method returns the list of
actual kernels, while the latter returns the list of "compatibility
levels" these kernels provide (e.g. ga-22.04 provides ga-20.04).
Another method with misleading name is `validate_hwe_kernel`, which not
only *validates* kernel string, but also *returns a valid one* if the one
provided was not valid.
All these were painful to work with, so I renamed them. This is another small
part of DGX-related changes. It is purely cosmetic, but simplifies things a lot.
--
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/forms/__init__.py b/src/maasserver/forms/__init__.py
index 09ce9b8..3838d7c 100644
--- a/src/maasserver/forms/__init__.py
+++ b/src/maasserver/forms/__init__.py
@@ -171,12 +171,12 @@ from maasserver.utils.orm import get_one
from maasserver.utils.osystems import (
get_distro_series_initial,
get_release_requires_key,
+ get_working_kernel,
list_all_releases_requiring_keys,
list_all_usable_osystems,
list_all_usable_releases,
list_osystem_choices,
list_release_choices,
- validate_hwe_kernel,
validate_min_hwe_kernel,
)
from provisioningserver.drivers.osystem import OperatingSystemRegistry
@@ -867,7 +867,7 @@ class MachineForm(NodeForm):
min_hwe_kernel = cleaned_data.get("min_hwe_kernel")
hwe_kernel = cleaned_data.get("hwe_kernel")
try:
- cleaned_data["hwe_kernel"] = validate_hwe_kernel(
+ cleaned_data["hwe_kernel"] = get_working_kernel(
hwe_kernel,
min_hwe_kernel,
architecture,
diff --git a/src/maasserver/forms/settings.py b/src/maasserver/forms/settings.py
index 8b9bd27..3c77516 100644
--- a/src/maasserver/forms/settings.py
+++ b/src/maasserver/forms/settings.py
@@ -177,7 +177,7 @@ def make_default_min_hwe_kernel_field(*args, **kwargs):
kernel_choices += list_hwe_kernel_choices(
[
kernel
- for kernel in BootResource.objects.get_usable_hwe_kernels(
+ for kernel in BootResource.objects.get_kernels(
commissioning_os_release
)
if release_a_newer_than_b(kernel, commissioning_series)
diff --git a/src/maasserver/models/bootresource.py b/src/maasserver/models/bootresource.py
index e9c2061..be9dc9e 100644
--- a/src/maasserver/models/bootresource.py
+++ b/src/maasserver/models/bootresource.py
@@ -359,7 +359,7 @@ class BootResourceManager(Manager):
kernels, key=lambda k: get_release_version_from_string(k)
)
- def get_usable_hwe_kernels(
+ def get_kernels(
self, name=None, architecture=None, platform=None, kflavor=None
):
"""Return the set of usable kernels for the given name, arch,
@@ -377,17 +377,28 @@ class BootResourceManager(Manager):
include_subarches=False,
)
- def get_supported_hwe_kernels(
+ def get_supported_kernel_compatibility_levels(
self, name=None, architecture=None, platform=None, kflavor=None
):
"""Return the set of supported kernels for the given name, arch,
kflavor.
- Returns the list of kernels downloaded by MAAS and the subarches each
- of those kernels support. For example if Trusty and Xenial have been
- downloaded this will return hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u,
- hwe-v, hwe-w, ga-16.04, hwe-16.04, hwe-16.04-edge,
- hwe-16.04-lowlatency, and hwe-16.04-lowlatency-edge."""
+ Returns the list of kernels' "subarch" values for all downloaded
+ kernels, as well as subarchitectures those kernels support.
+ Think of it as a list of "compatibility levels", where each
+ comma-separated value in "subarches" simplestream property
+ is a separate compatibility level. Useful for setting minimal
+ supported kernel version.
+
+ For example if Trusty and Xenial have been
+ downloaded this will return
+ - ga-16.04
+ - hwe-16.04
+ - hwe-16.04-edge
+ - hwe-16.04-lowlatency
+ - hwe-16.04-lowlatency-edge (all these are values of "subarch" field)
+ - hwe-[pqrstuvw] (all these are from "subarches" comma-separated list)
+ """
return self.get_hwe_kernels(
name,
architecture=architecture,
diff --git a/src/maasserver/models/tests/test_bootresource.py b/src/maasserver/models/tests/test_bootresource.py
index 462c21a..1eb0563 100644
--- a/src/maasserver/models/tests/test_bootresource.py
+++ b/src/maasserver/models/tests/test_bootresource.py
@@ -187,23 +187,23 @@ class TestBootResourceManager(MAASServerTestCase):
self.assertIsInstance(usable_arches, list)
self.assertCountEqual(arches, usable_arches)
- def test_get_usable_hwe_kernel_doesnt_include_all_subarches(self):
+ def test_get_kernels_doesnt_include_all_subarches(self):
factory.make_usable_boot_resource(
architecture="amd64/hwe-16.04",
extra={"subarches": "hwe-p,hwe-t,hwe-16.04,hwe-16.10"},
)
- self.assertEqual(
- ["hwe-16.04"], BootResource.objects.get_usable_hwe_kernels()
- )
+ self.assertEqual(["hwe-16.04"], BootResource.objects.get_kernels())
- def test_get_supported_hwe_kernel_includes_all_subarches(self):
+ def test_get_supported_kernel_compatibility_levels_includes_all_subarches(
+ self,
+ ):
factory.make_usable_boot_resource(
architecture="amd64/hwe-16.04",
extra={"subarches": "hwe-p,hwe-t,hwe-16.04,hwe-16.10"},
)
self.assertEqual(
["hwe-p", "hwe-t", "hwe-16.04", "hwe-16.10"],
- BootResource.objects.get_supported_hwe_kernels(),
+ BootResource.objects.get_supported_kernel_compatibility_levels(),
)
def test_get_commissionable_resource_returns_iterable(self):
@@ -786,7 +786,7 @@ class TestBootImagesAreInSync(MAASServerTestCase):
class TestGetUsableKernels(MAASServerTestCase):
- """Tests for `get_usable_hwe_kernels`."""
+ """Tests for `get_kernels`."""
scenarios = (
(
@@ -875,13 +875,13 @@ class TestGetUsableKernels(MAASServerTestCase):
)
self.assertCountEqual(
self.kernels,
- BootResource.objects.get_usable_hwe_kernels(self.name, self.arch),
+ BootResource.objects.get_kernels(self.name, self.arch),
"%s should return %s as its usable kernel"
% (self.name, self.kernels),
)
self.assertEqual(
generic_kernels,
- BootResource.objects.get_usable_hwe_kernels(
+ BootResource.objects.get_kernels(
name=self.name,
architecture=self.arch,
platform=None,
diff --git a/src/maasserver/node_action.py b/src/maasserver/node_action.py
index d60da4b..e35a09b 100644
--- a/src/maasserver/node_action.py
+++ b/src/maasserver/node_action.py
@@ -46,7 +46,7 @@ from maasserver.permissions import NodePermission
from maasserver.preseed import get_base_osystem_series, get_curtin_config
from maasserver.utils.orm import post_commit_do
from maasserver.utils.osystems import (
- validate_hwe_kernel,
+ get_working_kernel,
validate_osystem_and_distro_series,
)
from metadataserver.enum import SCRIPT_STATUS
@@ -547,7 +547,7 @@ class Deploy(NodeAction):
self.node.distro_series = configs["default_distro_series"]
self.node.save()
try:
- self.node.hwe_kernel = validate_hwe_kernel(
+ self.node.hwe_kernel = get_working_kernel(
hwe_kernel,
self.node.min_hwe_kernel,
self.node.architecture,
diff --git a/src/maasserver/rpc/boot.py b/src/maasserver/rpc/boot.py
index f489eaf..68fc881 100644
--- a/src/maasserver/rpc/boot.py
+++ b/src/maasserver/rpc/boot.py
@@ -30,7 +30,7 @@ from maasserver.preseed import (
)
from maasserver.third_party_drivers import get_third_party_driver
from maasserver.utils.orm import transactional
-from maasserver.utils.osystems import validate_hwe_kernel
+from maasserver.utils.osystems import get_working_kernel
from provisioningserver.events import EVENT_TYPES
from provisioningserver.logger import get_maas_logger
from provisioningserver.rpc.exceptions import BootConfigNoResponse
@@ -106,7 +106,7 @@ def get_boot_filenames(
# MAAS doesn't store in the BootResource table what subarch is the
# generic subarch so lookup what the generic subarch maps to.
try:
- boot_resource_subarch = validate_hwe_kernel(
+ boot_resource_subarch = get_working_kernel(
subarch,
None,
f"{arch}/{subarch}",
@@ -277,7 +277,7 @@ def get_boot_config_for_machine(machine, configs, purpose):
and machine.min_hwe_kernel
):
try:
- subarch = validate_hwe_kernel(
+ subarch = get_working_kernel(
None,
machine.min_hwe_kernel,
machine.architecture,
@@ -583,11 +583,11 @@ def get_config(
# converts between the two formats to make sure a bootable subarch is
# selected.
if subarch is None:
- min_hwe_kernel = validate_hwe_kernel(
+ min_hwe_kernel = get_working_kernel(
None, min_hwe_kernel, "%s/generic" % arch, osystem, series
)
else:
- min_hwe_kernel = validate_hwe_kernel(
+ min_hwe_kernel = get_working_kernel(
None,
min_hwe_kernel,
f"{arch}/{subarch}",
diff --git a/src/maasserver/rpc/tests/test_boot.py b/src/maasserver/rpc/tests/test_boot.py
index 7dddaca..21e69a2 100644
--- a/src/maasserver/rpc/tests/test_boot.py
+++ b/src/maasserver/rpc/tests/test_boot.py
@@ -630,7 +630,7 @@ class TestGetConfig(MAASServerTestCase):
None,
None,
)
- self.patch(boot_module, "validate_hwe_kernel").return_value = None
+ self.patch(boot_module, "get_working_kernel").return_value = None
factory.make_default_ubuntu_release_bootable(arch)
self.patch_autospec(boot_module, "event_log_pxe_request")
observed_config = get_config(
diff --git a/src/maasserver/utils/osystems.py b/src/maasserver/utils/osystems.py
index 67625bc..6ee8a0d 100644
--- a/src/maasserver/utils/osystems.py
+++ b/src/maasserver/utils/osystems.py
@@ -18,7 +18,7 @@ __all__ = [
"make_hwe_kernel_ui_text",
"parse_subarch_kernel_string",
"release_a_newer_than_b",
- "validate_hwe_kernel",
+ "get_working_kernel",
]
from collections import namedtuple, OrderedDict
@@ -139,7 +139,7 @@ def list_all_usable_hwe_kernels(releases):
for release in osystems:
os_release = osystem + "/" + release["name"]
kernels[osystem][release["name"]] = list_hwe_kernel_choices(
- sorted(BootResource.objects.get_usable_hwe_kernels(os_release))
+ sorted(BootResource.objects.get_kernels(os_release))
)
if len(kernels[osystem][release["name"]]) == 0:
kernels[osystem].pop(release["name"])
@@ -596,46 +596,46 @@ def release_a_newer_than_b(a, b):
return ver_a >= ver_b
-def validate_hwe_kernel(
- hwe_kernel,
- min_hwe_kernel,
+def get_working_kernel(
+ requested_kernel,
+ min_compatibility_level,
architecture,
osystem,
distro_series,
commissioning_osystem=undefined,
commissioning_distro_series=undefined,
):
- """Validates that hwe_kernel works on the selected os/release/arch.
+ """Returns ID of kernel that works on the selected os/release/arch.
- Checks that the current hwe_kernel is avalible for the selected
+ Checks that the requested kernel is available for the selected
os/release/architecture combination, and that the selected hwe_kernel is >=
min_hwe_kernel. If no hwe_kernel is selected one will be chosen.
"""
def validate_kernel_str(kstr):
- return kstr.startswith("hwe-") or kstr.startswith("ga-")
+ ksplit = kstr.split("-")
+ return "hwe" in ksplit or "ga" in ksplit
if not all((osystem, architecture, distro_series)):
- return hwe_kernel
+ return requested_kernel
+
+ arch, platform = architecture.split("/")
# If we are dealing with an ephemeral image, just return the hwe_kernel
# as-is, i.e. just stick with generic.
osystem_obj = OperatingSystemRegistry.get_item(osystem, default=None)
if osystem_obj is not None:
- arch, subarch = architecture.split("/")
purposes = osystem_obj.get_boot_image_purposes(
- arch, subarch, distro_series, "*"
+ arch, platform, distro_series, "*"
)
if "ephemeral" in purposes:
- return hwe_kernel
-
- arch, subarch = architecture.split("/")
+ return requested_kernel
# if we're deploying a custom image, we'll want to fetch info for the base image
# for the purpose of booting the ephemeral OS installer
if osystem == "custom" and distro_series:
boot_resource = BootResource.objects.get_resource_for(
- osystem, arch, subarch, distro_series
+ osystem, arch, platform, distro_series
)
if boot_resource is not None:
osystem, distro_series = boot_resource.split_base_image()
@@ -652,62 +652,77 @@ def validate_hwe_kernel(
"commissioning_distro_series"
)
- if subarch != "generic" and (
- (hwe_kernel and validate_kernel_str(hwe_kernel))
- or (min_hwe_kernel and validate_kernel_str(min_hwe_kernel))
+ if platform != "generic" and (
+ (requested_kernel and validate_kernel_str(requested_kernel))
+ or (
+ min_compatibility_level
+ and validate_kernel_str(min_compatibility_level)
+ )
):
raise ValidationError(
"Subarchitecture(%s) must be generic when setting hwe_kernel."
- % subarch
+ % platform
)
os_release = osystem + "/" + distro_series
- if hwe_kernel and validate_kernel_str(hwe_kernel):
- usable_kernels = BootResource.objects.get_usable_hwe_kernels(
- os_release, arch
+ if requested_kernel and validate_kernel_str(requested_kernel):
+ # Specific kernel was requested -- check whether it will work
+ usable_kernels = BootResource.objects.get_kernels(
+ os_release, architecture=arch
)
- if hwe_kernel not in usable_kernels:
+ if requested_kernel not in usable_kernels:
raise ValidationError(
"%s is not available for %s on %s."
- % (hwe_kernel, os_release, architecture)
+ % (requested_kernel, os_release, architecture)
)
- if not release_a_newer_than_b(hwe_kernel, distro_series):
+ if not release_a_newer_than_b(requested_kernel, distro_series):
raise ValidationError(
- f"{hwe_kernel} is too old to use on {os_release}."
+ f"{requested_kernel} is too old to use on {os_release}."
+ )
+ if (
+ min_compatibility_level
+ and validate_kernel_str(min_compatibility_level)
+ ) and (
+ not release_a_newer_than_b(
+ requested_kernel, min_compatibility_level
)
- if (min_hwe_kernel and validate_kernel_str(min_hwe_kernel)) and (
- not release_a_newer_than_b(hwe_kernel, min_hwe_kernel)
):
raise ValidationError(
- "hwe_kernel(%s) is older than min_hwe_kernel(%s)."
- % (hwe_kernel, min_hwe_kernel)
+ "chosen kernel (%s) is older than minimal kernel required by the machine (%s)."
+ % (requested_kernel, min_compatibility_level)
)
- return hwe_kernel
- elif min_hwe_kernel and validate_kernel_str(min_hwe_kernel):
+ return requested_kernel
+ elif min_compatibility_level and validate_kernel_str(
+ min_compatibility_level
+ ):
+ # No specific kernel was requested, but there is a minimal
+ # compatibility level restriction. Look for kernels that could
+ # fit the description.
+
# Determine what kflavor is being used by check against a list of
# known kflavors.
valid_kflavors = {
br.kflavor for br in BootResource.objects.exclude(kflavor=None)
}
kflavor = "generic"
- for kernel_part in min_hwe_kernel.split("-"):
+ for kernel_part in min_compatibility_level.split("-"):
if kernel_part in valid_kflavors:
kflavor = kernel_part
break
- usable_kernels = BootResource.objects.get_usable_hwe_kernels(
+ usable_kernels = BootResource.objects.get_kernels(
os_release, architecture=arch, kflavor=kflavor
)
for i in usable_kernels:
if release_a_newer_than_b(
- i, min_hwe_kernel
+ i, min_compatibility_level
) and release_a_newer_than_b(i, distro_series):
return i
raise ValidationError(
"%s has no kernels available which meet min_hwe_kernel(%s)."
- % (distro_series, min_hwe_kernel)
+ % (distro_series, min_compatibility_level)
)
- for kernel in BootResource.objects.get_usable_hwe_kernels(
+ for kernel in BootResource.objects.get_kernels(
os_release, architecture=arch, kflavor="generic"
):
if release_a_newer_than_b(kernel, distro_series):
@@ -719,8 +734,12 @@ def validate_min_hwe_kernel(min_hwe_kernel):
"""Check that the min_hwe_kernel is avalible."""
if not min_hwe_kernel or min_hwe_kernel == "":
return ""
- usable_kernels = BootResource.objects.get_supported_hwe_kernels()
- if min_hwe_kernel not in usable_kernels:
- raise ValidationError("%s is not a usable kernel." % min_hwe_kernel)
+ compatibility_levels = (
+ BootResource.objects.get_supported_kernel_compatibility_levels()
+ )
+ if min_hwe_kernel not in compatibility_levels:
+ raise ValidationError(
+ 'No kernel matches ">=%s" requirement.' % min_hwe_kernel
+ )
else:
return min_hwe_kernel
diff --git a/src/maasserver/utils/tests/test_osystems.py b/src/maasserver/utils/tests/test_osystems.py
index 446712f..3812cb7 100644
--- a/src/maasserver/utils/tests/test_osystems.py
+++ b/src/maasserver/utils/tests/test_osystems.py
@@ -27,6 +27,7 @@ from maasserver.utils.osystems import (
get_release_from_distro_info,
get_release_requires_key,
get_release_version_from_string,
+ get_working_kernel,
HWE_CHANNEL_WEIGHT,
HWE_EDGE_CHANNEL_WEIGHT,
InvalidSubarchKernelStringError,
@@ -42,7 +43,6 @@ from maasserver.utils.osystems import (
ParsedKernelString,
PLATFORM_WEIGHT,
release_a_newer_than_b,
- validate_hwe_kernel,
validate_min_hwe_kernel,
validate_osystem_and_distro_series,
)
@@ -767,37 +767,39 @@ class TestReleaseANewerThanB(MAASServerTestCase):
class TestValidateHweKernel(MAASServerTestCase):
- def test_validate_hwe_kernel_returns_default_kernel(self):
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-u")
- hwe_kernel = validate_hwe_kernel(
+ def test_get_working_kernel_returns_default_kernel(self):
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-u",
+ )
+ hwe_kernel = get_working_kernel(
None, None, "amd64/generic", "ubuntu", "trusty"
)
self.assertEqual(hwe_kernel, "hwe-t")
- def test_validate_hwe_kernel_set_kernel(self):
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-v")
- hwe_kernel = validate_hwe_kernel(
+ def test_get_working_kernel_set_kernel(self):
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-v",
+ )
+ hwe_kernel = get_working_kernel(
"hwe-v", None, "amd64/generic", "ubuntu", "trusty"
)
self.assertEqual(hwe_kernel, "hwe-v")
- def test_validate_hwe_kernel_accepts_ga_kernel(self):
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("ga-16.04",)
- hwe_kernel = validate_hwe_kernel(
+ def test_get_working_kernel_accepts_ga_kernel(self):
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "ga-16.04",
+ )
+ hwe_kernel = get_working_kernel(
"ga-16.04", None, "amd64/generic", "ubuntu", "xenial"
)
self.assertEqual(hwe_kernel, "ga-16.04")
- def test_validate_hwe_kernel_fails_with_nongeneric_arch_and_kernel(self):
+ def test_get_working_kernel_fails_with_nongeneric_arch_and_kernel(self):
exception_raised = False
try:
- validate_hwe_kernel(
+ get_working_kernel(
"hwe-v", None, "armfh/hardbank", "ubuntu", "trusty"
)
except ValidationError as e:
@@ -809,13 +811,14 @@ class TestValidateHweKernel(MAASServerTestCase):
exception_raised = True
self.assertTrue(exception_raised)
- def test_validate_hwe_kernel_fails_with_missing_hwe_kernel(self):
+ def test_get_working_kernel_fails_with_missing_hwe_kernel(self):
exception_raised = False
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-u")
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-u",
+ )
try:
- validate_hwe_kernel(
+ get_working_kernel(
"hwe-v", None, "amd64/generic", "ubuntu", "trusty"
)
except ValidationError as e:
@@ -826,13 +829,14 @@ class TestValidateHweKernel(MAASServerTestCase):
exception_raised = True
self.assertTrue(exception_raised)
- def test_validate_hwe_kernel_fails_with_old_kernel_and_newer_release(self):
+ def test_get_working_kernel_fails_with_old_kernel_and_newer_release(self):
exception_raised = False
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-v")
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-v",
+ )
try:
- validate_hwe_kernel(
+ get_working_kernel(
"hwe-t", None, "amd64/generic", "ubuntu", "vivid"
)
except ValidationError as e:
@@ -844,11 +848,12 @@ class TestValidateHweKernel(MAASServerTestCase):
def test_validate_hwe_kern_fails_with_old_kern_and_new_min_hwe_kern(self):
exception_raised = False
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-v")
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-v",
+ )
try:
- validate_hwe_kernel(
+ get_working_kernel(
"hwe-t", "hwe-v", "amd64/generic", "ubuntu", "precise"
)
except ValidationError as e:
@@ -859,13 +864,14 @@ class TestValidateHweKernel(MAASServerTestCase):
exception_raised = True
self.assertTrue(exception_raised)
- def test_validate_hwe_kernel_fails_with_no_avalible_kernels(self):
+ def test_get_working_kernel_fails_with_no_avalible_kernels(self):
exception_raised = False
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-v")
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-v",
+ )
try:
- validate_hwe_kernel(
+ get_working_kernel(
"hwe-t", "hwe-v", "amd64/generic", "ubuntu", "precise"
)
except ValidationError as e:
@@ -879,7 +885,7 @@ class TestValidateHweKernel(MAASServerTestCase):
def test_validate_hwe_kern_fails_with_old_release_and_newer_hwe_kern(self):
exception_raised = False
try:
- validate_hwe_kernel(
+ get_working_kernel(
None, "hwe-v", "amd64/generic", "ubuntu", "trusty"
)
except ValidationError as e:
@@ -892,12 +898,13 @@ class TestValidateHweKernel(MAASServerTestCase):
self.assertTrue(exception_raised)
def test_validate_hwe_kern_always_sets_kern_with_commissionable_os(self):
- self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- ).return_value = ("hwe-t", "hwe-v")
+ self.patch(BootResource.objects, "get_kernels").return_value = (
+ "hwe-t",
+ "hwe-v",
+ )
mock_get_config = self.patch(Config.objects, "get_config")
mock_get_config.return_value = "trusty"
- kernel = validate_hwe_kernel(
+ kernel = get_working_kernel(
None,
"hwe-v",
"%s/generic" % factory.make_name("arch"),
@@ -912,22 +919,20 @@ class TestValidateHweKernel(MAASServerTestCase):
def test_validate_hwe_kern_sets_hwe_kern_to_min_hwe_kern_for_edge(self):
# Regression test for LP:1654412
- mock_get_usable_hwe_kernels = self.patch(
- BootResource.objects, "get_usable_hwe_kernels"
- )
- mock_get_usable_hwe_kernels.return_value = (
+ mock_get_kernels = self.patch(BootResource.objects, "get_kernels")
+ mock_get_kernels.return_value = (
"hwe-16.04",
"hwe-16.04-edge",
)
arch = factory.make_name("arch")
- kernel = validate_hwe_kernel(
+ kernel = get_working_kernel(
None, "hwe-16.04-edge", "%s/generic" % arch, "ubuntu", "xenial"
)
self.assertEqual("hwe-16.04-edge", kernel)
self.assertThat(
- mock_get_usable_hwe_kernels,
+ mock_get_kernels,
MockCalledOnceWith(
"ubuntu/xenial", architecture=arch, kflavor="generic"
),
@@ -949,7 +954,7 @@ class TestValidateHweKernel(MAASServerTestCase):
)
osystem = "custom"
series = custom_resource.name
- kernel = validate_hwe_kernel(
+ kernel = get_working_kernel(
None, None, custom_resource.architecture, osystem, series
)
self.assertEqual("ga-18.04", kernel)
@@ -959,7 +964,7 @@ class TestValidateMinHweKernel(MAASServerTestCase):
def test_validates_kernel(self):
kernel = factory.make_kernel_string(generic_only=True)
self.patch(
- BootResource.objects, "get_supported_hwe_kernels"
+ BootResource.objects, "get_supported_kernel_compatibility_levels"
).return_value = (kernel,)
self.assertEqual(kernel, validate_min_hwe_kernel(kernel))
diff --git a/src/maasserver/websockets/handlers/general.py b/src/maasserver/websockets/handlers/general.py
index f410b2a..fe0ac0e 100644
--- a/src/maasserver/websockets/handlers/general.py
+++ b/src/maasserver/websockets/handlers/general.py
@@ -90,9 +90,7 @@ class GeneralHandler(Handler):
def hwe_kernels(self, params):
"""Return all supported hwe_kernels."""
- return list_hwe_kernel_choices(
- BootResource.objects.get_usable_hwe_kernels()
- )
+ return list_hwe_kernel_choices(BootResource.objects.get_kernels())
def min_hwe_kernels(self, params):
"""Return all supported min_hwe_kernels.
@@ -101,7 +99,7 @@ class GeneralHandler(Handler):
the flavor during deployment.
"""
return list_hwe_kernel_choices(
- BootResource.objects.get_supported_hwe_kernels()
+ BootResource.objects.get_supported_kernel_compatibility_levels()
)
def default_min_hwe_kernel(self, params):
Follow ups