summaryrefslogtreecommitdiff
path: root/src/op_mode/lldp.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/op_mode/lldp.py')
-rwxr-xr-xsrc/op_mode/lldp.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/op_mode/lldp.py b/src/op_mode/lldp.py
index dc2b1e0b5..1a1b94783 100755
--- a/src/op_mode/lldp.py
+++ b/src/op_mode/lldp.py
@@ -61,7 +61,14 @@ def _get_raw_data(interface=None, detail=False):
def _get_formatted_output(raw_data):
data_entries = []
- for neighbor in dict_search('lldp.interface', raw_data):
+ tmp = dict_search('lldp.interface', raw_data)
+ if not tmp:
+ return None
+ # 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 = []
@@ -80,6 +87,10 @@ def _get_formatted_output(raw_data):
# Capabilities
cap = ''
capabilities = jmespath.search('chassis.[*][0][0].capability', values)
+ # One can not always ensure that "capability" is of type list, add
+ # safeguard. E.G. Unify US-24-250W only has a dict, not a list of dicts
+ if isinstance(capabilities, dict):
+ capabilities = [capabilities]
if capabilities:
for capability in capabilities:
if capability['enabled']: