diff options
author | Christian Breunig <christian@breunig.cc> | 2023-01-21 09:22:43 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-01-21 09:23:07 +0100 |
commit | a55dcaee83b0966bc9564e0a7996b6e1b4e922a6 (patch) | |
tree | c390d3ffa1d14ce6126ac1df41ed62474751ae30 /src/op_mode | |
parent | 9b99f22df3f00715108b462bb66c8f4c9c502528 (diff) | |
download | vyos-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/op_mode')
-rwxr-xr-x | src/op_mode/lldp.py | 4 |
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']: |