Use the actual device name when checking vgdisplay

fixes #26867
This commit is contained in:
Joe Julian 2015-09-02 16:17:28 -07:00
parent a563af29d3
commit 3dfb33849a

View file

@ -23,6 +23,9 @@ A state module to manage LVMs
'''
from __future__ import absolute_import
# Import python libs
import os
# Import salt libs
import salt.utils
@ -122,16 +125,17 @@ def vg_present(name, devices=None, **kwargs):
if __salt__['lvm.vgdisplay'](name):
ret['comment'] = 'Volume Group {0} already present'.format(name)
for device in devices.split(','):
pvs = __salt__['lvm.pvdisplay'](device)
if pvs and pvs.get(device, None):
if pvs[device]['Volume Group Name'] == name:
realdev = os.path.realpath(device)
pvs = __salt__['lvm.pvdisplay'](realdev)
if pvs and pvs.get(realdev, None):
if pvs[realdev]['Volume Group Name'] == name:
ret['comment'] = '{0}\n{1}'.format(
ret['comment'],
'{0} is part of Volume Group'.format(device))
elif pvs[device]['Volume Group Name'] == '#orphans_lvm2':
__salt__['lvm.vgextend'](name, device)
pvs = __salt__['lvm.pvdisplay'](device)
if pvs[device]['Volume Group Name'] == name:
elif pvs[realdev]['Volume Group Name'] == '#orphans_lvm2':
__salt__['lvm.vgextend'](name, realdev)
pvs = __salt__['lvm.pvdisplay'](realdev)
if pvs[realdev]['Volume Group Name'] == name:
ret['changes'].update(
{device: 'added to {0}'.format(name)})
else:
@ -143,7 +147,7 @@ def vg_present(name, devices=None, **kwargs):
ret['comment'] = '{0}\n{1}'.format(
ret['comment'],
'{0} is part of {1}'.format(
device, pvs[device]['Volume Group Name']))
device, pvs[realdev]['Volume Group Name']))
ret['result'] = False
else:
ret['comment'] = '{0}\n{1}'.format(