jamiecaesar / securecrt-tools

SecureCRT scripts, written in Python, for doing various tasks when connected to Cisco equipment.
Apache License 2.0
246 stars 78 forks source link

update session.py #37

Closed tylersiemers closed 5 years ago

tylersiemers commented 5 years ago

Added support to recognize XR, lines 570 added IOS to show version. Certain XR platforms output multiple lines for the keyword Cisco, the output can be hundreds of lines to match on. Example, "iosxr-mcast, V 6.4.1[Default], Cisco Systems, at disk0:iosxr-mcast-6.4.1". Added "IOS" to slim down return string on XR. Lines 586-587. Added elif to catch IOS XR and return as IOS OS.

jamiecaesar commented 5 years ago

Changing the command to "show version | i Cisco IOS" I'm pretty sure is going to break NXOS checks, because we won't get any output from its show version that way. Also NXOS would require quotes around "Cisco IOS" so we'd also get a syntax error issuing that, which is a second reason why I think NXOS will break if I merge in that change.

Also, we need a new version tag ("IOS XR" probably), instead of just using "IOS". IOS XE has the exact same command set and outputs as regular IOS so I haven't had a reason to differentiate it, but I'm nearly positive we'll have to for XR. The reason is because many of the scripts will say "if session.os == 'IOS':" and choose the TextFSM template to parse the output for that OS. Since IOS XR probably has a different output format then regular IOS, we'd have to be able to select a different template to parse the outputs. Document_device doesn't do this because it only writes outputs to file, but many of the others do, and I'm trying to keep those in mind.

On the plus side, a co-worker who is familiar with EVE spun up an XR image in our lab, so I'll see if I can't get into an XR device tonight and make some updates, and then have you test against a real system for me. I'll be sure to tweak the document_device script to handle XR as well since that seems to be the one you were using initially.

tylersiemers commented 5 years ago

Perfect. I think a new instance for XR would be awesome. Thanks

jamiecaesar commented 5 years ago

Pull the latest ios-xr branch and give it a try. I've tested that it still works with all the existing OSs, but I haven't tried it against an XR device yet (have to sync up with someone to get access).

tylersiemers commented 5 years ago

I"ll give a try more at the office, but it failed at line 67. of the s_documents

image

jamiecaesar commented 5 years ago

Make sure you completely quit and re-open SecureCRT. It seems to cache the imports that are called from scripts, so anytime I change anything in the securecrt_tools module folder you have to completely restart SecureCRT for them to take effect.

jamiecaesar commented 5 years ago

And I just made another small change.

tylersiemers commented 5 years ago

Works great. I'll look at running some of the other scripts. Just made one change to the s_document_device.py in the IOS-XR branch. Thanks

jamiecaesar commented 5 years ago

Glad to hear it. I've merged that pull request. Any of the other scripts that process output to produce a file in a different format will probably require a decent amount of work, but it will be great to get them working. I'm going to close this pull request, since we solved this differently.