diff --git a/subiquity/server/controller.py b/subiquity/server/controller.py index 88b6c3aef..7a05fd704 100644 --- a/subiquity/server/controller.py +++ b/subiquity/server/controller.py @@ -50,6 +50,7 @@ def __init__(self, app): def setup_autoinstall(self): if not self.app.autoinstall_config: return + validate = True with self.context.child("load_autoinstall_data"): key_candidates = [self.autoinstall_key] if self.autoinstall_key_alias is not None: @@ -63,8 +64,9 @@ def setup_autoinstall(self): pass else: ai_data = self.autoinstall_default + validate = False - if ai_data is not None and self.autoinstall_schema is not None: + if validate and self.autoinstall_schema is not None: jsonschema.validate(ai_data, self.autoinstall_schema) self.load_autoinstall_data(ai_data) diff --git a/subiquity/server/controllers/drivers.py b/subiquity/server/controllers/drivers.py index ade96456c..8915e46ae 100644 --- a/subiquity/server/controllers/drivers.py +++ b/subiquity/server/controllers/drivers.py @@ -60,7 +60,7 @@ def make_autoinstall(self): } def load_autoinstall_data(self, data): - if data is not None and "install" in data: + if "install" in data: self.model.do_install = data["install"] def start(self): diff --git a/subiquity/server/controllers/source.py b/subiquity/server/controllers/source.py index 031be32e3..5377b75bb 100644 --- a/subiquity/server/controllers/source.py +++ b/subiquity/server/controllers/source.py @@ -76,11 +76,6 @@ def make_autoinstall(self): return {"search_drivers": self.model.search_drivers} def load_autoinstall_data(self, data: Any) -> None: - if data is None: - # For some reason, the schema validator does not reject - # "source: null" despite "type" being "object" - data = self.autoinstall_default - # search_drivers is marked required so the schema validator should # reject any missing data. assert "search_drivers" in data diff --git a/subiquity/server/controllers/ubuntu_pro.py b/subiquity/server/controllers/ubuntu_pro.py index d59387aef..0de37f094 100644 --- a/subiquity/server/controllers/ubuntu_pro.py +++ b/subiquity/server/controllers/ubuntu_pro.py @@ -61,6 +61,7 @@ class UbuntuProController(SubiquityController): }, }, } + autoinstall_default = {} def __init__(self, app) -> None: """ Initializer for server-side Ubuntu Pro controller. """ @@ -79,8 +80,6 @@ def __init__(self, app) -> None: def load_autoinstall_data(self, data: dict) -> None: """ Load autoinstall data and update the model. """ - if data is None: - return self.model.token = data.get("token", "") def make_autoinstall(self) -> dict: