From 3dd56c55c0878350ad675efe1575a54ce1a63915 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 19 Jun 2019 15:32:32 -0400 Subject: [PATCH] Fix a few more bugs --- client-cli/pvc.py | 2 +- client-common/ceph.py | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 93dcbd7b..ec8771c8 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -1443,7 +1443,7 @@ def ceph_volume_snapshot_remove(pool, volume, name): Remove a Ceph RBD volume with name NAME from pool POOL. """ - click.echo('DANGER: This will completely remove volume {} from pool {} and all data contained in it.'.format(name, pool)) + click.echo('DANGER: This will completely remove snapshot {} from volume {}/{} and all data contained in it.'.format(name, pool, volume)) choice = input('Are you sure you want to do this? (y/N) ') if choice == 'y' or choice == 'Y': zk_conn = pvc_common.startZKConnection(zk_host) diff --git a/client-common/ceph.py b/client-common/ceph.py index 44c9a7df..38090dc4 100644 --- a/client-common/ceph.py +++ b/client-common/ceph.py @@ -729,14 +729,16 @@ def getCephSnapshots(zk_conn, pool, volume): snapshot_list = list() volume_list = list() - if volume == 'all': - volume_list = getCephVolumes(zk_conn, pool) - else: - volume_list = [ '{}/{}'.format(pool, volume) ] + volume_list = getCephVolumes(zk_conn, pool) + if volume != 'all': + for volume_entry in volume_list: + volume_pool, volume_name = volume_entry.split('/') + if volume_name == volume: + volume_list = [ '{}/{}'.format(volume_pool, volume_name) ] - for volume_name in volume_list: - for snapshot_name in zkhandler.listchildren(zk_conn, '/ceph/snapshots/{}'.format(volume_name)): - snapshot_list.append('{}@{}'.format(volume_name, snapshot_name)) + for volume_entry in volume_list: + for snapshot_name in zkhandler.listchildren(zk_conn, '/ceph/snapshots/{}'.format(volume_entry)): + snapshot_list.append('{}@{}'.format(volume_entry, snapshot_name)) return snapshot_list @@ -1161,6 +1163,9 @@ def remove_volume(zk_conn, pool, name): def get_list_volume(zk_conn, pool, limit): volume_list = [] + if pool != 'all' and not verifyPool(zk_conn, name): + return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name) + full_volume_list = getCephVolumes(zk_conn, pool) if limit: @@ -1252,6 +1257,12 @@ def remove_snapshot(zk_conn, pool, volume, name): def get_list_snapshot(zk_conn, pool, volume, limit): snapshot_list = [] + if pool != 'all' and not verifyPool(zk_conn, pool): + return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(pool) + + if volume != 'all' and not verifyPool(zk_conn, volume): + return False, 'ERROR: No volume with name "{}" is present in the cluster.'.format(volume) + full_snapshot_list = getCephSnapshots(zk_conn, pool, volume) if limit: