I would like help in this Script here, i am totally new in Python, just want to know if you guys have any Idea, why this script below works good only with routers and switches, for ASA and WLC 5500 and 9800 it don't works.
This is the script:
from netmiko import (
ConnectHandler,
NetmikoTimeoutException,
NetmikoAuthenticationException,
)
from netmiko.ssh_autodetect import SSHDetect
from netmiko.ssh_dispatcher import ConnectHandler
import getpass
import os
import time
import sys
import subprocess
import logging
import re
password = getpass.getpass()
username = os.getlogin()
devices = []
with open('devices.txt') as routers:
for i in routers:
RR = {
"device_type": "autodetect",
"host": i,
"username": ('admin_' + username),
"password": password,
}
print (f'admin_{username} is connecting to the Device: {i}')
try:
connect = ConnectHandler(**RR)
guesser = SSHDetect(**RR)
best_match = guesser.autodetect()
print("="*100)
print(connect.find_prompt() + ':' + best_match)
print("="*100)
configs = []
with open('commands.txt') as configu:
for c in configu:
output = connect.send_command(c)
print(c)
print(output)
print("-"*50)
except (NetmikoTimeoutException, NetmikoAuthenticationException) as error:
print ('!!!ERROR!!! The admin_' + username + ' COULD NOT CONNECT ON ' + i)
print(error)
continue
connect.disconnect()
Tried to run this script in WLC and ASA.
Appreciate any help : )
Thanks