Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOS-XR] learn igmp fails to run #186

Open
geortich opened this issue Jan 30, 2025 · 0 comments
Open

[IOS-XR] learn igmp fails to run #186

geortich opened this issue Jan 30, 2025 · 0 comments

Comments

@geortich
Copy link

Description

pyats/genie learn igmp fails to run due to a twofold problem.

  1. There's an issue with the igmp parser. I have logged a separate issue including a fix, in the genieparser repo.
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant