]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume api.lvm create_vg should optionally name vgs on the fly
authorAlfredo Deza <adeza@redhat.com>
Thu, 5 Jul 2018 15:39:53 +0000 (11:39 -0400)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 28 Aug 2018 15:04:38 +0000 (10:04 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 01aece2b9ab034e8d4419f262a33764664ad93a2)

src/ceph-volume/ceph_volume/api/lvm.py

index 8ac38e2009c4c09843986ca4635a45ca0ab799cd..cc2c1132d0eb6abaa7f7facc29b0bfc0d08de699 100644 (file)
@@ -401,19 +401,27 @@ def create_pv(device):
     ])
 
 
-def create_vg(name, *devices):
+def create_vg(devices, name=None):
     """
     Create a Volume Group. Command looks like::
 
         vgcreate --force --yes group_name device
 
     Once created the volume group is returned as a ``VolumeGroup`` object
+
+    :param devices: A list of devices to create a VG. Optionally, a single
+                    device (as a string) can be used.
+    :param name: Optionally set the name of the VG, defaults to 'ceph-{uuid}'
     """
+    if not isinstance(devices, list):
+        devices = [devices]
+    if name is None:
+        name = "ceph-%s" % str(uuid.uuid4())
     process.run([
         'vgcreate',
         '--force',
         '--yes',
-        name] + list(devices)
+        name] + devices
     )
 
     vg = get_vg(vg_name=name)