From 2a42491c65bc49bbcd7ecd86ca61878dde5dc73d Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Thu, 18 Jan 2018 11:10:15 -0600 Subject: [PATCH] ceph-volume: adds an api.lvm.remove_pv method Used to remove physical volumes Signed-off-by: Andrew Schoen (cherry picked from commit 0811c02b118c270b2bec87cd26a877b26bc780b1) --- src/ceph-volume/ceph_volume/api/lvm.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 3931442072ea..a88daa7082f5 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. -- 2.47.3