01-20-2022 12:29 PM
I am looking into writing a script that will make vlan port changes on a Nexus 9k series switch. I'm looking to use snmp to facilitate this but I've been unable to find any documentation to help me figure out how to go about it. I am hoping someone here can point me in the right direction.
01-20-2022 05:39 PM
Hi
Best way is using Python, Expect or Ansible. Here a very simples script I wrote in Expect. Basicaly what it does is access a device, execute a command, grab de output and leave.
You can adapt according to your needs.
#!/usr/bin/expect set router "x.x.x.x" set username "user" set password "pass" set port "22" spawn ssh -p $port $router match_max 100000000 set timeout 6 expect "(yes/no)?" { send "yes\r"; exp_continue } expect User: send -- "$username\r" expect Password: send -- "$password\r" expect > send -- "terminal lengh 0\r" send -- "sh run | i snmp\r" log_file "show_snmp.txt" send "logout\r" expect "(y/N)" send -- "n\r" expect eof
01-20-2022 06:00 PM
Baron,
Using SNMP to make config changes is not the way to go.. Flavio is correct in the programming languages but did not mention netconf. You may want to check out the 9k program guide.
01-20-2022 06:04 PM
in addition to @Flavio Miranda ....i am exploring some stuff with Python: may below help you :
https://developer.cisco.com/docs/nx-os/#!interface-module/interface-class
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: