]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds an api.lvm.remove_vg method
authorAndrew Schoen <aschoen@redhat.com>
Wed, 17 Jan 2018 19:12:17 +0000 (13:12 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 18 Jan 2018 17:12:30 +0000 (11:12 -0600)
This method can be used to remove volume groups

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

index b39a71d1d255b70bbb7f82f0625fd5ac991998fe..1c3566b4ad36453ac002f149f544f4dd608d89ae 100644 (file)
@@ -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.