diff --git a/pyanaconda/modules/common/structures/partitioning.py b/pyanaconda/modules/common/structures/partitioning.py index 20adc6f5c1f..ddcb290b151 100644 --- a/pyanaconda/modules/common/structures/partitioning.py +++ b/pyanaconda/modules/common/structures/partitioning.py @@ -269,6 +269,7 @@ class MountPointRequest(DBusData): def __init__(self): self._device_spec = "" + self._ks_spec = "" self._mount_point = "" self._mount_options = "" self._reformat = False @@ -288,6 +289,19 @@ def device_spec(self, spec: Str): """Set the block device to mount.""" self._device_spec = spec + @property + def ks_spec(self) -> Str: + """Kickstart specification of the block device to mount. + + :return: a device specification + """ + return self._ks_spec + + @ks_spec.setter + def ks_spec(self, spec: Str): + """Set the kickstart specification of the device to mount.""" + self._ks_spec = spec + @property def mount_point(self) -> Str: """Mount point. diff --git a/pyanaconda/modules/storage/partitioning/manual/manual_module.py b/pyanaconda/modules/storage/partitioning/manual/manual_module.py index 2ee41e8976b..040a6db9d20 100644 --- a/pyanaconda/modules/storage/partitioning/manual/manual_module.py +++ b/pyanaconda/modules/storage/partitioning/manual/manual_module.py @@ -58,8 +58,8 @@ def process_kickstart(self, data): request = MountPointRequest() request.mount_point = mount_data.mount_point - device = self.storage.devicetree.resolve_device(mount_data.device) - request.device_spec = device.device_id + request.device_spec = None + request.ks_spec = mount_data.device request.reformat = mount_data.reformat request.format_type = mount_data.format @@ -77,8 +77,12 @@ def setup_kickstart(self, data): mount_data = data.MountData() mount_data.mount_point = request.mount_point - device = self.storage.devicetree.get_device_by_device_id(request.device_spec) - mount_data.device = device.path + if request.device_spec: + device = self.storage.devicetree.get_device_by_device_id(request.device_spec) + mount_data.device = device.path + else: + mount_data.device = request.ks_spec + mount_data.reformat = request.reformat mount_data.format = request.format_type @@ -163,7 +167,13 @@ def _find_request_for_device(self, device, requests): :return: an instance of MountPointRequest or None """ for request in requests: - if device is self.storage.devicetree.get_device_by_device_id(request.device_spec): + if request.device_spec: + rdevice = self.storage.devicetree.get_device_by_device_id(request.device_spec) + else: + rdevice = self.storage.devicetree.resolve_device(request.ks_spec) + if device is rdevice: + if not request.device_spec: + request.device_spec = device.device_id return request return None diff --git a/pyanaconda/modules/storage/partitioning/manual/manual_partitioning.py b/pyanaconda/modules/storage/partitioning/manual/manual_partitioning.py index 147dab2425b..bc412270230 100644 --- a/pyanaconda/modules/storage/partitioning/manual/manual_partitioning.py +++ b/pyanaconda/modules/storage/partitioning/manual/manual_partitioning.py @@ -64,7 +64,13 @@ def _setup_mount_point(self, storage, mount_data): # XXX empty request, ignore return - device = storage.devicetree.get_device_by_device_id(device_spec) + if device_spec: + device = storage.devicetree.get_device_by_device_id(device_spec) + else: + device = storage.devicetree.resolve_device(mount_data.ks_spec) + if device: + device_spec = device.device_id + if device is None: raise StorageError( _("Unknown or invalid device '{}' specified").format(device_spec) diff --git a/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_manual.py b/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_manual.py index 8d5c08cf3d4..d7e3eeed7e5 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_manual.py +++ b/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_manual.py @@ -71,6 +71,7 @@ def test_mount_points_property(self): "reformat": get_variant(Bool, False), "format-type": get_variant(Str, ""), "format-options": get_variant(Str, ""), + "ks-spec": get_variant(Str, ""), "mount-options": get_variant(Str, "") } self._check_dbus_property( @@ -84,6 +85,7 @@ def test_mount_points_property(self): "reformat": get_variant(Bool, True), "format-type": get_variant(Str, "xfs"), "format-options": get_variant(Str, "-L BOOT"), + "ks-spec": get_variant(Str, ""), "mount-options": get_variant(Str, "user") } self._check_dbus_property( @@ -97,6 +99,7 @@ def test_mount_points_property(self): "reformat": get_variant(Bool, False), "format-type": get_variant(Str, ""), "format-options": get_variant(Str, ""), + "ks-spec": get_variant(Str, ""), "mount-options": get_variant(Str, "") } request_2 = { @@ -105,6 +108,7 @@ def test_mount_points_property(self): "reformat": get_variant(Bool, True), "format-type": get_variant(Str, ""), "format-options": get_variant(Str, ""), + "ks-spec": get_variant(Str, ""), "mount-options": get_variant(Str, "") } self._check_dbus_property( @@ -174,6 +178,7 @@ def test_gather_requests(self): 'format-options': get_variant(Str, ''), 'format-type': get_variant(Str, 'ext4'), 'mount-options': get_variant(Str, ''), + 'ks-spec': get_variant(Str, ''), 'mount-point': get_variant(Str, '/'), 'reformat': get_variant(Bool, False) }, @@ -182,6 +187,7 @@ def test_gather_requests(self): 'format-options': get_variant(Str, ''), 'format-type': get_variant(Str, 'swap'), 'mount-options': get_variant(Str, ''), + 'ks-spec': get_variant(Str, ''), 'mount-point': get_variant(Str, ''), 'reformat': get_variant(Bool, False) } @@ -225,6 +231,7 @@ def test_gather_requests_combination(self): 'device-spec': get_variant(Str, 'dev1'), 'format-options': get_variant(Str, '-L BOOT'), 'format-type': get_variant(Str, 'xfs'), + 'ks-spec': get_variant(Str, ''), 'mount-options': get_variant(Str, 'user'), 'mount-point': get_variant(Str, '/home'), 'reformat': get_variant(Bool, True) @@ -233,6 +240,7 @@ def test_gather_requests_combination(self): 'device-spec': get_variant(Str, 'dev2'), 'format-options': get_variant(Str, ''), 'format-type': get_variant(Str, 'swap'), + 'ks-spec': get_variant(Str, ''), 'mount-options': get_variant(Str, ''), 'mount-point': get_variant(Str, ''), 'reformat': get_variant(Bool, False)