Use genie parser on text files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2021 09:29 AM
Hello everyone,
is there a possibility to use the genie parser on output saved in text files?
The issue is that that it is not possible to install pyATS or genie on the machine where I can access the devices. What I can do is get the output of "show ip interface" save that to a text file and have genie parse that file on my machine.
I could use the NTC TextFSM parser, but wanted to know and learn if it is possible to use genie offline, so to say.
Thank you very much.
Kind regards,
Petrit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2021 02:54 PM - edited 05-14-2021 02:57 PM
Hello,
You can use the pyats-genie-command-parse library as follows
from pyats_genie_command_parse import GenieCommandParse parse_obj = GenieCommandParse(nos='ios') data = parse_obj.parse_file(show_command='show version', file_name_and_path='./show_version.txt') print(data)
This is a library to be able to parse NOS command output using the available Genie parsers, it seperates out needing to create a testbed.yml, and allows you to just get the output, and parse the output with Genie parsers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2021 07:46 PM
Hi,
I tried using this "pyats_genie_command_parse", seems that some command works some didn't...Eg. are "show interfaces GigabitEthernet2/0/3 counters" or "show authentication sessions interface GigabitEthernet2/0/48 details" (to see NAC session in switchport).
These command always throw an exception. Did I miss something? Seems that those with an interface name have this issue...
ModuleNotFoundError: Could not find module_name for command show interfaces xxx counters for nos iosxe from genie: cli() missing 1 required positional argument: 'interface'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 12:43 AM
@petritberisha @choywy Were you able to implement genie offline?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 02:43 AM
from pyats.topology import loader
tb = loader.load("testbed.yaml")
device = tb.devices[hostname]
Hostname from your testbed.yaml file
parsed_result = device.parse(command, output=output)
Where output is the output of the command, a string
