CSV export of address information for entire network hierarchy
If you are in the IPAM view of the web interface (Data Management > IPAM) and look at a network you can get a display of all the addresses in that network and information related to those addresses, such as DNS names, MAC addresses, etc. I was working with someone who wanted to see a similar display, but for an entire set of networks under a network container at once. (For example, if you had a network container 192.168.0.0/20 with multiple subnetworks 192.168.0.0/24, 192.168.1.0/24, etc., and wanted a consolidated report on all addresses in all subnets.)
To my knowledge it's not possible to get such a consolidated display in the web interface, so I wrote a Python script to do something similar and export the resulting data as a CSV file for viewing in Excel, Google Spreadsheet, etc. See the attached script for more. Two key features of the script are as follows:
- You can specify a network container or network to export. For a network container it will export address information for all networks under the container, no matter how deeply they are nested.
- You can use a separate INI file to store your API credentials and other information needed to access the grid, in order to avoid hard-coding that information in the script or typing it in.
The script as it exists exports only a limited number of fields. One possible improvement would be to allow more fields to be exported, and provide the user running the script more control over which fields to include in the output (e.g., using a command line argument).
If you find any bugs in the script or make any enhancements to it, please let me know!