- log.write( "Checking device %s to see if it is part " \
- "of the volume group.\n" % 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 %s | grep -q 'planetlab'" % lvm_partition
- already_added = utils.sysexec_noerr(cmd, log, shell=True)
+ log.write("Checking device {} to see if it is part " \
+ "of the volume group.\n".format(device))
+
+ # 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)