此映像是要配置的路由器的GNS3的图表。试图备份思科路由器的配置。但是连接没有打开。
from napalm import *
import napalm
drivers = napalm.get_network_driver('ios')
device_detail = {'hostname':'192.168.1.2','username':'wahid','password':'wahid'}
router = drivers(**device_detail)
router.open()
#The problem is here <- Exception has occurred: ValueError
#Failed to enter enable mode. Please ensure you pass the 'secret' argument to #ConnectHandler.
print('Connection is Opened with ->{}'.format(device_detail['hostname']))
config = router.get_config()
print('Configuratin on this {} router ->'.format(device_detail['hostname']))发布于 2022-08-16 16:32:51
你能试一试如下:
from napalm import get_network_driver
from getpass import getpass
hostname = input("IP address of router: ")
username = input(f"Username of {hostname}: ")
password = getpass(f"Password of {hostname}")
secret = getpass(f"Enable password of {hostname}: ")
driver = get_network_driver("ios")
device_detail = {
"hostname": hostname,
"username": username,
"password": password,
"optional_args": {
"secret": secret
}
}
with driver(**device_detail) as router:
print(router.get_facts())https://stackoverflow.com/questions/73031189
复制相似问题