filesystem: give Source.get_handler variation name

In order to lookup the snapd system correctly, we need the correct
variant information, and it works best by name.
This commit is contained in:
Dan Bungert 2023-05-10 15:26:07 -06:00
parent 03c48daded
commit 1bcf66c89b
2 changed files with 8 additions and 6 deletions

View File

@ -211,8 +211,9 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
await super().configured() await super().configured()
self.stop_listening_udev() self.stop_listening_udev()
async def _mount_systems_dir(self): async def _mount_systems_dir(self, variation_name):
self._source_handler = self.app.controllers.Source.get_handler() self._source_handler = \
self.app.controllers.Source.get_handler(variation_name)
source_path = self._source_handler.setup() source_path = self._source_handler.setup()
cur_systems_dir = '/var/lib/snapd/seed/systems' cur_systems_dir = '/var/lib/snapd/seed/systems'
source_systems_dir = os.path.join(source_path, cur_systems_dir[1:]) source_systems_dir = os.path.join(source_path, cur_systems_dir[1:])
@ -234,9 +235,9 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
self._source_handler.cleanup() self._source_handler.cleanup()
self._source_handler = None self._source_handler = None
async def _get_system(self, label): async def _get_system(self, variation_name, label):
try: try:
await self._mount_systems_dir() await self._mount_systems_dir(variation_name)
except NoSnapdSystemsOnSource: except NoSnapdSystemsOnSource:
return None return None
try: try:
@ -304,7 +305,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
system = None system = None
label = variation.snapd_system_label label = variation.snapd_system_label
if label is not None: if label is not None:
system = await self._get_system(label) system = await self._get_system(name, label)
log.debug("got system %s for variation %s", system, name) log.debug("got system %s for variation %s", system, name)
if system is not None and len(system.volumes) > 0: if system is not None and len(system.volumes) > 0:
self._variation_info[name] = self.info_for_system( self._variation_info[name] = self.info_for_system(
@ -606,7 +607,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
async def guided_core_boot(self, disk: Disk): async def guided_core_boot(self, disk: Disk):
# Formatting for a core boot classic system relies on some curtin # Formatting for a core boot classic system relies on some curtin
# features that are only available with v2 partitioning. # features that are only available with v2 partitioning.
await self._mount_systems_dir() await self._mount_systems_dir(self._info.name)
self.model.storage_version = 2 self.model.storage_version = 2
[volume] = self._info.system.volumes.values() [volume] = self._info.system.volumes.values()
self._on_volume = snapdapi.OnVolume.from_volume(volume) self._on_volume = snapdapi.OnVolume.from_volume(volume)

View File

@ -833,6 +833,7 @@ class TestCoreBootInstallMethods(IsolatedAsyncioTestCase):
self.fsc = FilesystemController(app=self.app) self.fsc = FilesystemController(app=self.app)
self.fsc._configured = True self.fsc._configured = True
self.fsc.model = make_model(Bootloader.UEFI) self.fsc.model = make_model(Bootloader.UEFI)
self.fsc._mount_systems_dir = mock.AsyncMock()
def _add_details_for_structures(self, structures): def _add_details_for_structures(self, structures):
self.fsc._info = VariationInfo( self.fsc._info = VariationInfo(