diff --git a/netbox/dcim/migrations/0071_auto_20190612_1730.py b/netbox/dcim/migrations/0071_auto_20190612_1730.py new file mode 100644 index 000000000..cbcc406ae --- /dev/null +++ b/netbox/dcim/migrations/0071_auto_20190612_1730.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.2 on 2019-06-12 17:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0070_auto_20190612_1801'), + ] + + operations = [ + migrations.AlterField( + model_name='interface', + name='_connected_circuittermination', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='circuits.CircuitTermination'), + ), + ] diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 19306c7de..7541726b2 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -1949,7 +1949,6 @@ class Interface(CableTermination, ComponentModel): _connected_circuittermination = models.ForeignKey( to='circuits.CircuitTermination', on_delete=models.SET_NULL, - related_name='+', blank=True, null=True ) diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 8d8a05e10..356ba2978 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -533,27 +533,20 @@ class TopologyMap(models.Model): def add_network_connections(self, devices): - from circuits.models import CircuitTermination from dcim.models import Interface # Add all interface connections to the graph - connected_interfaces = Interface.objects.select_related( - '_connected_interface__device' - ).filter( - Q(device__in=devices) | Q(_connected_interface__device__in=devices), - _connected_interface__isnull=False, - pk__lt=F('_connected_interface') - ) + connected_interfaces = Interface.objects.exclude(cable=None) + seen = set() for interface in connected_interfaces: + if interface in seen: + continue style = 'solid' if interface.connection_status == CONNECTION_STATUS_CONNECTED else 'dashed' - self.graph.edge(interface.device.name, interface.connected_endpoint.device.name, style=style) - - # Add all circuits to the graph - for termination in CircuitTermination.objects.filter(term_side='A', connected_endpoint__device__in=devices): - peer_termination = termination.get_peer_termination() - if (peer_termination is not None and peer_termination.interface is not None and - peer_termination.interface.device in devices): - self.graph.edge(termination.interface.device.name, peer_termination.interface.device.name, color='blue') + trace = interface.trace(follow_circuits=True) + endpoint = trace[-1][2] + if endpoint and endpoint.device in devices: + self.graph.edge(interface.device.name, endpoint.device.name, style=style) + seen.add(endpoint) def add_console_connections(self, devices):