From 024e61f1736211a1442deae7ce74280c604c0db1 Mon Sep 17 00:00:00 2001 From: Prem Prakash Date: Tue, 23 Jul 2019 07:07:50 -0700 Subject: [PATCH] Fixing the expected neighbor command due to change in output format under sonic-buildimage/pull/3036 (#584) - What I did Fixed show interface neigh expected which was broken because of Azure/sonic-buildimage#3036 - How I did it There was a change in the output format for --var-json option in sonic-config-engine,changes had to be done for show commands as well. --- show/main.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/show/main.py b/show/main.py index 9f5631d038..e8a2617bf3 100755 --- a/show/main.py +++ b/show/main.py @@ -458,32 +458,32 @@ def expected(interfacename): #Swap Key and Value from interface: name to name: interface device2interface_dict = {} - for port in natsorted(neighbor_dict.keys()): + for port in natsorted(neighbor_dict['DEVICE_NEIGHBOR'].keys()): temp_port = port if get_interface_mode() == "alias": port = iface_alias_converter.name_to_alias(port) - neighbor_dict[port] = neighbor_dict.pop(temp_port) - device2interface_dict[neighbor_dict[port]['name']] = {'localPort': port, 'neighborPort': neighbor_dict[port]['port']} + neighbor_dict['DEVICE_NEIGHBOR'][port] = neighbor_dict['DEVICE_NEIGHBOR'].pop(temp_port) + device2interface_dict[neighbor_dict['DEVICE_NEIGHBOR'][port]['name']] = {'localPort': port, 'neighborPort': neighbor_dict['DEVICE_NEIGHBOR'][port]['port']} header = ['LocalPort', 'Neighbor', 'NeighborPort', 'NeighborLoopback', 'NeighborMgmt', 'NeighborType'] body = [] if interfacename: - for device in natsorted(neighbor_metadata_dict.keys()): + for device in natsorted(neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'].keys()): if device2interface_dict[device]['localPort'] == interfacename: body.append([device2interface_dict[device]['localPort'], device, device2interface_dict[device]['neighborPort'], - neighbor_metadata_dict[device]['lo_addr'], - neighbor_metadata_dict[device]['mgmt_addr'], - neighbor_metadata_dict[device]['type']]) + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['lo_addr'], + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['mgmt_addr'], + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['type']]) else: - for device in natsorted(neighbor_metadata_dict.keys()): + for device in natsorted(neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'].keys()): body.append([device2interface_dict[device]['localPort'], device, device2interface_dict[device]['neighborPort'], - neighbor_metadata_dict[device]['lo_addr'], - neighbor_metadata_dict[device]['mgmt_addr'], - neighbor_metadata_dict[device]['type']]) + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['lo_addr'], + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['mgmt_addr'], + neighbor_metadata_dict['DEVICE_NEIGHBOR_METADATA'][device]['type']]) click.echo(tabulate(body, header))