diff --git a/autoinstall-schema.json b/autoinstall-schema.json index a331f065..69a402a9 100644 --- a/autoinstall-schema.json +++ b/autoinstall-schema.json @@ -395,6 +395,9 @@ "additionalProperties": false } }, + "drivers": { + "type": "boolean" + }, "timezone": { "type": "string" }, diff --git a/subiquity/common/apidef.py b/subiquity/common/apidef.py index 8ad2fabe..8d850805 100644 --- a/subiquity/common/apidef.py +++ b/subiquity/common/apidef.py @@ -293,6 +293,10 @@ class API: def POST(data: Payload[ModifyPartitionV2]) \ -> StorageResponseV2: ... + class drivers: + def GET(wait: bool = False) -> bool: ... + def POST(install: bool): ... + class snaplist: def GET(wait: bool = False) -> SnapListResponse: ... def POST(data: Payload[List[SnapSelection]]): ... diff --git a/subiquity/models/drivers.py b/subiquity/models/drivers.py new file mode 100644 index 00000000..30167d9f --- /dev/null +++ b/subiquity/models/drivers.py @@ -0,0 +1,22 @@ +# Copyright 2021 Canonical, Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import logging + +log = logging.getLogger('subiquity.models.drivers') + + +class DriversModel: + do_install = False diff --git a/subiquity/models/subiquity.py b/subiquity/models/subiquity.py index fffc4bad..1302df9c 100644 --- a/subiquity/models/subiquity.py +++ b/subiquity/models/subiquity.py @@ -30,6 +30,7 @@ from subiquitycore.file_util import write_file from subiquity.common.resources import get_users_and_groups from subiquity.server.types import InstallerChannels +from .drivers import DriversModel from .filesystem import FilesystemModel from .identity import IdentityModel from .kernel import KernelModel @@ -132,6 +133,7 @@ class SubiquityModel: self.chroot_prefix = [] self.debconf_selections = DebconfSelectionsModel() + self.drivers = DriversModel() self.filesystem = FilesystemModel() self.identity = IdentityModel() self.kernel = KernelModel() diff --git a/subiquity/server/controllers/__init__.py b/subiquity/server/controllers/__init__.py index 3e0e65d3..323b920a 100644 --- a/subiquity/server/controllers/__init__.py +++ b/subiquity/server/controllers/__init__.py @@ -15,6 +15,7 @@ from .cmdlist import EarlyController, LateController, ErrorController from .debconf import DebconfController +from .drivers import DriversController from .filesystem import FilesystemController from .identity import IdentityController from .install import InstallController @@ -39,6 +40,7 @@ from .zdev import ZdevController __all__ = [ 'DebconfController', + 'DriversController', 'EarlyController', 'ErrorController', 'FilesystemController', diff --git a/subiquity/server/controllers/drivers.py b/subiquity/server/controllers/drivers.py new file mode 100644 index 00000000..5615b6c4 --- /dev/null +++ b/subiquity/server/controllers/drivers.py @@ -0,0 +1,50 @@ +# Copyright 2022 Canonical, Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import asyncio +import logging + +from subiquity.common.apidef import API +from subiquity.server.controller import SubiquityController + + +log = logging.getLogger('subiquity.server.controllers.drivers') + + +class DriversController(SubiquityController): + + endpoint = API.drivers + + autoinstall_key = model_name = "drivers" + autoinstall_schema = { + 'type': 'boolean', + } + autoinstall_default = False + + def make_autoinstall(self): + return self.model.do_install + + def load_autoinstall_data(self, data): + self.model.do_install = data + + def start(self): + asyncio.create_task(self.configured()) + + async def GET(self, wait: bool = False) -> bool: + return False + + async def POST(self, install: bool): + self.model.do_install = install + await self.configured() diff --git a/subiquity/server/server.py b/subiquity/server/server.py index 2b3639a0..1e9df82e 100644 --- a/subiquity/server/server.py +++ b/subiquity/server/server.py @@ -200,6 +200,7 @@ INSTALL_MODEL_NAMES = ModelNames({ }) POSTINSTALL_MODEL_NAMES = ModelNames({ + "drivers", "identity", "locale", "network", @@ -252,6 +253,7 @@ class SubiquityServer(Application): "Identity", "SSH", "SnapList", + "Drivers", "TimeZone", "Install", "Updates",