From: Andrew Schoen Date: Thu, 18 Jan 2018 17:10:15 +0000 (-0600) Subject: ceph-volume: adds an api.lvm.remove_pv method X-Git-Tag: wip-pdonnell-testing-20180317.202121~496^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0811c02b118c270b2bec87cd26a877b26bc780b1;p=ceph-ci.git ceph-volume: adds an api.lvm.remove_pv method Used to remove physical volumes 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 3931442072e..a88daa7082f 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -233,6 +233,28 @@ def remove_vg(vg_name): return True +def remove_pv(pv_name): + """ + Removes a physical volume. + + Will return True if the pv is successfully removed or + raises a RuntimeError if the removal fails. + """ + stdout, stderr, returncode = process.call( + [ + 'pvremove', + '-v', # verbose + '-f', # force it + pv_name + ], + show_command=True, + terminal_verbose=True, + ) + if returncode != 0: + raise RuntimeError("Unable to remove vg %s".format(pv_name)) + return True + + def remove_lv(path): """ Removes a logical volume given it's absolute path.