Skip to content

Commit

Permalink
Fix for KeyError: 'DEVICE_NEIGHBOR' when executing 'show interfaces n…
Browse files Browse the repository at this point in the history
…eighbor expected' command (sonic-net#456)
  • Loading branch information
ramachandrareddygaddam authored and jleveque committed Feb 27, 2019
1 parent d409987 commit 84aafb6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,19 @@ def expected(interfacename):
"""Show expected neighbor information by interfaces"""
neighbor_cmd = 'sonic-cfggen -d --var-json "DEVICE_NEIGHBOR"'
p1 = subprocess.Popen(neighbor_cmd, shell=True, stdout=subprocess.PIPE)
neighbor_dict = json.loads(p1.stdout.read())
try :
neighbor_dict = json.loads(p1.stdout.read())
except ValueError:
print("DEVICE_NEIGHBOR information is not present.")
return

neighbor_metadata_cmd = 'sonic-cfggen -d --var-json "DEVICE_NEIGHBOR_METADATA"'
p2 = subprocess.Popen(neighbor_metadata_cmd, shell=True, stdout=subprocess.PIPE)
neighbor_metadata_dict = json.loads(p2.stdout.read())
try :
neighbor_metadata_dict = json.loads(p2.stdout.read())
except ValueError:
print("DEVICE_NEIGHBOR_METADATA information is not present.")
return

#Swap Key and Value from interface: name to name: interface
device2interface_dict = {}
Expand Down

0 comments on commit 84aafb6

Please sign in to comment.