mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Include a pvremove module and pvabsent state
This is usefull for ensuring that the block device is removed from all kernel memory. This is required for detaching vdb's in xen.
This commit is contained in:
parent
e988137d90
commit
4c154fb55b
@ -202,6 +202,23 @@ def pvcreate(devices, **kwargs):
|
||||
return out[0]
|
||||
|
||||
|
||||
def pvremove(devices):
|
||||
'''
|
||||
Remove a physical device being used as an LVM physical volume
|
||||
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt mymachine lvm.pvremove /dev/sdb1,/dev/sdb2
|
||||
'''
|
||||
cmd = 'pvremove -y'
|
||||
for device in devices.split(','):
|
||||
cmd += ' {0}'.format(device)
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
return out[0]
|
||||
|
||||
|
||||
def vgcreate(vgname, devices, **kwargs):
|
||||
'''
|
||||
Create an LVM volume group
|
||||
|
@ -69,6 +69,36 @@ def pv_present(name, **kwargs):
|
||||
return ret
|
||||
|
||||
|
||||
def pv_absent(name):
|
||||
'''
|
||||
Ensure that a Physical Device is not being used by lvm
|
||||
|
||||
name
|
||||
The device name to initialize.
|
||||
'''
|
||||
ret = {'changes': {},
|
||||
'comment': '',
|
||||
'name': name,
|
||||
'result': True}
|
||||
|
||||
if not __salt__['lvm.pvdisplay'](name):
|
||||
ret['comment'] = 'Physical Volume {0} does not exist'.format(name)
|
||||
elif __opts__['test']:
|
||||
ret['comment'] = 'Physical Volume {0} is set to be removed'.format(name)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
else:
|
||||
changes = __salt__['lvm.pvremove'](name)
|
||||
|
||||
if not __salt__['lvm.pvdisplay'](name):
|
||||
ret['comment'] = 'Failed to remove Physical Volume {0}'.format(name)
|
||||
ret['result'] = False
|
||||
else:
|
||||
ret['comment'] = 'Removed Physical Volume {0}'.format(name)
|
||||
ret['changes'] = changes
|
||||
return ret
|
||||
|
||||
|
||||
def vg_present(name, devices=None, **kwargs):
|
||||
'''
|
||||
Create an LVM volume group
|
||||
|
Loading…
Reference in New Issue
Block a user