Template for downloading CSV of connections between devices and/or patch panels #17386
-
Hi there team, I've got a site which we administer through netbox which is relatively complex in terms of cable paths from device A to device B. Usually, there are two devices linked by 4-5 different cables across four different patch panels. What I wanted was to be able to download a cable route from device A to device B with each hop clearly marked in CSV format. Basically, I want the cable trace feature in CSV format for all connections originating in a specific rack? Anyway, how best would I be able to go about this as its not immediately clear within netbox how I can ask it to do that for me. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Most flexible would be to query from the REST API and write your own code to format however you like. If you want to do this within Netbox then you could create an export template. The method
Note that you get a list of three-tuples here, each element of which of which has a list of terminations or cables (one cable can connect to multiple components at each end), so it's not exactly ideal for CSV representation. You'd need to do some jinja2 munging to make it some sort of acceptable format, and that's pretty ugly. But a starting point would be something like this (briefly tested): this is an export template on "Interface", so you'd have to go to Interfaces and filter to the interface(s) of interest.
Sample output:
An alternative would be to make it an export template on Device, and then iterate over the interfaces on each device. If you can turn it into something useful, you might want to submit a completed version of this to the customizations repo. |
Beta Was this translation helpful? Give feedback.
Most flexible would be to query from the REST API and write your own code to format however you like.
If you want to do this within Netbox then you could create an export template. The method
trace()
on an interface gives you a list of the path elements. You can exercise this in nbshell.Note that you get a list of three-tuples here, each element of which of which has a list of terminations or cables…