CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error for "n*Nd" route types for IOSXE when using learn routing.

fiblund opened this issue · comments

Hi :)

First of all - Fantastic tool! :)

I have tested using pyATS to learn routing from IOSXE routers in SD-WAN mode, and I get an error for routes with the type "n*Nd".

n*Nd is a NAT default route:
n - NAT
Nd - NAT DIA

    • candidate default

Here is the traceback
(venv) ➜ pyats git:(main) ✗ more pre_change/routing_iosxe_DEBEREVOR01_exception.txt

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 "/Users/frederikfibiger-lundberg/projects/pyats/venv/lib/python3.9/site-packages/genie/libs/ops/routing/iosxe/routing.py", line 143, in learn
    self.make(final_call=True)
  File "/Users/frederikfibiger-lundberg/projects/pyats/venv/lib/python3.9/site-packages/genie/ops/base/base.py", line 103, in make
    self.maker.make(*args, **kwargs)
  File "src/genie/ops/base/maker.py", line 315, in genie.ops.base.maker.Maker.make
  File "src/genie/ops/base/maker.py", line 427, in genie.ops.base.maker.Maker._call_parser
  File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
  File "/Users/frederikfibiger-lundberg/projects/pyats/venv/lib/python3.9/site-packages/genie/libs/parser/iosxe/show_routing.py", line 50, in cli
    return parser.parse(output=out)
  File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
  File "/Users/frederikfibiger-lundberg/projects/pyats/venv/lib/python3.9/site-packages/genie/libs/parser/iosxe/show_routing.py", line 439, in cli
    route_dict['source_protocol'] = source_protocol
UnboundLocalError: local variable 'source_protocol' referenced before assignment

I have managed to fix the issue locally by adding the following code:
229: # added to support "n*Nd" route types, which are used in Cisco SD-WAN for NAT DIA routes
230: source_protocol_dict['nat_dia'] = ['n', 'Nd']

image

Hi

Can you please share the os, platform and device output for the above. It would be helpful in debugging

Of course, I should have thought about that :)

Attached the relevant files

Platform: C8300-1N1S-6T
OS: Cisco IOS XE Software, Version 17.06.03a
Cisco IOS Software [Bengaluru], c8000be Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 17.6.3a, RELEASE SOFTWARE (fc1)

(venv) ➜  egmont git:(main) ✗ pyats learn routing --testbed-file test_tb.yaml 
Enter default password for device DEBEREVOR01: 

Learning '['routing']' on devices '['DEBEREVOR01']'
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:02<00:00,  2.56s/it]
+==============================================================================+
| Genie Learn Summary for device DEBEREVOR01                                   |
+==============================================================================+
|  Connected to DEBEREVOR01                                                    |
|  -   Log: ./connection_DEBEREVOR01.txt                                       |
|------------------------------------------------------------------------------|
|  Could not learn feature 'routing'                                           |
|  -  Exception:      ./routing_iosxe_DEBEREVOR01_exception.txt                |
|  -  Ops structure:  ./routing_iosxe_DEBEREVOR01_ops.txt                      |
|  -  Device Console: ./routing_iosxe_DEBEREVOR01_console.txt                  |
|==============================================================================|

connection_DEBEREVOR01.txt
routing_iosxe_DEBEREVOR01_console.txt
routing_iosxe_DEBEREVOR01_exception.txt
routing_iosxe_DEBEREVOR01_ops.txt

Hi

Yes that fixes the problem.

Can you please contribute to the genieparser community.
All you need to do is create a PR in genieparser community and add the above changes along with the expected output and parsed output as unit test to justify your changes.

Below is the link to guide you through parser contribution,
https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html

Hi @Taarini

I've created and related the pull request :) Hoping I've filled everything out correctly - My first ever time contributing, so if there are any errors or things I could have done better/smarter, please let me know :)

Thanks for the help

Yes all good approved the PR