]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume: add reduce_vg function
authorMohamad Gebai <mgebai@suse.com>
Sun, 31 Mar 2019 17:04:40 +0000 (13:04 -0400)
committerMohamad Gebai <mgebai@suse.com>
Fri, 12 Apr 2019 16:54:07 +0000 (12:54 -0400)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
src/ceph-volume/ceph_volume/api/lvm.py

index ca05035b0bd16d5d82b72cea3702445478722cb5..e96725b7193a7026d85914f44bbba317aa6ea5ec 100644 (file)
@@ -464,6 +464,29 @@ def extend_vg(vg, devices):
     return vg
 
 
+def reduce_vg(vg, devices):
+    """
+    Reduce a Volume Group. Command looks like::
+
+        vgreduce --force --yes group_name [device, ...]
+
+    :param vg: A VolumeGroup object
+    :param devices: A list of devices to remove from the VG. Optionally, a
+                    single device (as a string) can be used.
+    """
+    if not isinstance(devices, list):
+        devices = [devices]
+    process.run([
+        'vgreduce',
+        '--force',
+        '--yes',
+        vg.name] + devices
+    )
+
+    vg = get_vg(vg_name=vg.name)
+    return vg
+
+
 def remove_vg(vg_name):
     """
     Removes a volume group.