call into snapd to finish the installation of a core boot classic system

This commit is contained in:
Michael Hudson-Doyle 2022-11-02 14:34:44 +01:00
parent 8b2df438d9
commit c24cfd3d04
5 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1 @@
{"type":"sync","status-code":200,"status":"OK","result":{"id":"5","kind":"install-step-finish","summary":"Finish setup of run system for \"classic\"","status":"Doing","tasks":[{"id":"78","kind":"install-finish","summary":"Finish setup of run system for \"classic\"","status":"Doing","progress":{"label":"","done":1,"total":1},"spawn-time":"2022-10-28T06:21:14.664247396Z"}],"ready":false,"spawn-time":"2022-10-28T06:21:14.66424385Z"}}

View File

@ -0,0 +1 @@
{"type":"sync","status-code":200,"status":"OK","result":{"id":"5","kind":"install-step-finish","summary":"Finish setup of run system for \"classic\"","status":"Done","tasks":[{"id":"78","kind":"install-finish","summary":"Finish setup of run system for \"classic\"","status":"Done","progress":{"label":"","done":1,"total":1},"spawn-time":"2022-10-28T06:21:14.664247396Z","ready-time":"2022-10-28T06:21:19.699805792Z"}],"ready":true,"spawn-time":"2022-10-28T06:21:14.66424385Z","ready-time":"2022-10-28T06:21:19.699808158Z"}}

View File

@ -481,6 +481,32 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
is_last=structure == volume.structure[-1]) is_last=structure == volume.structure[-1])
disk._partitions.sort(key=lambda p: p.number) disk._partitions.sort(key=lambda p: p.number)
def _on_volumes(self) -> Dict[str, snapdapi.OnVolume]:
# Return a value suitable for use as the 'on-volumes' part of a
# SystemActionRequest.
#
# This must be run after curtin partitioning, which will result in a
# call to update_devices which will have set .path on all block
# devices.
[(key, volume)] = self._system.volumes.items()
on_volume = snapdapi.OnVolume.from_volume(volume)
for on_volume_structure in on_volume.structure:
role = on_volume_structure.role
if role in self._role_to_device:
on_volume.device = self._role_to_device[role].path
return {key: on_volume}
@with_context(description="making system bootable")
async def finish_install(self, context):
label = self.app.base_model.source.current.snapd_system_label
await snapdapi.post_and_wait(
self.app.snapdapi,
self.app.snapdapi.v2.systems[label].POST,
snapdapi.SystemActionRequest(
action=snapdapi.SystemAction.INSTALL,
step=snapdapi.SystemActionStep.FINISH,
on_volumes=self._on_volumes()))
async def guided_POST(self, data: GuidedChoice) -> StorageResponse: async def guided_POST(self, data: GuidedChoice) -> StorageResponse:
log.debug(data) log.debug(data)
if self._system is not None: if self._system is not None:

View File

@ -254,6 +254,7 @@ class InstallController(SubiquityController):
).run, ).run,
] ]
if self.model.source.current.snapd_system_label: if self.model.source.current.snapd_system_label:
fs_controller = self.app.controllers.Filesystem
steps.extend([ steps.extend([
make_curtin_step( make_curtin_step(
name="partitioning", stages=["partitioning"], name="partitioning", stages=["partitioning"],
@ -265,6 +266,7 @@ class InstallController(SubiquityController):
name="extract", stages=["extract"], name="extract", stages=["extract"],
acquire_config=self.acquire_generic_config, acquire_config=self.acquire_generic_config,
).run, ).run,
fs_controller.finish_install,
self.setup_target, self.setup_target,
]) ])
else: else:

View File

@ -141,10 +141,17 @@ class FakeSnapdConnection:
"status-code": 200, "status-code": 200,
"status": "OK", "status": "OK",
}) })
change = None
if path == "v2/snaps/subiquity" and body['action'] == 'switch': if path == "v2/snaps/subiquity" and body['action'] == 'switch':
change = "8"
if path.startswith('v2/systems/') and body['action'] == 'install':
step = body['step']
if step == 'finish':
change = "5"
if change is not None:
return _FakeMemoryResponse({ return _FakeMemoryResponse({
"type": "async", "type": "async",
"change": "8", "change": change,
"status-code": 200, "status-code": 200,
"status": "Accepted", "status": "Accepted",
}) })