From 19170dad986fc22007535fdf7de0b7b462ba0215 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 28 Jan 2014 18:52:18 +0100 Subject: [PATCH] Added snapshot option to linux_lvm.lvcreate --- salt/modules/linux_lvm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/modules/linux_lvm.py b/salt/modules/linux_lvm.py index fc05fd6d1e..a1eaf27561 100644 --- a/salt/modules/linux_lvm.py +++ b/salt/modules/linux_lvm.py @@ -230,7 +230,7 @@ def vgcreate(vgname, devices, **kwargs): return vgdata -def lvcreate(lvname, vgname, size=None, extents=None, pv=''): +def lvcreate(lvname, vgname, size=None, extents=None, snapshot=None, pv=''): ''' Create a new logical volume, with option for which physical volume to be used @@ -240,10 +240,14 @@ def lvcreate(lvname, vgname, size=None, extents=None, pv=''): salt '*' lvm.lvcreate new_volume_name vg_name size=10G salt '*' lvm.lvcreate new_volume_name vg_name extents=100 /dev/sdb + salt '*' lvm.lvcreate new_snapshot vg_name snapshot=volume_name size=3G ''' if size and extents: return 'Error: Please specify only size or extents' + if snapshot: + vgname = '-s ' + vgname + '/' + snapshot + if size: cmd = 'lvcreate -n {0} {1} -L {2} {3}'.format(lvname, vgname, size, pv) elif extents: