s_update_interface_desc

s_update_interface_desc.script_main(session, prompt_check_mode=True, check_mode=True, enable_pass=None)
SINGLE device script
Author: Jamie Caesar

This script will grab the detailed CDP information from a Cisco IOS or NX-OS device and port-channel information and generate the commands to update interface descriptions. The user will be prompted to run in “Check Mode” which will write the configuration changes to a file (for verification or later manual application). If not, then the script will push the configuration commands to the device and save the configuration.

Script Settings (found in settings/settings.ini):

  • strip_domains - A list of domain names that will be stripped away if found in
    the CDP remote device name.
  • take_backups - If True, the script will save a copy of the running config before
    and after making changes.
  • rollback_file - If True, the script will generate a rollback configuration script
    and save it to a file.
Parameters:
  • session (sessions.Session) – A subclass of the sessions.Session object that represents this particular script session (either SecureCRTSession or DirectSession)
  • prompt_check_mode (bool) – A boolean that specifies if we should prompt the user to find out if we should run in “check mode”. We would make this False if we were using this function in a multi-device script, so that the process can run continually without prompting the user at each device.
  • check_mode (bool) – A boolean to specify whether we should run in “check mode” (Generate what the script would do only – does not push config), or not (Pushes the changes to the device). The default is True for safety reasons, and this option will be overwritten unless prompt_checkmode is False.
  • enable_pass (str) – The enable password for the device. Will be passed to start_cisco_session method if available.
s_update_interface_desc.extract_cdp_data(cdp_table)

Extract only remote host and interface for each local interface in the CDP table

Parameters:cdp_table (list of list) – The TextFSM output for CDP neighbor detail
Returns:A dictionary for each local interface with corresponding remote host and interface.
Return type:dict
s_update_interface_desc.add_port_channels(desc_data, pc_data)

Adds port-channel information to our CDP data so that we can also put descriptions on port-channel interfaces that have members found in the CDP table.

Parameters:
  • desc_data – Our CDP description data that needs to be updated
  • pc_data
Type:

pc_data: