You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pyats/genie learn igmp fails to run due to a twofold problem.
There's an issue with the igmp parser. I have logged a separate issue including a fix, in the genieparser repo.
The codebase assumes that there is at least one VRF enabled for IGMP and that VRF has at least one IGMP enabled interface.
Example
Apply patch in 1. above to fix the first issue
run learn igmp on a device that doesn't have any IGMP enabled VRFs.
output
Issue while building the feature
Traceback (most recent call last):
File "src/genie/cli/commands/learn.py", line 365, in genie.cli.commands.learn.LearnCommand._retrieve_ops
File "/usr/local/lib/python3.12/site-packages/genie/libs/ops/igmp/iosxr/igmp.py", line 201, in learn
if 'interfaces' not in self.info['vrfs'][vrf]:
~~~~~~~~~~~~~~~~~^^^^^
KeyError: 'Internet'
Expected Behaviour
The command should parse the command output successfully and if there's a VRF that isn't enabled for IGMP it should output an empty dictionary instead.
Fix
Replace lines 198-202 with
if 'vrfs' not in self.info:
self.info['vrfs'] = {}
if vrf not in self.info['vrfs']:
self.info['vrfs'][vrf] = {}
if 'interfaces' not in self.info['vrfs'][vrf]:
self.info['vrfs'][vrf]['interfaces'] = {}
The first if statement, although not strictly necessary initialises the vrfs key if it is not already present.
The second one, initialises a nested VRF under the vrfs key, if it's not present already. This is required if a VRF is not enabled for IGMP.
The last if statement initialises the interfaces key. This again is required if a VRF is not enabled for IGMP and has no IGMP enabled interfaces.
Once the patch is applied learn igmp completes successfully and works as expected.
I have only pasted the output for the Internet VRF for brevity.
"Internet": {
"interfaces": {}
},
Let me know if you'd like me to raise a PR with this fix.
The text was updated successfully, but these errors were encountered:
Description
pyats/genie learn igmp
fails to run due to a twofold problem.Example
Apply patch in 1. above to fix the first issue
run learn igmp on a device that doesn't have any IGMP enabled VRFs.
output
Expected Behaviour
The command should parse the command output successfully and if there's a VRF that isn't enabled for IGMP it should output an empty dictionary instead.
Fix
Replace lines 198-202 with
The first
if
statement, although not strictly necessary initialises thevrfs
key if it is not already present.The second one, initialises a nested VRF under the
vrfs
key, if it's not present already. This is required if a VRF is not enabled for IGMP.The last
if
statement initialises theinterfaces
key. This again is required if a VRF is not enabled for IGMP and has no IGMP enabled interfaces.Once the patch is applied learn igmp completes successfully and works as expected.
I have only pasted the output for the
Internet
VRF for brevity.Let me know if you'd like me to raise a PR with this fix.
The text was updated successfully, but these errors were encountered: