diff --git a/subiquity/controllers/installprogress.py b/subiquity/controllers/installprogress.py index 5a56e764..dc3f80b4 100644 --- a/subiquity/controllers/installprogress.py +++ b/subiquity/controllers/installprogress.py @@ -92,7 +92,6 @@ class InstallProgressController(SubiquityTuiController): self._log_syslog_identifier = 'curtin_log.%s' % (os.getpid(),) self.tb_extractor = TracebackExtractor() self.curtin_event_contexts = {} - self.confirmation = asyncio.Event() def interactive(self): return self.app.interactive() @@ -307,7 +306,7 @@ class InstallProgressController(SubiquityTuiController): self.update_state(InstallState.NEEDS_CONFIRMATION) - await self.confirmation.wait() + await self.model.confirmation.wait() self.update_state(InstallState.RUNNING) diff --git a/subiquity/core.py b/subiquity/core.py index ce3e0ef0..e4e48f9d 100644 --- a/subiquity/core.py +++ b/subiquity/core.py @@ -191,8 +191,6 @@ class Subiquity(TuiApplication): self.note_data_for_apport("SnapUpdated", str(self.updated)) self.note_data_for_apport("UsingAnswers", str(bool(self.answers))) - self.install_confirmed = False - def subiquity_event(self, event): if event["MESSAGE"] == "starting install": if event["_PID"] == os.getpid(): @@ -405,8 +403,7 @@ class Subiquity(TuiApplication): listener.report_finish_event(context, description, status) async def confirm_install(self): - self.install_confirmed = True - self.controllers.InstallProgress.confirmation.set() + self.base_model.confirm() def _cancel_show_progress(self): if self.show_progress_handle is not None: @@ -466,11 +463,8 @@ class Subiquity(TuiApplication): self.next_screen(self.confirm_install()) async def make_view_for_controller(self, new): - can_install = all(e.is_set() for e in self.base_model.install_events) - if can_install and not self.install_confirmed: - if new.model_name: - if not self.base_model.is_configured(new.model_name): - raise Confirm + if self.base_model.needs_confirmation(new.model_name): + raise Confirm if new.interactive(): if new.answers: self.aio_loop.call_soon(new.run_answers) diff --git a/subiquity/models/subiquity.py b/subiquity/models/subiquity.py index 7896ed5c..9eefffa9 100644 --- a/subiquity/models/subiquity.py +++ b/subiquity/models/subiquity.py @@ -119,6 +119,8 @@ class SubiquityModel: self.ssh = SSHModel() self.userdata = {} + self.confirmation = asyncio.Event() + self._events = { name: asyncio.Event() for name in ALL_MODEL_NAMES } @@ -143,6 +145,16 @@ class SubiquityModel: } log.debug("model %s is configured, to go %s", model_name, unconfigured) + def needs_confirmation(self, model_name): + if model_name is None: + return False + if not all(e.is_set() for e in self.install_events): + return None + return not self.confirmation.is_set() + + def confirm(self): + self.confirmation.set() + def is_configured(self, model_name): return self._events[model_name].is_set()