system_setup: fixes for merge (WIP)
This commit is contained in:
parent
09e8bbb6dc
commit
eae46aa50a
|
@ -19,20 +19,27 @@ import subprocess
|
|||
from subiquity.common.apidef import API
|
||||
from subiquity.common.types import TimeZoneInfo
|
||||
from subiquity.server.controller import SubiquityController
|
||||
from shutil import which
|
||||
import os
|
||||
|
||||
log = logging.getLogger('subiquity.server.controllers.timezone')
|
||||
|
||||
TIMEDATECTLCMD = which('timedatectl')
|
||||
SD_BOOTED = os.path.exists('/run/systemd/system')
|
||||
|
||||
|
||||
def generate_possible_tzs():
|
||||
special_keys = ['', 'geoip']
|
||||
tzcmd = ['timedatectl', 'list-timezones']
|
||||
if not TIMEDATECTLCMD or not SD_BOOTED:
|
||||
return special_keys
|
||||
tzcmd = [TIMEDATECTLCMD, 'list-timezones']
|
||||
list_tz_out = subprocess.check_output(tzcmd, universal_newlines=True)
|
||||
real_tzs = list_tz_out.splitlines()
|
||||
return special_keys + real_tzs
|
||||
|
||||
|
||||
def timedatectl_settz(app, tz):
|
||||
tzcmd = ['timedatectl', 'set-timezone', tz]
|
||||
tzcmd = [TIMEDATECTLCMD, 'set-timezone', tz]
|
||||
if app.opts.dry_run:
|
||||
tzcmd = ['sleep', str(1/app.scale_factor)]
|
||||
|
||||
|
@ -44,7 +51,7 @@ def timedatectl_settz(app, tz):
|
|||
|
||||
def timedatectl_gettz():
|
||||
# timedatectl show would be easier, but isn't on bionic
|
||||
tzcmd = ['timedatectl', 'status']
|
||||
tzcmd = [TIMEDATECTLCMD, 'status']
|
||||
env = {'LC_ALL': 'C'}
|
||||
# ...
|
||||
# Time zone: America/Denver (MDT, -0600)
|
||||
|
|
|
@ -29,7 +29,6 @@ class SystemSetupClient(SubiquityClient):
|
|||
snapd_socket_path = None
|
||||
|
||||
controllers = [
|
||||
# "Serial",
|
||||
"Welcome",
|
||||
"WSLIdentity",
|
||||
"Integration",
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
from subiquity.models.subiquity import (
|
||||
SubiquityModel,
|
||||
)
|
||||
from subiquity.models.subiquity import ModelNames, SubiquityModel
|
||||
|
||||
from subiquitycore.utils import is_wsl
|
||||
|
||||
|
@ -49,7 +47,19 @@ class SystemSetupModel(SubiquityModel):
|
|||
|
||||
target = '/'
|
||||
|
||||
# Models that will be used in WSL system setup
|
||||
INSTALL_MODEL_NAMES = ModelNames({
|
||||
"locale",
|
||||
"identity",
|
||||
"wslconf1",
|
||||
})
|
||||
|
||||
def __init__(self, root, reconfigure=False):
|
||||
if reconfigure:
|
||||
self.INSTALL_MODEL_NAMES = ModelNames({
|
||||
"locale",
|
||||
"wslconf2",
|
||||
})
|
||||
# Parent class init is not called to not load models we don't need.
|
||||
self.root = root
|
||||
self.is_wsl = is_wsl()
|
||||
|
@ -61,11 +71,44 @@ class SystemSetupModel(SubiquityModel):
|
|||
self.wslconf1 = WSLConfiguration1Model()
|
||||
self.wslconf2 = WSLConfiguration2Model()
|
||||
|
||||
self.confirmation = asyncio.Event()
|
||||
self._confirmation = asyncio.Event()
|
||||
self._confirmation_task = None
|
||||
|
||||
self._configured_names = set()
|
||||
self._cur_install_model_names = set()
|
||||
self._cur_postinstall_model_names = set()
|
||||
self._install_model_names = self.INSTALL_MODEL_NAMES
|
||||
self._postinstall_model_names = None
|
||||
self._cur_install_model_names = self.INSTALL_MODEL_NAMES.default_names
|
||||
self._cur_postinstall_model_names = None
|
||||
self._install_event = asyncio.Event()
|
||||
self._postinstall_event = asyncio.Event()
|
||||
|
||||
def set_source_variant(self, variant):
|
||||
pass
|
||||
self._cur_install_model_names = \
|
||||
self._install_model_names.for_variant(variant)
|
||||
if self._cur_postinstall_model_names is not None:
|
||||
self._cur_postinstall_model_names = \
|
||||
self._postinstall_model_names.for_variant(variant)
|
||||
unconfigured_install_model_names = \
|
||||
self._cur_install_model_names - self._configured_names
|
||||
if unconfigured_install_model_names:
|
||||
if self._install_event.is_set():
|
||||
self._install_event = asyncio.Event()
|
||||
if self._confirmation_task is not None:
|
||||
self._confirmation_task.cancel()
|
||||
else:
|
||||
self._install_event.set()
|
||||
|
||||
def configured(self, model_name):
|
||||
self._configured_names.add(model_name)
|
||||
if model_name in self._cur_install_model_names:
|
||||
stage = 'install'
|
||||
names = self._cur_install_model_names
|
||||
event = self._install_event
|
||||
else:
|
||||
return
|
||||
unconfigured = names - self._configured_names
|
||||
log.debug(
|
||||
"model %s for %s stage is configured, to go %s",
|
||||
model_name, stage, unconfigured)
|
||||
if not unconfigured:
|
||||
event.set()
|
||||
|
|
|
@ -43,7 +43,7 @@ from subiquitycore.ssh import user_key_fingerprints
|
|||
from subiquitycore.utils import arun_command, run_command
|
||||
from system_setup.models.system_server import SystemSetupModel
|
||||
|
||||
log = logging.getLogger('subiquity.server.server')
|
||||
log = logging.getLogger('system_setup.server.server')
|
||||
|
||||
NOPROBERARG = "NOPROBER"
|
||||
|
||||
|
@ -106,8 +106,6 @@ class SystemSetupServer(Application):
|
|||
self.context.child("ErrorReporter"), self.opts.dry_run, self.root)
|
||||
self.prober = None
|
||||
self.kernel_cmdline = shlex.split(opts.kernel_cmdline)
|
||||
self.controllers.remove("Refresh")
|
||||
self.controllers.remove("SnapList")
|
||||
self.snapd = None
|
||||
self.note_data_for_apport("SnapUpdated", str(self.updated))
|
||||
self.event_listeners = []
|
||||
|
@ -123,7 +121,6 @@ class SystemSetupServer(Application):
|
|||
"Locale",
|
||||
"WSLConfiguration2",
|
||||
]
|
||||
super().__init__(opts, block_log_dir)
|
||||
|
||||
def make_model(self):
|
||||
root = '/'
|
||||
|
|
Loading…
Reference in New Issue