Fix modules.linux_lvm.pvcreate on existing LVM PVs

If all the devices submitted to pvcreate() are already initialized as
LVM physical volumes and override is True (which is default), pvcreate()
should return True and no futher actions should be made. The
'not cmd[1:]' check which is suited for this scenario is incorrect, as
we previously filled the 'cmd' list with two elements and thus the
condition would be always False. This would cause pvcreate() to call the
pvcreate executable with no arguments if all the submitted devices are
already initialized as LVM PVs.

Fixes #39070
This commit is contained in:
Sergei Zviagintsev 2017-01-19 14:56:05 +01:00
parent 0f84ca2487
commit f1e3e86e6a

View file

@ -229,7 +229,7 @@ def pvcreate(devices, override=True, **kwargs):
elif not override:
raise CommandExecutionError('Device "{0}" is already an LVM physical volume.'.format(device))
if not cmd[1:]:
if not cmd[2:]:
# All specified devices are already LVM volumes
return True