]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add reduce_vg function
authorMohamad Gebai <mgebai@suse.com>
Sun, 31 Mar 2019 17:04:40 +0000 (13:04 -0400)
committerJan Fajerski <jfajerski@suse.com>
Tue, 29 Oct 2019 16:36:02 +0000 (17:36 +0100)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
(cherry picked from commit ce0184b5d7f24f2b3b6a9491e0f3c1c847b8c0e7)

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

index 4b2b4f783dc9f3b3e38255bf1ab6ce6f3158f15e..2ab0d529b5251bf89f1518efe09dfdb1d6304be4 100644 (file)
@@ -470,6 +470,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.