ceph-volume api.lvm new utility to extend a volume group for one or more devices
authorAlfredo Deza <adeza@redhat.com>
Thu, 23 Aug 2018 12:35:02 +0000 (08:35 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 24 Aug 2018 14:18:04 +0000 (10:18 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 414f0a7eac17a40de074451dec7616dd3dd6c402..e766671b3238c0feb18b8ccb2255825b4fd7f105 100644 (file)
@@ -434,6 +434,31 @@ def create_vg(devices, name=None, name_prefix=None):
     return vg
 
 
+def extend_vg(vg, devices):
+    """
+    Extend a Volume Group. Command looks like::
+
+        vgextend --force --yes group_name [device, ...]
+
+    Once created the volume group is extended and returned as a ``VolumeGroup`` object
+
+    :param vg: A VolumeGroup object
+    :param devices: A list of devices to extend the VG. Optionally, a single
+                    device (as a string) can be used.
+    """
+    if not isinstance(devices, list):
+        devices = [devices]
+    process.run([
+        'vgextend',
+        '--force',
+        '--yes',
+        vg.name] + devices
+    )
+
+    vg = get_vg(vg_name=vg.name)
+    return vg
+
+
 def remove_vg(vg_name):
     """
     Removes a volume group.