From af0eee99dea951a67c9756a904e7dcc05fc940ac Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 9 Dec 2022 14:13:52 +0100 Subject: [PATCH] RAID: when a MD superblock is found on a disk, offer user to use it This adds an option to enable *all* RAID devices found. This is less flexible than a more selective mechanism would be, but really simple and covering all known use-cases. Signed-off-by: Yann Dirson --- tui/installer/screens.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tui/installer/screens.py b/tui/installer/screens.py index 89ca3cf6..70fb6905 100644 --- a/tui/installer/screens.py +++ b/tui/installer/screens.py @@ -176,6 +176,11 @@ def hardware_warnings(answers, ram_warning, vt_warning): def scan_existing(answers): tui.progress.showMessageDialog("Please wait", "Checking for existing products...") + + if 'assemble-raid' in answers: + logger.log("Assembling any RAID volumes") + rv = util.runCmd2([ 'mdadm', '--assemble', "--scan" ]) + answers['installed-products'] = product.find_installed_products() answers['upgradeable-products'] = upgrade.filter_for_upgradeable_products(answers['installed-products']) answers['backups'] = product.findXenSourceBackups() @@ -249,6 +254,16 @@ def get_installation_type(answers): entries.append(("Restore %s from backup on %s" % (b, diskutil.getHumanDiskName(b.root_disk)), (b, None))) + # if we were not already told to enable RAID, and any of the disks + # found holds a MD signature, propose to activate + if "assemble-raid" not in answers: + for disk in diskutil.getQualifiedDiskList(): + rv = util.runCmd2([ 'mdadm', '--examine', disk ]) + if rv == 0: + logger.log("Found a MD RAID on %s" % disk) + entries.append(("Assemble software RAID volumes", ("RAID", None))) + break + entries.append( ("Perform clean installation", None) ) # default value? @@ -333,6 +348,10 @@ def more_info(context): elif isinstance(entry[0], product.XenServerBackup): answers['install-type'] = constants.INSTALL_TYPE_RESTORE answers['backup-to-restore'], _ = entry + elif entry[0] == "RAID": + # go rescan for products after assembling RAID volumes + answers['assemble-raid'] = True + return LEFT_BACKWARDS return RIGHT_FORWARDS