]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds an api.lvm.remove_pv method
authorAndrew Schoen <aschoen@redhat.com>
Thu, 18 Jan 2018 17:10:15 +0000 (11:10 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 18 Jan 2018 17:12:31 +0000 (11:12 -0600)
Used to remove physical volumes

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 3931442072eae00303d3d998143c32a2429c0d42..a88daa7082f56c8ced415bf91e3762dfa8e63870 100644 (file)
@@ -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.