Oct-24-2020, 10:54 PM
I was able to get this to work. Prompts for IP Address and switchport number. Not as elegant as automatically running for all "up" interfaces, but it will have to do for now. I'll keep playing and learning with loops.
I added the global delay of 7 seconds to wait between the running of the "test cable tdr int x" and the "show cable tdr int x".
Maybe this will help someone down the road.
Well, back to reading more on python loops and nested loops.
Cheers!
#!/usr/bin/env python
from netmiko import Netmiko
from netmiko import ConnectHandler
import time
import re
ipaddr = input ('Enter the IP: ')
interface = input ('Enter the switchport number to be tested: ')
cisco = {
'device_type': 'cisco_ios',
'host': ipaddr,
'username': 'cisco',
'password': 'cisco',
'timeout': 35 * 60,
'global_delay_factor': 7,
}
net_connect = ConnectHandler(**cisco)
output1 = net_connect.send_command('test cable tdr int ' + interface)
output2 = net_connect.send_command('sh cable tdr int ' + interface)
print()
print('TDR TEST RESULTS FOR INTERFACE: ')
print()
print(output2)
I added the global delay of 7 seconds to wait between the running of the "test cable tdr int x" and the "show cable tdr int x".
Maybe this will help someone down the road.
Well, back to reading more on python loops and nested loops.
Cheers!
#!/usr/bin/env python
from netmiko import Netmiko
from netmiko import ConnectHandler
import time
import re
ipaddr = input ('Enter the IP: ')
interface = input ('Enter the switchport number to be tested: ')
cisco = {
'device_type': 'cisco_ios',
'host': ipaddr,
'username': 'cisco',
'password': 'cisco',
'timeout': 35 * 60,
'global_delay_factor': 7,
}
net_connect = ConnectHandler(**cisco)
output1 = net_connect.send_command('test cable tdr int ' + interface)
output2 = net_connect.send_command('sh cable tdr int ' + interface)
print()
print('TDR TEST RESULTS FOR INTERFACE: ')
print()
print(output2)