cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

2888
Views
0
Helpful
5
Replies
RichardAtkin
Participant

Programmatic way to Shut/No Shut Interface?

I have a modern network with DNAC and Cat 9k switches.  Given a static list of IPs , I'm trying to find a programmatic way of bouncing the interfaces those devices are connected to.

 

I know how to query DNAC with a Client's IP and have it return the Switch & Switchport the Client is connected to, but I can't work out how, either via DNAC or via Netconf to the Switch, to bounce the interface (ie, "Shutdown" followed shortly by "No Shutdown" in CLI terms).

 

Are there any examples of how to achieve this?  Or suggestions of the best approach?  It seems quite basic and I'm surprised I can't find any examples of how to bounce a port.

 

Thanks!

5 REPLIES 5
balaji.bandi
VIP Guru

Not sure what is the end goal you looking to achieve. But here is simple Linux script with expect command :

 

here is example script : (you can do many things :)

 

http://www.balajibandi.com/?s=expect

BB

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

How to Ask The Cisco Community for Help

Thanks for the suggestion, but error handling with an ‘automated SSH’ approach like that is difficult. I also have hundreds of interfaces that I need to bounce and this approach would take quite some time to execute... I’m really looking for a more purely programmatic answer.

Any other suggestions? Thanks!

If you looking to Build one, you need to list what you like to achieve, based on the post you looking for bounce the ports, so i have suggested the method to do the same.

 

if you looking if the ports gone disabled - this bit tricky, not that its not possible, - some time you need to investigate whu this ports gone error disabled ?

 

on programming point of view. send all the logs to syslog server - capture the logs, trigger the script.

 

you can send me personal message if you like more to do frame work we can discuss. (this is my favourite topic) self healing with out engineer intervention.

 

BB

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

How to Ask The Cisco Community for Help

robmccarty
Beginner

How are you getting the data from DNAC? Is it something you can work with easily (JSON, XML, etc)? Does it include the IP of the switch the hosts are on?

 

You could write something in python to take that and restconf the ports up/down

 

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/166/b_166_programmability_cg/restconf_prog_int.html

 

 

Tagir Temirgaliyev
Frequent Contributor

can be solved with bash and ansible

Create
Recognize Your Peers
Content for Community-Ad