You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from netmiko import ConnectHandler
from textfsm import TextFSM
from pprint import pprint
with open ('Devices.txt') as Devices:
for IP in Devices:
Device = {
'device_type': 'cisco_ios',
'ip' : IP,
'username': 'user',
'password': 'password'
}
net_connect = ConnectHandler(**Device)
print ('Connecting to ' + IP)
print ('-'*80)
output = net_connect.send_command('show snmp user', use_textfsm=True)
for i in output:
if i["authentication_protocol"] == "SHA":
print ( IP + 'Has the correct SNMP encryption settings')
else:
print (IP + "Does not have the correct SNMP encryption settings")
pprint ( output )
output2 = net_connect.send_command('show vtp status', use_textfsm=True)
for i in output2:
if i["mode"] == 'Off' :
print (IP + 'Has the correct VTP settings')
else:
print (IP + 'Does not have the correct VTP settings' )
# print (output2)
net_connect.disconnect()
So that is my current script. I am basically using netmiko and TextFSM to check certain things in a config to see if they are complaint. I am using the TextFSM NTC templates. One thing I noticed for the Cisco IOS templates, there is nothing for a show running config to use with TextFSM. There are a lot of things I check by doing a show run and verifying.
Is there a way with netmiko that I can search a running config for a certain text string and then print wheather or not that is in the running config or not? Simliar to what I am doing with the 2 ntc templates i used in the script above? Have the ability to do if else statements based on the strings i find? Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So that is my current script. I am basically using netmiko and TextFSM to check certain things in a config to see if they are complaint. I am using the TextFSM NTC templates. One thing I noticed for the Cisco IOS templates, there is nothing for a show running config to use with TextFSM. There are a lot of things I check by doing a show run and verifying.
https://github.com/networktocode/ntc-templates/tree/master/ntc_templates/templates
Is there a way with netmiko that I can search a running config for a certain text string and then print wheather or not that is in the running config or not? Simliar to what I am doing with the 2 ntc templates i used in the script above? Have the ability to do if else statements based on the strings i find? Thanks
Beta Was this translation helpful? Give feedback.
All reactions