From cf98b6971ced0caa29ff4f7ac346df652177fa29 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 18 Oct 2017 10:19:00 -0500 Subject: [PATCH] ceph-volume: adds a remove_lv command to the lvm api Signed-off-by: Andrew Schoen --- src/ceph-volume/ceph_volume/api/lvm.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 05f6cb2f07b5c..8b824f5da586f 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -213,6 +213,25 @@ def create_vg(name, *devices): return vg +def remove_lv(path): + """ + Removes a logical volume given it's absolute path. + """ + stdout, stderr, returncode = process.call( + [ + 'sudo', + 'lvremove', + '-v', # verbose + '-f', # force it + path + ], + show_command=True, + terminal_verbose=True, + ) + if returncode != 0: + raise RuntimeError("Unable to remove %s".format(path)) + + def create_lv(name, group, size=None, tags=None): """ Create a Logical Volume in a Volume Group. Command looks like:: -- 2.39.5