Skip to content

Commit

Permalink
generalize the way screens are skipped when installing desktop
Browse files Browse the repository at this point in the history
Also skip identity screen when installing neither server nor desktop
(i.e. core).
  • Loading branch information
mwhudson committed Jul 6, 2023
1 parent 00c65f7 commit db23775
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
23 changes: 18 additions & 5 deletions subiquity/server/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -89,18 +101,19 @@ async def apply_autoinstall_config(self, context):

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.
Expand Down
2 changes: 2 additions & 0 deletions subiquity/server/controllers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 2 additions & 14 deletions subiquity/server/controllers/snaplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -170,20 +172,6 @@ def __init__(self, app):
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 = []
Expand Down
15 changes: 2 additions & 13 deletions subiquity/server/controllers/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,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
Expand Down

0 comments on commit db23775

Please sign in to comment.