s_switchport_mapping

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

This script will first prompt for the location of the ARP table to use for processing. Next, the mac address table of the active session will be captured and a CSV file showing the MAC address and IP of what is attached to each port on the device will be output.

Parameters:session (sessions.Session) – A subclass of the sessions.Session object that represents this particular script session (either SecureCRTSession or DirectSession)
s_switchport_mapping.get_int_status(session)

A function that captures the “show interface status” command and returns the processed output from TextFSM

Parameters:session (sessions.Session) – The script object that represents this script being executed
Returns:TextFSM output from processing the “show interface status” command
Return type:list of list
s_switchport_mapping.get_mac_table(session)

A function that captures the mac address table and returns an output dictionary that can be used to look up the MAC address and VLAN associated with an interface.

Parameters:session (session.Session) – The script object that represents this script being executed
Returns:A dictionary that allows lookups of MAC and VLAN information for interfaces
Return type:dict
s_switchport_mapping.get_desc_table(session)

A function that creates a lookup dictionary that can be used to get the description of an interface.

Parameters:session (sessions.Session) – The script object that represents this script being executed
Returns:A dictionary that allows getting the description of an interface by using the interface as the key.
Return type:dict
s_switchport_mapping.get_arp_info(script)

A function that reads in the “show ip arp” CSV file that should be taken from the default gateway device for the switch being port mapped, so we can fill in the correct IP addresses for each device.

Parameters:script (scripts.Script) – The script object that represents this script being executed
Returns:A dictionary that can be used to lookup both the MAC and IP associated with an interface, or the IP and VLAN associated with a MAC address.
Return type:dict
s_switchport_mapping.mac_to_vendor(mac_lookup_table, mac)

Lookup MAC Vendor Info

Parameters:mac – MAC address to Lookup Vendor Info on
Returns:MAC Vendor