From fc46f70153bdae560e6d279137a59896a30907a3 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 5 Apr 2017 17:24:40 -0400 Subject: [PATCH] Closes #430: Include circuits when rendering topology maps --- netbox/extras/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox/extras/models.py b/netbox/extras/models.py index d45eac4cb..7d9c8d43d 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -318,6 +318,7 @@ class TopologyMap(models.Model): def render(self, img_format='png'): + from circuits.models import CircuitTermination from dcim.models import Device, InterfaceConnection # Construct the graph @@ -352,7 +353,7 @@ class TopologyMap(models.Model): for query in device_set.split(';'): # Split regexes on semicolons device_superset = device_superset | Q(name__regex=query) - # Add all connections to the graph + # Add all interface connections to the graph devices = Device.objects.filter(*(device_superset,)) connections = InterfaceConnection.objects.filter( interface_a__device__in=devices, interface_b__device__in=devices @@ -360,6 +361,12 @@ class TopologyMap(models.Model): for c in connections: graph.edge(c.interface_a.device.name, c.interface_b.device.name) + # Add all circuits to the graph + for termination in CircuitTermination.objects.filter(term_side='A', interface__device__in=devices): + peer_termination = termination.get_peer_termination() + if peer_termination is not None and peer_termination.interface.device in devices: + graph.edge(termination.interface.device.name, peer_termination.interface.device.name, color='blue') + return graph.pipe(format=img_format)