]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume api.lvm allow to create a vg
authorAlfredo Deza <adeza@redhat.com>
Wed, 11 Oct 2017 18:30:41 +0000 (14:30 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 18 Oct 2017 16:46:28 +0000 (12:46 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 3a2187ae521fee36c93c86ad7d5a83604366ada5..96809c9a2b02600f33d4c890d372e78dd3ce0cfb 100644 (file)
@@ -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