Create tshoottest.py

This commit is contained in:
theNetworkChuck 2019-12-19 11:00:41 -06:00 committed by GitHub
parent 3427c283da
commit 8e6a320db2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

38
tshoottest.py Normal file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env python
from netmiko import Netmiko
username = "networkchuck"
password = "Password123!"
access1 = {
"host": "10.16.0.11",
"username": username,
"password": password,
"device_type": "cisco_ios",
}
flswitch = {
"host": "10.16.20.10",
"username": username,
"password": password,
"device_type": "cisco_ios",
}
myswitches = [flswitch, access1]
for x in myswitches:
net_connect = Netmiko(**x)
ping = net_connect.send_command("show mac address-table address 0050.7966.6802", use_textfsm=True)
showver = net_connect.send_command("show version", use_textfsm=True)
hostname = showver[0]['hostname']
try:
thehost = ping[0]['destination_address']
except TypeError:
thehost = "nope"
if thehost != "nope":
print("The host is connected to " + hostname)
print("done")