From 41bedbae3cdd5ae033603adef1bd342fdd5420ba Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Thu, 1 Nov 2018 19:55:13 -0400 Subject: [PATCH] Verify the pool exists before removing it --- client-common/ceph.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client-common/ceph.py b/client-common/ceph.py index a5cbdcb3..16fae8f5 100644 --- a/client-common/ceph.py +++ b/client-common/ceph.py @@ -41,6 +41,13 @@ def verifyOSD(zk_conn, osd_id): else: return False +# Verify Pool is valid in cluster +def verifyPool(zk_conn, name): + if zkhandler.exists(zk_conn, '/ceph/pools/{}'.format(name)): + return True + else: + return False + # Verify OSD path is valid in cluster def verifyOSDBlock(zk_conn, node, device): for osd in zkhandler.listchildren(zk_conn, '/ceph/osds'): @@ -651,6 +658,9 @@ def add_pool(zk_conn, name, pgs): return success, message def remove_pool(zk_conn, name): + if not verifyPool(zk_conn, name): + return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name) + # Tell the cluster to create a new pool remove_pool_string = 'pool_remove {}'.format(name) zkhandler.writedata(zk_conn, {'/ceph/cmd': remove_pool_string})