genieparser
genieparser copied to clipboard
IOS-XR Issue with RPL route-policy parser
Hi,
I've just found an issue with parsing with the RPL route-policy parser. The prefix-set works fine, but this one throws an error.
Issue with the parser show rpl route-policy
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 531, in genie.conf.base.device.Device.parse
File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output
File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output
File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
File "~/coding/pyats/.venv/lib/python3.9/site-packages/genie/libs/parser/iosxr/show_rpl.py", line 529, in cli
match_level_eq = v.groupdict()['match_level_eq']
AttributeError: 'NoneType' object has no attribute 'groupdict'
100%|████████████████████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.16s/it]
Python version 3.9.6 with pyats 23.2
Hi naveci, Please let me know you are looking for the support for this issue? Please make sure to add the full logs / pyats version / package list.
Hi naveci, if you are looking for support, Please make sure to add the logs / pyats version / package list.
Hi @kameswararaot,
I'm not comfortable pasting RPLs into this comment section. What I see happening is that all RPLs are returned through PyATS. I then perform a parse of "show rpl route-policy" and this is where it then breaks with the error above.
The returned "get_parser" contains this: (<class 'genie.libs.parser.iosxr.show_rpl.ShowRplRoutePolicy'>, {}), basically meaning that it's empty. In my code, it jumps to the exception statement.
The reason is line 529 in your parser code:
match_level_eq = v.groupdict()['match_level_eq']
This value appears to be empty at the time of assignment.
The assignment of P19 is based on some conditionals. When checking the regex, it might be this part of the RPL config that it matches on:
route-policy EVPN-IN-RPL
if as-path in EVPN-AS-SET and evpn-route-type is 5 then
pass
endif
end-policy
I cannot find another matching part of the config
Hi naveci, Can you please send me the full output. Depending on that I will check the pattern.
At the same time please check the pyATS version. It should be 23.3, If not kindly update it to the latest one.
Hi naveci, Can you please send me the full output. Depending on that I will check the pattern.
At the same time please check the pyATS version. It should be 23.3, If not kindly update it to the latest one.
Please check these versions Python - 3.8 pyATS - 23.3
Hi naveci, Can you please send me the full output. Depending on that I will check the pattern.
At the same time please check the pyATS version. It should be 23.3, If not kindly update it to the latest one.
Please check these versions Python - 3.8 pyATS - 23.3
Hi naveci, Can you please send me the full output. Depending on that I will check the pattern.
At the same time please check the pyATS version. It should be 23.3, If not kindly update it to the latest one.
Please check these versions Python - 3.8 pyATS - 23.3
Hi @kameswararaot,
As mentioned before, the breaking configuration is:
route-policy EVPN-IN-RPL
if as-path in EVPN-AS-SET and evpn-route-type is 5 then
pass
endif
end-policy
I've updated to the latest PyATs version (23.3), but this hasn't fixed anything.
I don't want to share any company data on the public internet, so it took me some time to set up a test device to provide this output. I've posted the steps below where first it's a good output, then with the config above applied and then the broken output.
~/coding/pyats/src clear ✔ pyats 12:10:17
~/coding/pyats/src pyats parse "show rpl route-policy" --testbed-file testbed/static_route.yaml -v ✔ pyats 12:11:07
parser skipping argument parse
parser skipping argument show rpl route-policy
loading yaml file /Users/naveci/coding/pyats/src/testbed/static_route.yaml
parser skipping argument parse
parser skipping argument show rpl route-policy
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using the default YAML encoding key since no key was specified in configuration.
THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Credential credentials not found, trying default ...
/Users/naveci/coding/pyats/.venv/bin/pyats:8: DeprecationWarning: Connection block key 'init_exec_commands'is deprecated in Unicon v19.9. It is now specified under arguments/init_exec_commands.
sys.exit(main())
2023-04-24 12:11:10,870: %UNICON-INFO: +++ pyats-test-router01 logfile /tmp/pyats-test-router01-cli-20230424T121110869.log +++
2023-04-24 12:11:10,870: %UNICON-INFO: +++ Unicon plugin iosxr (unicon.plugins.iosxr) +++
Connection manager added new connection via cli with alias cli
<Banner
>
2023-04-24 12:11:11,718: %UNICON-INFO: +++ connection to spawn: ssh -l <company-useraccount> <router IP>, id: 4719661504 +++
2023-04-24 12:11:11,719: %UNICON-INFO: connection to pyats-test-router01
(<company-useraccount>@<router IP>)
Password: Using a default key as pyATS configuration under [secrets] string.key was not specified.
<another banner>
RP/0/RSP0/CPU0:pyats-test-router01#
2023-04-24 12:11:13,632: %UNICON-INFO: +++ initializing handle +++
0%| | 0/1 [00:00<?, ?it/s]External parser packages: []
Parser class: <class 'genie.libs.parser.iosxr.show_rpl.ShowRplRoutePolicy'> arguments: {}
Parser class: <class 'genie.libs.parser.iosxr.show_rpl.ShowRplRoutePolicy'> arguments: {}
2023-04-24 12:11:14,428: %UNICON-INFO: +++ pyats-test-router01 with via 'cli': executing command 'show rpl route-policy' +++
show rpl route-policy
Mon Apr 24 12:11:14.552 CEST
Listing for all Route Policy objects
route-policy DROP
drop
end-policy
!
route-policy PASS
pass
end-policy
!
route-policy show
end-policy
!
route-policy RP-SID($SID)
set label-index $SID
set aigp-metric igp-cost
end-policy
!
route-policy RP-PASS
pass
end-policy
!
route-policy ADD-PATH
set path-selection backup 1 install multipath-protect
end-policy
!
route-policy RP-BACKUP-PATH
set path-selection backup 1 install
end-policy
!
route-policy VRF:205:201
set community (65455:299, 65455:1001)
end-policy
!
route-policy BGP-HAB-00001-RPL
set community (65455:1001, 64500:2, 64497:1, 65455:102) additive
set local-preference 16000
set med 400
end-policy
!
route-policy RP-ALLOCATE-LABELS
if destination in PS-MY-LOOPBACK then
pass
endif
end-policy
!
route-policy RP-AS65455-CORE-IN
if destination in PS-MY-LOOPBACK then
drop
elseif destination in PS-HOST-ROUTE then
pass
endif
end-policy
!
route-policy ADD-BACKUP-PATH-RPL
set path-selection backup 1 install multipath-protect
end-policy
!
route-policy RP-AS65455-CORE-OUT
if destination in PS-MY-LOOPBACK then
pass
endif
end-policy
!
RP/0/RSP0/CPU0:pyats-test-router01#
{
'ADD-BACKUP-PATH-RPL': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
'ADD-PATH': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
'BGP-HAB-00001-RPL': {
'statements': {
10: {
'actions': {
'set_local_pref': 16000,
'set_med': 400,
},
'conditions': {
},
},
},
},
'DROP': {
'statements': {
10: {
'actions': {
'actions': 'drop',
},
'conditions': {
},
},
},
},
'PASS': {
'statements': {
10: {
'actions': {
'actions': 'pass',
},
'conditions': {
},
},
},
},
'RP-ALLOCATE-LABELS': {
'statements': {
10: {
'actions': {
'actions': 'pass',
},
'conditions': {
'match_prefix_list': 'PS-MY-LOOPBACK',
},
},
},
},
'RP-AS65455-CORE-IN': {
'statements': {
10: {
'actions': {
'actions': 'drop',
},
'conditions': {
'match_prefix_list': 'PS-MY-LOOPBACK',
},
},
20: {
'actions': {
'actions': 'pass',
},
'conditions': {
'match_prefix_list': 'PS-HOST-ROUTE',
},
},
},
},
'RP-AS65455-CORE-OUT': {
'statements': {
10: {
'actions': {
'actions': 'pass',
},
'conditions': {
'match_prefix_list': 'PS-MY-LOOPBACK',
},
},
},
},
'RP-BACKUP-PATH': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
'RP-PASS': {
'statements': {
10: {
'actions': {
'actions': 'pass',
},
'conditions': {
},
},
},
},
'RP-SID($SID)': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
'VRF:205:201': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
'show': {
'statements': {
10: {
'actions': {
},
'conditions': {
},
},
},
},
}
{
"ADD-BACKUP-PATH-RPL": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
},
"ADD-PATH": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
},
"BGP-HAB-00001-RPL": {
"statements": {
"10": {
"actions": {
"set_local_pref": 16000,
"set_med": 400
},
"conditions": {}
}
}
},
"DROP": {
"statements": {
"10": {
"actions": {
"actions": "drop"
},
"conditions": {}
}
}
},
"PASS": {
"statements": {
"10": {
"actions": {
"actions": "pass"
},
"conditions": {}
}
}
},
"RP-ALLOCATE-LABELS": {
"statements": {
"10": {
"actions": {
"actions": "pass"
},
"conditions": {
"match_prefix_list": "PS-MY-LOOPBACK"
}
}
}
},
"RP-AS65455-CORE-IN": {
"statements": {
"10": {
"actions": {
"actions": "drop"
},
"conditions": {
"match_prefix_list": "PS-MY-LOOPBACK"
}
},
"20": {
"actions": {
"actions": "pass"
},
"conditions": {
"match_prefix_list": "PS-HOST-ROUTE"
}
}
}
},
"RP-AS65455-CORE-OUT": {
"statements": {
"10": {
"actions": {
"actions": "pass"
},
"conditions": {
"match_prefix_list": "PS-MY-LOOPBACK"
}
}
}
},
"RP-BACKUP-PATH": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
},
"RP-PASS": {
"statements": {
"10": {
"actions": {
"actions": "pass"
},
"conditions": {}
}
}
},
"RP-SID($SID)": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
},
"VRF:205:201": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
},
"show": {
"statements": {
"10": {
"actions": {},
"conditions": {}
}
}
}
}
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00, 1.74s/it]
NOW WITH BROKEN CONFIG
~/coding/pyats/src pyats parse "show rpl route-policy" --testbed-file testbed/static_route.yaml -v ✔ 6s pyats 12:11:15
parser skipping argument parse
parser skipping argument show rpl route-policy
loading yaml file /Users/naveci/coding/pyats/src/testbed/static_route.yaml
parser skipping argument parse
parser skipping argument show rpl route-policy
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using the default YAML encoding key since no key was specified in configuration.
THIS IS A SHARED KEY AND IS NOT SECURE, PLEASE RUN `pyats secret keygen` AND ADD TO YOUR pyats.conf FILE BEFORE ENCODING ANY VALUES.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Credential credentials not found, trying default ...
/Users/naveci/coding/pyats/.venv/bin/pyats:8: DeprecationWarning: Connection block key 'init_exec_commands'is deprecated in Unicon v19.9. It is now specified under arguments/init_exec_commands.
sys.exit(main())
2023-04-24 12:11:40,081: %UNICON-INFO: +++ pyats-test-router01 logfile /tmp/pyats-test-router01-cli-20230424T121140080.log +++
2023-04-24 12:11:40,081: %UNICON-INFO: +++ Unicon plugin iosxr (unicon.plugins.iosxr) +++
Connection manager added new connection via cli with alias cli
< Banner >
2023-04-24 12:11:40,926: %UNICON-INFO: +++ connection to spawn: ssh -l <company-useraccount> <router IP>, id: 4530541904 +++
2023-04-24 12:11:40,926: %UNICON-INFO: connection to pyats-test-router01
(<company-useraccount>@<router IP>)
Password: Using a default key as pyATS configuration under [secrets] string.key was not specified.
<another banner>
RP/0/RSP0/CPU0:pyats-test-router01#
2023-04-24 12:11:42,703: %UNICON-INFO: +++ initializing handle +++
0%| | 0/1 [00:00<?, ?it/s]External parser packages: []
Parser class: <class 'genie.libs.parser.iosxr.show_rpl.ShowRplRoutePolicy'> arguments: {}
Parser class: <class 'genie.libs.parser.iosxr.show_rpl.ShowRplRoutePolicy'> arguments: {}
2023-04-24 12:11:43,510: %UNICON-INFO: +++ pyats-test-router01 with via 'cli': executing command 'show rpl route-policy' +++
show rpl route-policy
Mon Apr 24 12:11:43.636 CEST
Listing for all Route Policy objects
route-policy DROP
drop
end-policy
!
route-policy PASS
pass
end-policy
!
route-policy show
end-policy
!
route-policy RP-SID($SID)
set label-index $SID
set aigp-metric igp-cost
end-policy
!
route-policy RP-PASS
pass
end-policy
!
route-policy ADD-PATH
set path-selection backup 1 install multipath-protect
end-policy
!
route-policy EVPN-IN-RPL
if as-path in EVPN-AS-SET and evpn-route-type is 5 then
pass
endif
end-policy
!
route-policy RP-BACKUP-PATH
set path-selection backup 1 install
end-policy
!
route-policy VRF:205:201
set community (65455:299, 65455:1001)
end-policy
!
route-policy BGP-HAB-00001-RPL
set community (65455:1001, 64500:2, 64497:1, 65455:102) additive
set local-preference 16000
set med 400
end-policy
!
route-policy RP-ALLOCATE-LABELS
if destination in PS-MY-LOOPBACK then
pass
endif
end-policy
!
route-policy RP-AS65455-CORE-IN
if destination in PS-MY-LOOPBACK then
drop
elseif destination in PS-HOST-ROUTE then
pass
endif
end-policy
!
route-policy ADD-BACKUP-PATH-RPL
set path-selection backup 1 install multipath-protect
end-policy
!
route-policy RP-AS65455-CORE-OUT
if destination in PS-MY-LOOPBACK then
pass
endif
end-policy
!
RP/0/RSP0/CPU0:pyats-test-router01#
Issue with the parser show rpl route-policy
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 531, in genie.conf.base.device.Device.parse
File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output
File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output
File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
File "/Users/naveci/coding/pyats/.venv/lib/python3.9/site-packages/genie/libs/parser/iosxr/show_rpl.py", line 529, in cli
match_level_eq = v.groupdict()['match_level_eq']
AttributeError: 'NoneType' object has no attribute 'groupdict'
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00, 1.90s/it]
Hi naveci,
Since genieparser is community driven, I request you to contribute to the library to help fix the issue for the proposed output for IOSXR. Please let me know if you need any help during the process of PR.
The reason for the above error is due to the parser code
ther is no pattern for 'evpn-route-type'. Due to that reason it's showing Attribute error. To fix this issue support needs to be added in the iosxr file shared above.
Hi naveci,
Since genieparser is community driven, I request you to contribute to the library to help fix the issue for the proposed output for IOSXR. Please let me know if you need any help during the process of PR.
The reason for the above error is due to the parser code
ther is no pattern for 'evpn-route-type'. Due to that reason it's showing Attribute error. To fix this issue support needs to be added in the iosxr file shared above.
Hi naveci, Issue is fixed and PR merged. The parser will be release in next version.