subiquity/system_setup/server/controllers/configure.py

75 lines
2.4 KiB
Python
Raw Normal View History

# Copyright 2020 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
from subiquitycore.context import with_context
from subiquity.common.errorreport import ErrorReportKind
from subiquity.server.controller import (
SubiquityController,
)
from subiquity.common.types import (
ApplicationState,
)
log = logging.getLogger("subiquity.system_setup.controllers.configure")
class ConfigureController(SubiquityController):
def __init__(self, app):
super().__init__(app)
self.model = app.base_model
def start(self):
self.install_task = self.app.aio_loop.create_task(self.configure())
@with_context(
description="final system configuration", level="INFO",
childlevel="DEBUG")
async def configure(self, *, context):
context.set('is-configure-context', True)
try:
self.app.update_state(ApplicationState.WAITING)
self.app.update_state(ApplicationState.NEEDS_CONFIRMATION)
self.app.update_state(ApplicationState.RUNNING)
self.app.update_state(ApplicationState.POST_WAIT)
# TODO WSL:
# 1. Use self.model to get all data to commit
2021-08-31 11:26:49 +00:00
# 2. Write directly (without wsl utilities) to wsl.conf and other
# fstab files
# This must not use subprocesses.
# If dry-run: write in .subiquity
self.app.update_state(ApplicationState.POST_RUNNING)
self.app.update_state(ApplicationState.DONE)
except Exception:
kw = {}
self.app.make_apport_report(
ErrorReportKind.INSTALL_FAIL, "configuration failed", **kw)
raise
def stop_uu(self):
# This is a no-op to allow Shutdown controller to depend on this one
2021-08-31 11:26:49 +00:00
pass