Fix a few more bugs

This commit is contained in:
Joshua Boniface 2019-06-19 15:32:32 -04:00
parent 97a3dafa3b
commit 3dd56c55c0
2 changed files with 19 additions and 8 deletions

View File

@ -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)

View File

@ -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: