this image is the diagram for GNS3 of routers want to configure尝试备份 Cisco 路由器的配置。但连接未打开。
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']))
最佳答案
你能不能试一下:
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())
关于python - 支持思科路由器,使用 NAPALM,使用 SSH 远程登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73031189/