diff --git a/subiquity/server/controller.py b/subiquity/server/controller.py index 88b6c3ae..06def369 100644 --- a/subiquity/server/controller.py +++ b/subiquity/server/controller.py @@ -43,9 +43,21 @@ class SubiquityController(BaseController): # deprecated in favor of autoinstall_key. autoinstall_key_alias: Optional[str] = None + interactive_for_variants = None + _active = True + def __init__(self, app): super().__init__(app) self.context.set('controller', self) + if self.interactive_for_variants is not None: + self.app.hub.subscribe( + InstallerChannels.INSTALL_CONFIRMED, self._confirmed) + + async def _confirmed(self): + variant = self.app.base_model.source.current.variant + if variant not in self.interactive_for_variants: + await self.configured() + self._active = False def setup_autoinstall(self): if not self.app.autoinstall_config: @@ -89,18 +101,19 @@ class SubiquityController(BaseController): def interactive(self): if not self.app.autoinstall_config: - return True + return self._active i_sections = self.app.autoinstall_config.get( 'interactive-sections', []) if "*" in i_sections: - return True + return self._active if self.autoinstall_key in i_sections: - return True + return self._active - return (self.autoinstall_key_alias is not None - and self.autoinstall_key_alias in i_sections) + if self.autoinstall_key_alias is not None \ + and self.autoinstall_key_alias in i_sections: + return self._active async def configured(self): """Let the world know that this controller's model is now configured. diff --git a/subiquity/server/controllers/identity.py b/subiquity/server/controllers/identity.py index 22a839e7..d32e3754 100644 --- a/subiquity/server/controllers/identity.py +++ b/subiquity/server/controllers/identity.py @@ -62,6 +62,8 @@ class IdentityController(SubiquityController): 'additionalProperties': False, } + interactive_for_variants = {'desktop', 'server'} + def __init__(self, app): super().__init__(app) core_reserved_path = resource_path("reserved-usernames") diff --git a/subiquity/server/controllers/snaplist.py b/subiquity/server/controllers/snaplist.py index 7ed08911..1b174914 100644 --- a/subiquity/server/controllers/snaplist.py +++ b/subiquity/server/controllers/snaplist.py @@ -160,6 +160,8 @@ class SnapListController(SubiquityController): } model_name = "snaplist" + interactive_for_variants = {'server'} + def _make_loader(self): return SnapdSnapInfoLoader( self.model, self.app.snapd, self.opts.snap_section, @@ -170,20 +172,6 @@ class SnapListController(SubiquityController): self.loader = self._make_loader() self.app.hub.subscribe( InstallerChannels.SNAPD_NETWORK_CHANGE, self.snapd_network_changed) - self.app.hub.subscribe( - InstallerChannels.INSTALL_CONFIRMED, self._confirmed) - self._active = True - - async def _confirmed(self): - if self.app.base_model.source.current.variant == 'desktop': - await self.configured() - self._active = False - self.loader.stop() - - def interactive(self): - if super().interactive(): - return self._active - return False def load_autoinstall_data(self, ai_data): to_install = [] diff --git a/subiquity/server/controllers/ssh.py b/subiquity/server/controllers/ssh.py index 27202733..d3ff5772 100644 --- a/subiquity/server/controllers/ssh.py +++ b/subiquity/server/controllers/ssh.py @@ -29,7 +29,6 @@ from subiquity.server.ssh import ( SSHKeyFetcher, DryRunSSHKeyFetcher, ) -from subiquity.server.types import InstallerChannels log = logging.getLogger('subiquity.server.controllers.ssh') @@ -51,26 +50,15 @@ class SSHController(SubiquityController): }, } + interactive_for_variants = {'server'} + def __init__(self, app): super().__init__(app) - self.app.hub.subscribe( - InstallerChannels.INSTALL_CONFIRMED, self._confirmed) - self._active = True if app.opts.dry_run: self.fetcher = DryRunSSHKeyFetcher(app) else: self.fetcher = SSHKeyFetcher(app) - async def _confirmed(self): - if self.app.base_model.source.current.variant == 'desktop': - await self.configured() - self._active = False - - def interactive(self): - if super().interactive(): - return self._active - return False - def load_autoinstall_data(self, data): if data is None: return