From d12899ed02e60e185f744312f8eeb499a60458af Mon Sep 17 00:00:00 2001 From: Travis Prescott Date: Fri, 3 Feb 2017 08:20:29 -0800 Subject: [PATCH] Fixes #1860. (#1971) --- .../cli/command_modules/network/_format.py | 18 ++++++++++++++++++ .../cli/command_modules/network/commands.py | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_format.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_format.py index b8ed5654794..18667355660 100644 --- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_format.py +++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_format.py @@ -40,6 +40,24 @@ def transform_dns_record_set_table_output(result): table_output.append(table_row) return table_output +def transform_dns_zone_table_output(result): + is_list = isinstance(result, list) + + if not is_list: + result = [result] + + final_result = [] + for item in result: + new_item = OrderedDict([ + ('ZoneName', item['name']), + ('ResourceGroup', item['resourceGroup']), + ('RecordSets', item['numberOfRecordSets']), + ('MaxRecordSets', item['maxNumberOfRecordSets']) + ]) + final_result.append(new_item) + + return final_result if is_list else final_result[0] + def transform_local_gateway_table_output(result): final_result = [] for item in result: diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py index 9b43791e47e..88e2438ab57 100644 --- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py +++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py @@ -14,7 +14,7 @@ delete_network_resource_property_entry) from ._format import \ (transform_local_gateway_table_output, transform_dns_record_set_output, - transform_dns_record_set_table_output) + transform_dns_record_set_table_output, transform_dns_zone_table_output) custom_path = 'azure.cli.command_modules.network.custom#{}' @@ -402,9 +402,9 @@ def _make_singular(value): custom_function_op=custom_path.format('update_traffic_manager_endpoint')) # DNS ZonesOperations -cli_command(__name__, 'network dns zone show', 'azure.mgmt.dns.operations.zones_operations#ZonesOperations.get', cf_dns_mgmt_zones) +cli_command(__name__, 'network dns zone show', 'azure.mgmt.dns.operations.zones_operations#ZonesOperations.get', cf_dns_mgmt_zones, table_transformer=transform_dns_zone_table_output) cli_command(__name__, 'network dns zone delete', 'azure.mgmt.dns.operations.zones_operations#ZonesOperations.delete', cf_dns_mgmt_zones, confirmation=True) -cli_command(__name__, 'network dns zone list', custom_path.format('list_dns_zones')) +cli_command(__name__, 'network dns zone list', custom_path.format('list_dns_zones'), table_transformer=transform_dns_zone_table_output) cli_generic_update_command(__name__, 'network dns zone update', 'azure.mgmt.dns.operations.zones_operations#ZonesOperations.get', 'azure.mgmt.dns.operations.zones_operations#ZonesOperations.create_or_update',