I'm studying about Python scripting and testing a couple of scripts with Napalm. In my scenario, I'm access the Sandbox Router from Cisco and create the config based on file "NapalmBGP-R1.cfg. Works fine, but I try to after the user run this program, the program ask him if you can see the BGP configurations. After i digit "Yes" or anything different from Yes, the program don't display anything. Where I'm wrong?
from napalm import get_network_driver
import json
driver = get_network_driver ("ios")
device = driver(
hostname="sandbox-iosxe-recomm-1.cisco.com",
username="developer",
password="C1sco12345",
optional_args={"port": 22},
)
device.open()
print ('BGP Configuration in process...Wait')
device.load_merge_candidate(filename="NapalmBGP-R1.cfg")
device.commit_config()
print ("BGP Configuration DONE")
input("Do you like to see the BGP configuration?")
bgp_info = input()
if (bgp_info=="Yes"):
print ("Follow the BGP configuration")
output = device.get_bgp_config()
print(json.dumps(output, indent=4))
elif bgp_info != "Yes":
device.close()
print ("Done")