Always handle single-instance results

This commit is contained in:
Joshua Boniface 2020-01-05 02:55:28 -05:00
parent 065ba29c84
commit 44753c0609
4 changed files with 16 additions and 4 deletions

View File

@ -356,7 +356,7 @@ def format_list_osd(osd_list):
if not osd_list: if not osd_list:
osd_list = list() osd_list = list()
# Handle single-item list # Handle single-item list
if isinstance(osd_list, dict): if not isinstance(osd_list, list):
osd_list = [ osd_list ] osd_list = [ osd_list ]
osd_list_output = [] osd_list_output = []
@ -709,7 +709,7 @@ def format_list_pool(pool_list):
if not pool_list: if not pool_list:
pool_list = list() pool_list = list()
# Handle single-entry list # Handle single-entry list
if isinstance(pool_list, dict): if not isinstance(pool_list, list):
pool_list = [ pool_list ] pool_list = [ pool_list ]
pool_list_output = [] pool_list_output = []
@ -1079,7 +1079,7 @@ def format_list_volume(volume_list):
if not volume_list: if not volume_list:
volume_list = list() volume_list = list()
# Handle single-entry list # Handle single-entry list
if isinstance(volume_list, dict): if not isinstance(volume_list, list):
volume_list = [ volume_list ] volume_list = [ volume_list ]
volume_list_output = [] volume_list_output = []
@ -1338,7 +1338,7 @@ def format_list_snapshot(snapshot_list):
if not snapshot_list: if not snapshot_list:
snapshot_list = list() snapshot_list = list()
# Handle single-entry list # Handle single-entry list
if isinstance(snapshot_list, dict): if not isinstance(snapshot_list, list):
snapshot_list = [ snapshot_list ] snapshot_list = [ snapshot_list ]
snapshot_list_output = [] snapshot_list_output = []

View File

@ -538,6 +538,10 @@ def format_list(config, network_list):
click.echo("No network found") click.echo("No network found")
return return
# Handle single-element lists
if not isinstance(network_list, list):
network_list = [ network_list ]
network_list_output = [] network_list_output = []
# Determine optimal column widths # Determine optimal column widths

View File

@ -214,6 +214,10 @@ def format_info(node_information, long_output):
click.echo('') click.echo('')
def format_list(node_list): def format_list(node_list):
# Handle single-element lists
if not isinstance(node_list, list):
node_list = [ node_list ]
node_list_output = [] node_list_output = []
# Determine optimal column widths # Determine optimal column widths

View File

@ -448,6 +448,10 @@ def follow_console_log(config, vm, lines=10):
# Output display functions # Output display functions
# #
def format_info(config, domain_information, long_output): def format_info(config, domain_information, long_output):
# Handle single-element lists
if not isinstance(domain_information, list):
domain_information = [ domain_information ]
# Format a nice output; do this line-by-line then concat the elements at the end # Format a nice output; do this line-by-line then concat the elements at the end
ainformation = [] ainformation = []
ainformation.append('{}Virtual machine information:{}'.format(ansiprint.bold(), ansiprint.end())) ainformation.append('{}Virtual machine information:{}'.format(ansiprint.bold(), ansiprint.end()))