mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 12:38:17 -06:00
Fix graph now that CircuitTermination.interface doesn't exist anymore
Note: it shouldn't have existed because of `related_name='+'` in the first place, but it did…
This commit is contained in:
parent
cb2e41ef54
commit
ba07bcfbba
19
netbox/dcim/migrations/0071_auto_20190612_1730.py
Normal file
19
netbox/dcim/migrations/0071_auto_20190612_1730.py
Normal file
@ -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'),
|
||||
),
|
||||
]
|
@ -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
|
||||
)
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user