]> 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)
committerAlfredo Deza <adeza@redhat.com>
Mon, 16 Jul 2018 13:57:40 +0000 (09:57 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 29962cac9e25c5dd107cdf0db454a59d86d6422d..f6b0de0ffde5ea72d9d61d4b5be0d38e743bb90c 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)