Skip to content

Commit

Permalink
Fix using kickstart mount command with device ID
Browse files Browse the repository at this point in the history
We unfortunately don't have populated devicetree when parsing the
kickstart so we cannot get the device ID we need later when
working with the manual partitioning requests so we need a new
attribute for requests gathered from kickstart so we can use
resolve_device later to actually get the device and the device ID
from it.

Resolves: rhinstaller/kickstart-tests#1273
  • Loading branch information
vojtechtrefny authored and rvykydal committed Aug 9, 2024
1 parent 57d09af commit 9a2a254
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
14 changes: 14 additions & 0 deletions pyanaconda/modules/common/structures/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
20 changes: 15 additions & 5 deletions pyanaconda/modules/storage/partitioning/manual/manual_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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 = {
Expand All @@ -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(
Expand Down Expand Up @@ -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)
},
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9a2a254

Please sign in to comment.