cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
501
Views
10
Helpful
3
Replies

Need help scripting config changes via snmp on Nexus 9k

baron164
Level 1
Level 1

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.

3 Replies 3

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

keibler09
Level 1
Level 1

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.  

https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/programmability/guide/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x/b_Cisco_Nexus_9000_Series_NX-OS_Programmability_Guide_7x_chapter_010101.html

balaji.bandi
Hall of Fame
Hall of Fame

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

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Getting Started

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:

Review Cisco Networking products for a $25 gift card