任何人都可以建议我如何在 python 上使用 gns3 Api

问题描述 投票:0回答:0

我用过cisco DevNet Sandbox。我在使用 napalm 模块 python 时遇到错误。当我尝试使用正确的凭据进行身份验证时,它总是告诉我身份验证失败。那么我可以在 python 上使用 Gns3 Api 来解决这个关于 Cisco DevNet 实验室的问题吗?

import napalm
import json

# CSR1000V
cisco_sandbox = {
   "hostname": " sandbox-iosxe-recomm-1.cisco.com",
   "port": 22,
   "username": "developer",
   "password": " C1sco12345",
}

NXOS = "nxos"
IOS = "ios"
NXOS_SSH = "nxos_ssh"

driver = napalm.get_network_driver(IOS)
if driver:
   connection = driver(
     hostname=cisco_sandbox["hostname"],
     username=cisco_sandbox["username"],
     password=cisco_sandbox["password"]
   )
else:
    connection = driver(
            hostname=cisco_sandbox["hostname"],
            username=cisco_sandbox["username"],
            password=cisco_sandbox["password"],
            optional_args={"port": cisco_sandbox["port"]}
        )

connection.open()
print(f"----- Connecting {cisco_sandbox['hostname']} on port {cisco_sandbox['port']}")
print(
    f"----- Device Facts:\n\t{json.dumps(connection.get_facts(), indent=4)}")
connection.close()
python networking sandbox cisco napalm
© www.soinside.com 2019 - 2024. All rights reserved.