Python scripts designed to assist network engineers working with NX-OS devices. The primary focus is on enhancing the visibility and manageability of Cisco Discovery Protocol (CDP) information while working with NX-OS CLI; i.e., via console or ssh.
resize
commands to your preference.
# Disable guestshell to resize allocations guestshell disable y # Resize guestshell allocations guestshell resize cpu 10 guestshell resize mem 2048 guestshell resize rootfs 2000 guestshell enable
NOTE: Steps 2-5 are to be ran straight from NX-OS CLI. To run within guestshell, enter guestshell
in NX-OS CLI and then run the commands without "guestshell run".
Set up DNS for guestshell and test DNS ping.
guestshell run sudo sh -c 'echo nameserver 9.9.9.9 > /etc/resolv.conf'
guestshell run sudo chvrf management ping -c4 google.com
Update guestshell & add dependencies, the yum update
process may take a while.
guestshell run sudo chvrf management yum -y update guestshell run sudo chvrf management yum -y install git guestshell run sudo chvrf management pip3 install natsort
Clone repository.
guestshell run sudo chvrf management git clone https://github.com/derek-shnosh/nxos-cdp-helpers.git /bootflash/scripts/nxos-cdp-helpers/
Remove guestshell DNS config (security measure).
guestshell run sudo sh -c 'echo "" > /etc/resolv.conf'
Create CLI aliases to run the scripts.
cli alias name cdpbr guestshell run python /bootflash/scripts/nxos-cdp-helpers/python/nxos-cdp-brief.py cli alias name cdpdesc guestshell run python /bootflash/scripts/nxos-cdp-helpers/python/nxos-cdp-describe.py -i
Copy the scripts to the switch.
copy <source>/nxos-cdp-brief.py bootflash:scripts/ copy <source>/nxos-cdp-describe.py bootflash:scripts/
Create CLI aliases to run the scripts.
cli alias name cdpbr python /bootflash/scripts/nxos-cdp-brief.py cli alias name cdpdesc python /bootflash/scripts/nxos-cdp-describe.py -i
nxos-cdp-brief.py
This script generates a custom CDP neighbor brief table that displays the local interface for each neighbor, along with the neighbor hostname, connecting interface, IP address (mgmt preferred), and optionally their platform and software version.
natsort
module to sort neighbors by interface in a human-readable order. If natsort
is not installed, a lexicographical sort is performed (see the natsort
PyPI page for elaboration).-p
and -v
arguments.-p
): Neighbor's platform or model (optional).-v
): Neighbor's software/firmware version (optional).# CDP brief output
cdpbr
nxos-cdp-describe.py
This script will rename interfaces based on the CDP information present, formatted as HOSTNAME:INTF
. For example, if NX-OS interface Eth1/3 has a neighbor entry for IDF-1-ACCESS that is uplinkd using its Te1/1/1 interface, the description would be IDF-1-ACCESS:1/1/1
# CDP describe, single interface cpdesc Eth1/3 # CDP describe, all interfaces cdpdesc all
This project is licensed under the MIT License - see the LICENSE file for details.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community