cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5071
Views
6
Helpful
3
Replies

Use genie parser on text files

petritberisha
Level 1
Level 1

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

 

3 Replies 3

AriBejarano
Level 1
Level 1

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.

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'

alalina
Cisco Employee
Cisco Employee

@petritberisha @choywy Were you able to implement genie offline?