summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-01-22 08:20:10 +0100
committerChristian Breunig <christian@breunig.cc>2023-01-22 08:20:10 +0100
commit33c3a02729ae95a8173f902cddd039c17262fbcb (patch)
tree73d18dc9b74683696e5c9110e2bc4e54d2871abb /src/op_mode
parent275ea7303cfdb79c042da1b710622aee17a488a8 (diff)
downloadvyos-1x-33c3a02729ae95a8173f902cddd039c17262fbcb.tar.gz
vyos-1x-33c3a02729ae95a8173f902cddd039c17262fbcb.zip
T4911: op-mode: bugfix AttributeError: 'str' object has no attribute 'items'
One can not always ensure that "interface" is of type list, add safeguard. E.G. Juniper Networks, Inc. ex2300-c-12t only has a dict, not a list of dicts So this is actually an upstream lldpd bug where the output depends on the amount of data transmitted.
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/lldp.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/op_mode/lldp.py b/src/op_mode/lldp.py
index bfcb8f8c7..1a1b94783 100755
--- a/src/op_mode/lldp.py
+++ b/src/op_mode/lldp.py
@@ -64,7 +64,11 @@ def _get_formatted_output(raw_data):
tmp = dict_search('lldp.interface', raw_data)
if not tmp:
return None
- for neighbor in dict_search('lldp.interface', raw_data):
+ # One can not always ensure that "interface" is of type list, add safeguard.
+ # E.G. Juniper Networks, Inc. ex2300-c-12t only has a dict, not a list of dicts
+ if isinstance(tmp, dict):
+ tmp = [tmp]
+ for neighbor in tmp:
for local_if, values in neighbor.items():
tmp = []