From ce0184b5d7f24f2b3b6a9491e0f3c1c847b8c0e7 Mon Sep 17 00:00:00 2001 From: Mohamad Gebai Date: Sun, 31 Mar 2019 13:04:40 -0400 Subject: [PATCH] ceph-volume: add reduce_vg function Signed-off-by: Mohamad Gebai --- src/ceph-volume/ceph_volume/api/lvm.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index ca05035b0bd..e96725b7193 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -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. -- 2.39.5