mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
a563af29d3
commit
3dfb33849a
1 changed files with 12 additions and 8 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue