From 16d7feb2b5d5eb5fa0bf23a95b60623ae2e1676f Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 11 Oct 2017 14:30:41 -0400 Subject: [PATCH] ceph-volume api.lvm allow to create a vg Signed-off-by: Alfredo Deza --- src/ceph-volume/ceph_volume/api/lvm.py | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 3a2187ae521..96809c9a2b0 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -190,14 +190,35 @@ def create_pv(device): ]) +def create_vg(name, *devices): + """ + Create a Volume Group. Command looks like:: + + vgcreate --force --yes group_name device + + Once created the volume group is returned as a ``VolumeGroup`` object + """ + process.run([ + 'sudo', + 'vgcreate', + '--force', + '--yes', + name] + list(devices) + ) + + vg = get_vg(vg_name=name) + return vg + + def create_lv(name, group, size=None, **tags): """ Create a Logical Volume in a Volume Group. Command looks like:: lvcreate -L 50G -n gfslv vg0 - ``name``, ``group``, and ``size`` are required. Tags are optional and are "translated" to include - the prefixes for the Ceph LVM tag API. + ``name``, ``group``, are required. If ``size`` is provided it must follow + lvm's size notation (like 1G, or 20M). Tags are optional and are + "translated" to include the prefixes for the Ceph LVM tag API. """ # XXX add CEPH_VOLUME_LVM_DEBUG to enable -vvvv on lv operations @@ -215,7 +236,7 @@ def create_lv(name, group, size=None, **tags): 'lvcreate', '--yes', '-L', - '%sG' % size, + '%s' % size, '-n', name, group ]) # create the lv with all the space available, this is needed because the -- 2.39.5