summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-01-21 09:22:43 +0100
committerChristian Breunig <christian@breunig.cc>2023-01-21 09:23:07 +0100
commita55dcaee83b0966bc9564e0a7996b6e1b4e922a6 (patch)
treec390d3ffa1d14ce6126ac1df41ed62474751ae30 /src
parent9b99f22df3f00715108b462bb66c8f4c9c502528 (diff)
downloadvyos-1x-a55dcaee83b0966bc9564e0a7996b6e1b4e922a6.tar.gz
vyos-1x-a55dcaee83b0966bc9564e0a7996b6e1b4e922a6.zip
T4911: op-mode: bugfix TypeError: string indices must be integers
One can not always ensure that "capability" is of type list, add a safeguard. E.G. Unify US-24-250W only has a dict, not a list of dicts.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/lldp.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/op_mode/lldp.py b/src/op_mode/lldp.py
index dc2b1e0b5..c815ffcd4 100755
--- a/src/op_mode/lldp.py
+++ b/src/op_mode/lldp.py
@@ -80,6 +80,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']: