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: wip-pdonnell-testing-20180317.202121~496^2~11 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=50a6a543a956d133b428cf36ad629c2131be5490;p=ceph-ci.git ceph-volume: adds an api.lvm.remove_vg method This method can be used to remove volume groups Signed-off-by: Andrew Schoen --- diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index b39a71d1d25..1c3566b4ad3 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.