network_info_scripts
network_info_scripts copied to clipboard
Not an issue - just a question
Hi Hank!
I am beginning my journey with Python/Network Automation and I am a big fan of your content.
I've been doing the interactive coding of your interface_report_interactive.py script and I wanted to convert it to a CDP Neighbors report.
I am stuck at this point:
for interface, details in interfaces.items(): writer.writerow({"Interface": interface, "MAC Address": details["mac_address"]})
I don't know where to find equivalents of interface, details["mac_address"] keys for CDP index keys.
What I want to achieve is to get the script to loop through the entire index of neighbors and put them all in CSV table with the following headers (local_hostname, local_port, neighbor_port, neighbor_name, neighbor_platform).
Sample parse below:
"index": { "1": { "advertisement_ver": 2, "capabilities": "Router Switch IGMP", "device_id": "UK-RDG-CSW-01.wiecaszek.com", "duplex_mode": "full", "entry_addresses": { "10.0.100.1": {} }, "hold_time": 144, "local_interface": "GigabitEthernet0/10", "management_addresses": { "10.0.100.1": {} }, "native_vlan": "1", "platform": "cisco WS-C3750G-24PS", "port_id": "GigabitEthernet1/0/24", "software_version": "Cisco IOS Software, C3750 Software (C3750-IPSERVICESK9-M), Version 15.0(1)SE, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Wed 20-Jul-11 09:32 by prod_rel_team", "vtp_management_domain": "FLAT" }, "2": { "advertisement_ver": 2, "capabilities": "Trans-Bridge Source-Route-Bridge IGMP", "device_id": "UK-RDG-AP-02.flat3.com", "duplex_mode": "full", "entry_addresses": { "10.0.100.8": {}, "FE80::5257:A8FF:FE30:930": { "type": "link-local" } }, "hold_time": 162, "local_interface": "GigabitEthernet0/8", "management_addresses": { "10.0.100.8": {} }, "native_vlan": "", "platform": "cisco AIR-AP1142N-E-K9", "port_id": "GigabitEthernet0", "software_version": "Cisco IOS Software, C1140 Software (C1140-K9W7-M), Version 15.3(3)JB, RELEASE SOFTWARE (fc2)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2015 by Cisco Systems, Inc.\nCompiled Wed 29-Apr-15 17:37 by prod_rel_team", "vtp_management_domain": "" } }, "total_entries_displayed": 2
I'd appreciate it if you could point me towards a resource that can resolve my problem.
I hope it makes sense :)
Thanks!