skeleton of a ubuntu-drivers controller and api

[Olivier Gayot]
 * update copyright year 2018 -> 2022
 * drop explicit inheritance from object

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Michael Hudson-Doyle 2021-11-24 13:31:30 +13:00 committed by Olivier Gayot
parent 43090a46ba
commit b2cd25b299
7 changed files with 85 additions and 0 deletions

View File

@ -395,6 +395,9 @@
"additionalProperties": false
}
},
"drivers": {
"type": "boolean"
},
"timezone": {
"type": "string"
},

View File

@ -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]]): ...

View File

@ -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 <http://www.gnu.org/licenses/>.
import logging
log = logging.getLogger('subiquity.models.drivers')
class DriversModel:
do_install = False

View File

@ -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()

View File

@ -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',

View File

@ -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 <http://www.gnu.org/licenses/>.
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()

View File

@ -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",