From: Andrew Schoen Date: Wed, 17 Jan 2018 19:12:17 +0000 (-0600) Subject: ceph-volume: adds an api.lvm.remove_vg method X-Git-Tag: v12.2.3~79^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3002953e4f506850339c676a85dc5402def7423d;p=ceph.git ceph-volume: adds an api.lvm.remove_vg method This method can be used to remove volume groups Signed-off-by: Andrew Schoen (cherry picked from commit 50a6a543a956d133b428cf36ad629c2131be5490) --- diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index b39a71d1d255b..1c3566b4ad364 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -213,6 +213,28 @@ def create_vg(name, *devices): return vg +def remove_vg(vg_name): + """ + Removes a volume group. + + Will return True if the vg is successfully removed or + raises a RuntimeError if the removal fails. + """ + stdout, stderr, returncode = process.call( + [ + 'vgremove', + '-v', # verbose + '-f', # force it + vg_name + ], + show_command=True, + terminal_verbose=True, + ) + if returncode != 0: + raise RuntimeError("Unable to remove vg %s".format(vg_name)) + return True + + def remove_lv(path): """ Removes a logical volume given it's absolute path.