Skip to content

Commit

Permalink
use existing get_grub_device instead of new get_grub_devices
Browse files Browse the repository at this point in the history
newer versions of leapp deprecated get_grub_device and use
get_grub_devices instead which support raid, etc

our version does not support multiple grub devices,
so use legacy functions instead
  • Loading branch information
Monstrofil committed Jun 13, 2024
1 parent e05bbad commit 210f246
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def has_legacy_grub(device):

def check_grub_disks_for_legacy_grub():
# Both GRUB2 and Grub Legacy are recognized by `get_grub_devices`
grub_devices = grub_lib.get_grub_devices()
# oshyshatskyi: newer versions of leapp support multiple grub devices e.g. for raid
# because our version does not support that, we always check only one device
# https://github.com/oamg/leapp-repository/commit/2ba44076625e35aabfd2a1f9e45b2934f99f1e8d
grub_device = grub_lib.get_grub_device()
grub_devices = []
if grub_device:
grub_devices.append(grub_device)

legacy_grub_devices = []
for device in grub_devices:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScanGRUBDevicePartitionLayout(Actor):
"""

name = 'scan_grub_device_partition_layout'
consumes = (GrubInfo,)
consumes = ()
produces = (GRUBDevicePartitionLayout,)
tags = (FactsPhaseTag, IPUWorkflowTag,)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from leapp.libraries.stdlib import api, CalledProcessError, run
from leapp.models import GRUBDevicePartitionLayout, GrubInfo, PartitionInfo
from leapp.models import GRUBDevicePartitionLayout, PartitionInfo
from leapp.libraries.common import grub

SAFE_OFFSET_BYTES = 1024*1024 # 1MiB

Expand Down Expand Up @@ -82,11 +83,20 @@ def get_partition_layout(device):


def scan_grub_device_partition_layout():
grub_devices = next(api.consume(GrubInfo), None)
if not grub_devices:
# oshyshatskyi: newer versions of leapp support multiple grub devices e.g. for raid
# because our version does not support that, we always check only one device
# https://github.com/oamg/leapp-repository/commit/2ba44076625e35aabfd2a1f9e45b2934f99f1e8d
grub_device = grub.get_grub_device()
if not grub_device:
return

for device in grub_devices.orig_devices:
grub_devices = [grub_device]

# oshyshatskyi: originally rhel used actor to collect information
# but we are too out of date to cherry-pick it
# anyway, actor did the same thing:
# devices = grub.get_grub_devices()
# grub_info = GrubInfo(orig_devices=devices)
for device in grub_devices:
dev_info = get_partition_layout(device)
if dev_info:
api.produce(dev_info)

0 comments on commit 210f246

Please sign in to comment.