Dynamically update your interface name via port auto-description

Overview: Port auto-description will dynamically update the port description based on the LLDP information received from the neighbour. As always we are looking for your feedback please let us know if you have ideas on how to improve this script or other ideas…

The tool: The script, called ‘portAuto’, will dynamically change the port description based on the neighbour’s LLDP information. This could be used as a stand alone script or part of a larger toolset.

How to get the code:

Installation: In order to install this extension perform the following steps:

  • copy ‘portAuto’ to /mnt/flash
  • enable the Command API interface, in configuration mode issue the following commands

(config)# management api http-commands
(config-mgmt-api-http-cmds)# no shutdown

  • change SWITCH_IP, USERNAME and PASSWORD at the top of the script to the ones appropriate for your installation. If running locally on the switch, you can use ‘127.0.0.1’ for the IP

Using the tool: You can utilize the script in any of the following ways:

  • Execute directly from bash (from the switch, or a remote switch/server running Python):

(bash)# /mnt/flash/portAuto

  • Configure an alias on the switch:

(config)# alias portAuto bash /mnt/flash/portAuto

  • Schedule a job on the switch – run portAuto every 12 hours with Event Scheduler:

(config)# schedule portAuto interval 720 max-log-files 0 command bash sudo /mnt/flash/portAuto

  • Run at switch boot time by adding the following startup:

(config)# event-handler portAutoDescription
(config-handler-portAutoDescription)# trigger on-boot
(config-handler-portAutoDescription)# action bash /mnt/flash/portAuto
(config-handler-portAutoDescription)# asynchronous
(config-handler-portAutoDescription)# exit

Disclaimer: This script is built using Arista eAPI thus requiring EOS 4.12 or later.

The code – time to Git it