DNAC-Acess-interface-count

The objective of this script is to get the status of Gigabit all user interfaces in the DNA-C infrastructure.
The script is hard-coded to get only equipement with "Access" role.

Use Case Description

My company moved to a new building, which made the team lose track of how many interfaces were being used. Hence, the objective of the script is to easily confirm which switches have available interfaces, without having to check for each device. Besides that, we could avoid spreadsheets that were being used for documentation, that were not always kept up to date.

Requirements

The following libraries are used in this script:

  • pip install requests
  • pip install regex
  • pip install dnacentersdk
  • pip install prettytable

The librarie connect_dnac is a second file used to store the username/password/dna-c ip address

Cisco DNA-C SandBox URL: https://sandboxdnac.cisco.com

capture2

DevNet Sandbox

  • Always-On Cisco DNA Center
  • Version: 1.3.1.6

Credentials and further detail about the Lab environment available at: https://devnetsandbox.cisco.com/

Configuration

The script has two files: connect_dnac.py and get_interfaces.py
connect_dnac.py contains the : dna url, username and password

Before running the script, the credentials of the DNA-C must be changed.

connect_dna

Usage

After updating the credentials on the connect_dnac.py, run the get_interfaces.py

Here is the test using the DevNet Sandbox.

Obs:

The reason why it shows only interfaces down on the sandbox it's because the hosts are connected using the 'TenGigabit" interfaces, but we are only checking for 'Gigabit'.

The code that filters by GigabitEthernet

image

The result:

image

If the script is changed to look for TenGigabitEthernet

image

The following output can be observed:

image

Next Steps

The primary goal was achieved and it suits the team's needs at the moment. However, the script can be enhanced by applying the programmed next features:

  • Gathering all interfaces and displays by the types on the table;
  • User selection by Device role, such as Access, Border and/or Core.

Thank you!

I'd like to thank you for taking the time to check out my project. I'm open to all suggestions and hope that this can be useful to other teams as well.
Thanks!

Guilherme Gianotto Bratfish
guilhermebrat@gmail.com

published

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.