genieparser
genieparser copied to clipboard
[IOS-XE] issue with command : show ip bgp vpnv4 vrf VRF-NAME
Hello, I installed pyats[library] + genie + pyats-genie-command-parse 1.3.9 on ubuntu 20.04 I use it on .txt files as explained at the url : https://community.cisco.com/t5/controllers/use-genie-parser-on-text-files/m-p/4588903 I run it on pycharm so I can correct my mistakes easily. I have seen the available list of parser for os at the url : https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers My installation works very well for the command : show ip route vrf VRF-NAME But even though the command "show ip bgp vpnv4 vrf VRF-NAME" is listed as supported at the above url of supported parsers (n.b. for os = 'iosxe') it does not work.
I keep having the following error : pyats_genie_command_parse.py", line 168, in __parse raise ModuleNotFoundError(f'Could not find module_name for command {show_command} ' ModuleNotFoundError: Could not find module_name for command show ip bgp vpnv4 vrf MPLS for nos iosxe from genie: local variable 'original_address_family' referenced before assignment. In order to provide complete technical context : I run pyats-genie-command-parse 1.3.9 and I upgraded genie pyats library to 24.2 before running the script.
The full script I run in pycharm is : from pyats_genie_command_parse import GenieCommandParse import json
parse_obj = GenieCommandParse(nos='iosxe') address_family = "vpnv4" vrf = "MPLS" test = f'show ip bgp {address_family} vrf {vrf}' print(f'show ip bgp {address_family} vrf {vrf}') data = parse_obj.parse_file(show_command=f'show ip bgp {address_family} vrf {vrf}', file_name_and_path='./PE_R1_show_ip_bgp_vpnv4_vrf_MPLS.txt') with open("json_line.txt", "a") as j: print(data, file=j) with open("json_indented.txt", "a") as i: print('\n', json.dumps(data, indent=2), file=i)
and the file PE_R1_show_ip_bgp_vpnv4_vrf_MPLS.txt is :
PE-R1#show ip bgp vpnv4 vrf MPLS BGP table version is 19, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, L long-lived-stale, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path Route Distinguisher: 1:1 (default for vrf MPLS) *>i 4.4.4.4/32 3.3.3.3 20 100 0 ? *> 5.5.5.5/32 10.0.15.5 0 0 55 ? r> 10.0.15.0/24 10.0.15.5 0 0 55 ? *>i 10.0.34.0/24 3.3.3.3 0 100 0 ? *>i 172.44.0.0/24 3.3.3.3 20 100 0 ? *>i 172.44.10.0/24 3.3.3.3 20 100 0 ? *>i 172.44.20.0/24 3.3.3.3 20 100 0 ? *>i 172.44.30.0/24 3.3.3.3 20 100 0 ? *> 172.55.0.0/24 10.0.15.5 0 0 55 ? *> 172.55.10.0/24 10.0.15.5 0 0 55 ? *> 172.55.20.0/24 10.0.15.5 0 0 55 ? *> 172.55.30.0/24 10.0.15.5 0 0 55 ? PE-R1#
The full result I get when I run the script in pycharm is :
/home/thibault/PycharmProjects/test-genie-parser/venv/bin/python /home/thibault/PycharmProjects/test-g-parser/main.py show ip bgp vpnv4 vrf MPLS Traceback (most recent call last): File "/home/thibault/PycharmProjects/test-genie-parser/venv/lib/python3.8/site-packages/pyats_genie_command_parse/pyats_genie_command_parse.py", line 165, in __parse return found_parser(device=mock_device).parse() File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse File "/home/thibault/PycharmProjects/test-genie-parser/venv/lib/python3.8/site-packages/genie/libs/parser/iosxe/show_bgp.py", line 766, in cli return super().cli(output=show_output, vrf=vrf, File "/home/thibault/PycharmProjects/test-genie-parser/venv/lib/python3.8/site-packages/genie/libs/parser/iosxe/show_bgp.py", line 529, in cli new_address_family = original_address_family + ' RD ' + route_distinguisher UnboundLocalError: local variable 'original_address_family' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/thibault/PycharmProjects/test-g-parser/main.py", line 9, in
Process finished with exit code 1
Did someone saw this parser work on that command ? Can someone investigate the reason for this issue ? I can provide extra information if needed to clarify any point, best Regards
Hi,
Kindly give me some time I will check and get beck to you.
Thank you
Certainly, I am curious to find out what is happening :-)
Hi,
I have received the output and have not observed any errors. Please use the code provided below and include any necessary details and reproduce the issue.
Output:
{'vrf': {'MPLS': {'address_family': {'vpnv4 RD 1:1': {'bgp_table_version': 19, 'route_identifier': '1.1.1.1', 'route_distinguisher': '1:1', 'default_vrf': 'MPLS'}}}}}
from pyats.topology.loader import load
testbed = """
devices:
device_name:
os: 'iosxe'
custom:
abstraction:
order: [os]
connections:
defaults:
class: unicon.Unicon
a:
ip: x.x.x.x
port: xx
protocol: telnet
"""
testbed = load(testbed)
dev = testbed.devices['device_name']
print(dev.parse("show ip bgp vpnv4 vrf MPLS"))
Hi,
I have received the output and have not observed any errors. Please use the code provided below and include any necessary details and reproduce the issue.
Output:
{'vrf': {'MPLS': {'address_family': {'vpnv4 RD 1:1': {'bgp_table_version': 19, 'route_identifier': '1.1.1.1', 'route_distinguisher': '1:1', 'default_vrf': 'MPLS'}}}}}
from pyats.topology.loader import load
testbed = """
devices:
device_name:
os: 'iosxe'
custom:
abstraction:
order: [os]
connections:
defaults:
class: unicon.Unicon
a:
ip: x.x.x.x
port: xx
protocol: telnet
"""
testbed = load(testbed)
dev = testbed.devices['device_name']
print(dev.parse("show ip bgp vpnv4 vrf MPLS"))
Hi,
I have received the output and have not observed any errors. Please use the code provided below and include any necessary details and reproduce the issue.
Output:
{'vrf': {'MPLS': {'address_family': {'vpnv4 RD 1:1': {'bgp_table_version': 19, 'route_identifier': '1.1.1.1', 'route_distinguisher': '1:1', 'default_vrf': 'MPLS'}}}}}
from pyats.topology.loader import load
testbed = """
devices:
device_name:
os: 'iosxe'
custom:
abstraction:
order: [os]
connections:
defaults:
class: unicon.Unicon
a:
ip: x.x.x.x
port: xx
protocol: telnet
"""
testbed = load(testbed)
dev = testbed.devices['device_name']
print(dev.parse("show ip bgp vpnv4 vrf MPLS"))
Hello,Thanks for your reply, give me some time to test your way of testing it, it's different than mine since I remark your using pyats while I'm using pyats_genie_command_parse.py(which has to be installed on top of pyats) so it's a different way to test the same software, I think. But I will test is as soon as I can I'll keep you posted Best Regards Thibault
Le mardi 2 avril 2024 à 16:03:34 UTC+2, Harishv ***@***.***> a écrit :
Hi,
I have received the output and have not observed any errors. Please use the code provided below and include any necessary details and reproduce the issue.
Output:
{'vrf': {'MPLS': {'address_family': {'vpnv4 RD 1:1': {'bgp_table_version': 19, 'route_identifier': '1.1.1.1', 'route_distinguisher': '1:1', 'default_vrf': 'MPLS'}}}}} from pyats.topology.loader import load
testbed = """
devices:
device_name:
os: 'iosxe'
custom:
abstraction:
order: [os]
connections:
defaults:
class: unicon.Unicon
a:
ip: x.x.x.x
port: xx
protocol: telnet
"""
testbed = load(testbed)
dev = testbed.devices['device_name']
print(dev.parse("show ip bgp vpnv4 vrf MPLS"))
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Hi, Could you please provide an update on the above if you have tested it?
Hello, I had some time to look into your email and I think there is a misunderstanding. So first let me tell you what I'm trying to do really,but may be haven't I been clear engouh so far. What am I trying to do : -> I'm trying to parse the output of a CLI command captured in a .txt fileand to parse it into a json dictionary structure (in a file) so that afterwords it will be easier to compare with a Python script I will make.That script will compare the output of a command issued AFTER a migration, with the result of that same command BEFORE the migration operation in a production network to assess what's new, what's lacking, what has changed etc. In fact the final purpose of all of that is to verify the result of a migration operation, if the routing table or BGP table has not lost updatesor some updates have changed next-hop, or new updates have appeared etc. In the production network there are so many routes/updates thatcomparing with the eye before and after is tedious (1000+ routes/updates)so the script will highlight missing updates/routes, new updates/routes, modifiedupdates/routes and unchanged updates/routes by producing 4 .txt file listing respectively the missing updates/routes, new updates/routes, modifiedupdates/routes and unchanged updates/routes.. So analysing the result of the script with the files it produces (i.e missing_updates.txt, etc.), will enable me to check QUICKLY if the migration operation went fine as expected, or not. The thing is that my script will not run on a PC that is ALLOWEDto connect to the production network.I can only log in a remote desktop which is also connected to the production network on which I can use Putty to connect to the device and log outputs in a .txt file, hence my need to parse a command from a .txt file. So trying to achieve that, a google search lead me to those links :https://community.cisco.com/t5/controllers/use-genie-parser-on-text-files/td-p/4394183https://pyats-genie-command-parse.readthedocs.io/en/latest/doc-source/directions/file-parse.htmlexplaining how to parse Cisco commands from an output .txt file. The method explained in those links require, on top of pyats[library]the installation of pyats-genie-command-parse as explained in the following link :https://pypi.org/project/pyats-genie-command-parse/ That method works very well with show ip route vrf, but not with show ip bgp vpnv4 vrf VRF I mentioned the .txt file I'm trying to parse in the github issue. I understand you want to use pyats querying a live network either a production network which I can't, either a simulation network in pyats which I haven't setup. In fact if you have read until here I never used pyats for testingbut only what is shown in the links above and in the github issue I createdonly to parse CLI commands from outputs in .txt files. I'm curious so I will try some day, but since I do it on top of my job I do it when I can, I would have to create a testbed yaml description of the labI never did. I used a CML 2.7 lab to create the network, I could send youthe CML 2.7 configuration file (i.e export) of the network to produce the outputso if you have a CML 2.7 (the lab uses the just CML 2.7 released IOL node) you couldeasily reproduce the lab and test in pyats if you can. At the time being since I do not have the network simulated, in fact I made the CML 2.7 tests as a beta tester on dCloud, but the beta tests are over I don't haveCML 2.7 yet. But when I can I will try to setup a simulation network and use pyats (which I never did) to see if your method works. Now be aware also that shoud your method work,it wouldn't even reach my goal which is to parse .txt filesbecause for my application my PC is NOT ALLOWED to connect to the network live. Thanks, I hope it is clearer now, I hope we will be able to move forward this issue even if it is by disjointed time slots, best regards Thibault Le mardi 2 avril 2024 à 16:03:34 UTC+2, Harishv @.***> a écrit :
Hi,
I have received the output and have not observed any errors. Please use the code provided below and include any necessary details and reproduce the issue.
Output:
{'vrf': {'MPLS': {'address_family': {'vpnv4 RD 1:1': {'bgp_table_version': 19, 'route_identifier': '1.1.1.1', 'route_distinguisher': '1:1', 'default_vrf': 'MPLS'}}}}} from pyats.topology.loader import load
testbed = """
devices:
device_name:
os: 'iosxe'
custom:
abstraction:
order: [os]
connections:
defaults:
class: unicon.Unicon
a:
ip: x.x.x.x
port: xx
protocol: telnet
"""
testbed = load(testbed)
dev = testbed.devices['device_name']
print(dev.parse("show ip bgp vpnv4 vrf MPLS"))
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Hi,
Please update pyats-genie-command-parse to version 1.3.10 and if you encounter any issues, reach out to the repository owner of the pyats-genie-command-parse package. It's a third-party package not owned by Cisco.
Could you please provide an update on the above
Could you please provide an update on the above
Thank you
Hello, For your information before opening the case, I was in pyats-genie-command-parse 1.3.8 the problem was occurringin the end I decided to open an issue.But before that I wanted to do my homework and make sure the issue was still present in the current version, that's why I upgraded pyats to the then current version and pyats-genie-command-parse 1.3.9, I reproduced the problem and openned the issue. Now you suggest me to upgrade to the next version, why not, but have you seen anything related to the problem in the changelog of pyats-genie-command-parse 1.3.10 ? Otherwise, I could spend my life upgrading but if no one makes a correction about the problem nothing would change... Anyway, as I told you I will go on on this when I have time. Besause I think CLI parsing is very important in Network Automation hence in networks as a whole. Best Regards Thibault Le jeudi 18 avril 2024 à 19:02:30 UTC+2, Harishv @.***> a écrit :
Could you please provide an update on the above
Thank you
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
In version 1.3.9, pyats version 23.10 was used, but in version 1.3.10, the pyats version has been updated to the latest, which is 24.3. Therefore, we are not encountering this issue in the latest pyats version
In version 1.3.9, pyats version 23.10 was used, but in version 1.3.10, the pyats version has been updated to the latest, which is 24.3. Therefore, we are not encountering this issue in the latest pyats version
Thank you
Could you please provide an update on this issue?
Thank you.
Hello,Sorry no, I really can't I'm leaving 3 week s on holiday and I'm busy finishing my work before. I'll let you know Best Regards Thibault Le jeudi 25 avril 2024 à 17:45:50 UTC+2, Harishv @.***> a écrit :
Could you please provide an update on this issue?
Thank you.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
once you are back Could you please provide an update on this issue?
Thank you.
If you are back.Could you please provide an update on this issue?
Thank you.
If you are back.Could you please provide an update on this issue?
Thank you.
Could you please provide an update on this issue?
Thank you.
Hi,
I haven't received any update on the issue. Hence, I am closing it. If you see any issue related to pyats, kindly raise a new ticket.
Thank you.
Hello, I've just finished a brand new installation on ubuntu 22.04 with pyATS full installed and pyats-genie-command-parse 1.3.10and the issue is still there. show ip route vrf VRF-NAME works just fine as it always did with pyats-genie-command-parse butshow ip bpg vpnv4 vrf VRF-NAME produces the same tracebacks ModuleNotFoundError: Could not find module_name for command show ip bgp vpnv4 MPLS for nos iosxe from genie I assume this is not a pyATS issue but instead a pyats-genie-command-parse.Too bad. Best Regards Thibault
Le mercredi 22 mai 2024 à 11:22:15 UTC+2, Harishv ***@***.***> a écrit :
Closed #831 as completed.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>