adapt SubiquityModel api to allow a bit more flexibility
This commit is contained in:
parent
0bc2cf4a95
commit
fdd1879d50
|
@ -129,15 +129,15 @@ class SubiquityModel:
|
|||
self.updates = UpdatesModel()
|
||||
self.userdata = {}
|
||||
|
||||
self.confirmation = asyncio.Event()
|
||||
self._confirmation = asyncio.Event()
|
||||
|
||||
self._events = {
|
||||
name: asyncio.Event() for name in ALL_MODEL_NAMES
|
||||
}
|
||||
self.install_events = {
|
||||
self._install_events = {
|
||||
self._events[name] for name in INSTALL_MODEL_NAMES
|
||||
}
|
||||
self.postinstall_events = {
|
||||
self._postinstall_events = {
|
||||
self._events[name] for name in POSTINSTALL_MODEL_NAMES
|
||||
}
|
||||
|
||||
|
@ -161,13 +161,22 @@ class SubiquityModel:
|
|||
"model %s for %s is configured, to go %s",
|
||||
model_name, stage, unconfigured)
|
||||
|
||||
async def wait_install(self):
|
||||
await asyncio.wait({e.wait() for e in self._install_events})
|
||||
|
||||
async def wait_postinstall(self):
|
||||
await asyncio.wait({e.wait() for e in self._postinstall_events})
|
||||
|
||||
async def wait_confirmation(self):
|
||||
await self._confirmation.wait()
|
||||
|
||||
def needs_configuration(self, model_name):
|
||||
if model_name is None:
|
||||
return False
|
||||
return not self._events[model_name].is_set()
|
||||
|
||||
def confirm(self):
|
||||
self.confirmation.set()
|
||||
self._confirmation.set()
|
||||
|
||||
def get_target_groups(self):
|
||||
command = ['chroot', self.target, 'getent', 'group']
|
||||
|
|
|
@ -199,7 +199,9 @@ class InstallController(SubiquityController):
|
|||
async def install(self, *, context):
|
||||
context.set('is-install-context', True)
|
||||
try:
|
||||
await asyncio.wait({e.wait() for e in self.model.install_events})
|
||||
self.app.update_state(ApplicationState.WAITING)
|
||||
|
||||
await self.model.wait_install()
|
||||
|
||||
if not self.app.interactive:
|
||||
if 'autoinstall' in self.app.kernel_cmdline:
|
||||
|
@ -207,7 +209,7 @@ class InstallController(SubiquityController):
|
|||
|
||||
self.app.update_state(ApplicationState.NEEDS_CONFIRMATION)
|
||||
|
||||
await self.model.confirmation.wait()
|
||||
await self.model.wait_confirmation()
|
||||
|
||||
self.app.update_state(ApplicationState.RUNNING)
|
||||
|
||||
|
@ -224,8 +226,7 @@ class InstallController(SubiquityController):
|
|||
|
||||
self.app.update_state(ApplicationState.POST_WAIT)
|
||||
|
||||
await asyncio.wait(
|
||||
{e.wait() for e in self.model.postinstall_events})
|
||||
await self.model.wait_postinstall()
|
||||
|
||||
self.app.update_state(ApplicationState.POST_RUNNING)
|
||||
|
||||
|
|
Loading…
Reference in New Issue