s_create_sessions_from_cdp

s_create_sessions_from_cdp.script_main(session)
SINGLE device script
Author: Jamie Caesar

This script will grab the detailed CDP information from a Cisco IOS or NX-OS device and create SecureCRT sessions based on the information. By default all sessions will be created as SSH2, so you may have to manually change some sessions to make them work, depending on the device capabilities/configuration.

Only devices that contain “Router” or “Switch” in their capabilities field of the CDP information will have sessions created for them. This skips phones, hosts like VMware or Server modules, and other devices that we don’t usually log into directly).

NOTE ON DEFAULTS: This script uses the SecureCRT Default Session settings as a base for any sessions that are created. The folder where the sessions are saved is specified in the ‘settings.ini’ file, and the hostname and IP are extracted from the CDP information. All other setting defaults are configured within SecureCRT.

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

  • folder - The path starting from the <SecureCRT Config>/Sessions/ directory where
    the sessions will be created.
  • strip_domains - A list of domain names that will be stripped away if found in the CDP remote device name.
Parameters:session (sessions.Session) – A subclass of the sessions.Session object that represents this particular script session (either SecureCRTSession or DirectSession)
s_create_sessions_from_cdp.create_session_list(cdp_list)

This function takes the TextFSM output of the CDP information and uses it to create a list of new SecureCRT sessions to create (system name and IP address).

Parameters:cdp_list (list) – The TextFSM output after processing the “show cdp neighbor detail” output
Returns:A list (system name and IP address) of the sessions that need to be created.
Return type:list