X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FCheckForNewDisks.py;h=1c171a36f11d0d557ef59217b9cdd2dd2089ba51;hb=6dbdbad233ca8770d2f9913c161a3da3f7b8130d;hp=60ae952f3a08f8034e9a7c8f7622069e83be2d6d;hpb=099b149838e51d6b04bb73073738bf1e4a5e67ad;p=bootmanager.git diff --git a/source/steps/CheckForNewDisks.py b/source/steps/CheckForNewDisks.py index 60ae952..1c171a3 100644 --- a/source/steps/CheckForNewDisks.py +++ b/source/steps/CheckForNewDisks.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 # # Copyright (c) 2003 Intel Corporation # All rights reserved. @@ -50,7 +50,7 @@ def Run(vars, log): except ValueError as var: raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var)) - all_devices = systeminfo.get_block_device_list(vars, log) + devices_dict = systeminfo.get_block_devices_dict(vars, log) # will contain the new devices to add to the volume group new_devices = [] @@ -58,9 +58,11 @@ def Run(vars, log): # total amount of new space in gb extended_gb_size = 0 - for device in all_devices.keys(): + utils.display_disks_status(PARTITIONS, "In CheckForNewDisks", log) - (major, minor, blocks, gb_size, readonly) = all_devices[device] + for device, details in devices_dict.items(): + + (major, minor, blocks, gb_size, readonly) = details if device[:14] == "/dev/planetlab": log.write("Skipping device {} in volume group.\n".format(device)) @@ -78,10 +80,17 @@ def Run(vars, log): log.write("Checking device {} to see if it is part " \ "of the volume group.\n".format(device)) - # this is the lvm partition, if it exists on that device - lvm_partition = InstallPartitionDisks.get_partition_path_from_device(device, vars, log) - cmd = "pvdisplay {} | grep -q 'planetlab'".format(lvm_partition) - already_added = utils.sysexec_noerr(cmd, log, shell=True) + # Thierry - June 2015 + # when introducing the 'upgrade' verb, we ran into the situation + # where 'pvdisplay' at this point displays e.g. /dev/sda, instead + # of /dev/sda1 + # we thus consider that if either of these is known, then + # the disk is already part of LVM + first_partition = InstallPartitionDisks.get_partition_path_from_device(device, vars, log) + probe_first_part = "pvdisplay {} | grep -q planetlab".format(first_partition) + probe_device = "pvdisplay {} | grep -q planetlab".format(device) + already_added = utils.sysexec_noerr(probe_first_part, log, shell=True) \ + or utils.sysexec_noerr(probe_device, log, shell=True) if already_added: log.write("It appears {} is part of the volume group, continuing.\n"\ @@ -92,7 +101,7 @@ def Run(vars, log): # an lvm partition on it (new disks won't have this, and that is # what this code is for, so it should be ok). cmd = "parted --script --list {} | grep -q lvm$".format(device) - has_lvm = utils.sysexec_noerr(cmd, log) + has_lvm = utils.sysexec_noerr(cmd, log, shell=True) if has_lvm: log.write("It appears {} has lvm already setup on it.\n".format(device)) paranoid = False