Use None instead of all in ceph.py

Make it like other optional args (like direction in net ACLs) and use
None instead of 'all' when specifying any option
This commit is contained in:
Joshua Boniface 2019-07-05 13:57:15 -04:00
parent e31e1264e5
commit 6ee3c91a63
2 changed files with 8 additions and 8 deletions

View File

@ -1460,7 +1460,7 @@ def ceph_volume_remove(pool, name, yes):
) )
@click.option( @click.option(
'-p', '--pool', 'pool', '-p', '--pool', 'pool',
default='all', show_default=True, default=None, show_default=True,
help='Show volumes from this pool only.' help='Show volumes from this pool only.'
) )
def ceph_volume_list(limit, pool): def ceph_volume_list(limit, pool):
@ -1549,12 +1549,12 @@ def ceph_volume_snapshot_remove(pool, volume, name, yes):
) )
@click.option( @click.option(
'-p', '--pool', 'pool', '-p', '--pool', 'pool',
default='all', show_default=True, default=None, show_default=True,
help='Show snapshots from this pool only.' help='Show snapshots from this pool only.'
) )
@click.option( @click.option(
'-p', '--volume', 'volume', '-p', '--volume', 'volume',
default='all', show_default=True, default=None, show_default=True,
help='Show snapshots from this volume only.' help='Show snapshots from this volume only.'
) )
def ceph_volume_snapshot_list(pool, volume, limit): def ceph_volume_snapshot_list(pool, volume, limit):

View File

@ -855,7 +855,7 @@ Wr: {pool_write_ops: <{pool_write_ops_length}} \
# #
def getCephVolumes(zk_conn, pool): def getCephVolumes(zk_conn, pool):
volume_list = list() volume_list = list()
if pool == 'all': if not pool:
pool_list = zkhandler.listchildren(zk_conn, '/ceph/pools') pool_list = zkhandler.listchildren(zk_conn, '/ceph/pools')
else: else:
pool_list = [ pool ] pool_list = [ pool ]
@ -944,7 +944,7 @@ def remove_volume(zk_conn, pool, name):
def get_list_volume(zk_conn, pool, limit): def get_list_volume(zk_conn, pool, limit):
volume_list = [] volume_list = []
if pool != 'all' and not verifyPool(zk_conn, name): if pool and not verifyPool(zk_conn, name):
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name) return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name)
full_volume_list = getCephVolumes(zk_conn, pool) full_volume_list = getCephVolumes(zk_conn, pool)
@ -1085,7 +1085,7 @@ def getCephSnapshots(zk_conn, pool, volume):
volume_list = list() volume_list = list()
volume_list = getCephVolumes(zk_conn, pool) volume_list = getCephVolumes(zk_conn, pool)
if volume != 'all': if volume:
for volume_entry in volume_list: for volume_entry in volume_list:
volume_pool, volume_name = volume_entry.split('/') volume_pool, volume_name = volume_entry.split('/')
if volume_name == volume: if volume_name == volume:
@ -1160,10 +1160,10 @@ def remove_snapshot(zk_conn, pool, volume, name):
def get_list_snapshot(zk_conn, pool, volume, limit): def get_list_snapshot(zk_conn, pool, volume, limit):
snapshot_list = [] snapshot_list = []
if pool != 'all' and not verifyPool(zk_conn, pool): if pool and not verifyPool(zk_conn, pool):
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(pool) return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(pool)
if volume != 'all' and not verifyPool(zk_conn, volume): if volume and not verifyPool(zk_conn, volume):
return False, 'ERROR: No volume with name "{}" is present in the cluster.'.format(volume) return False, 'ERROR: No volume with name "{}" is present in the cluster.'.format(volume)
full_snapshot_list = getCephSnapshots(zk_conn, pool, volume) full_snapshot_list = getCephSnapshots(zk_conn, pool, volume)