mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-05 23:06:25 -06:00
Update path tracing logic (WIP)
This commit is contained in:
@@ -21,7 +21,7 @@ from utilities.fields import ColorField, GenericArrayForeignKey
|
|||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
from utilities.serialization import deserialize_object, serialize_object
|
from utilities.serialization import deserialize_object, serialize_object
|
||||||
from wireless.models import WirelessLink
|
from wireless.models import WirelessLink
|
||||||
from .device_components import FrontPort, PathEndpoint, RearPort
|
from .device_components import FrontPort, PathEndpoint, RearPort, PortAssignment
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Cable',
|
'Cable',
|
||||||
@@ -775,58 +775,83 @@ class CablePath(models.Model):
|
|||||||
|
|
||||||
if isinstance(remote_terminations[0], FrontPort):
|
if isinstance(remote_terminations[0], FrontPort):
|
||||||
# Follow FrontPorts to their corresponding RearPorts
|
# Follow FrontPorts to their corresponding RearPorts
|
||||||
rear_ports = RearPort.objects.filter(
|
if position_stack:
|
||||||
pk__in=[t.rear_port_id for t in remote_terminations]
|
|
||||||
)
|
|
||||||
if len(rear_ports) > 1 or rear_ports[0].positions > 1:
|
|
||||||
position_stack.append([fp.rear_port_position for fp in remote_terminations])
|
|
||||||
|
|
||||||
terminations = rear_ports
|
|
||||||
|
|
||||||
elif isinstance(remote_terminations[0], RearPort):
|
|
||||||
if len(remote_terminations) == 1 and remote_terminations[0].positions == 1:
|
|
||||||
front_ports = FrontPort.objects.filter(
|
|
||||||
rear_port_id__in=[rp.pk for rp in remote_terminations],
|
|
||||||
rear_port_position=1
|
|
||||||
)
|
|
||||||
# Obtain the individual front ports based on the termination and all positions
|
|
||||||
elif len(remote_terminations) > 1 and position_stack:
|
|
||||||
positions = position_stack.pop()
|
positions = position_stack.pop()
|
||||||
|
|
||||||
# Ensure we have a number of positions equal to the amount of remote terminations
|
|
||||||
if len(remote_terminations) != len(positions):
|
|
||||||
raise UnsupportedCablePath(
|
|
||||||
_("All positions counts within the path on opposite ends of links must match")
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get our front ports
|
|
||||||
q_filter = Q()
|
q_filter = Q()
|
||||||
for rt in remote_terminations:
|
for rt in remote_terminations:
|
||||||
position = positions.pop()
|
position = positions.pop()
|
||||||
q_filter |= Q(rear_port_id=rt.pk, rear_port_position=position)
|
q_filter |= Q(front_port=rt, front_port_position=position)
|
||||||
if q_filter is Q():
|
port_assignments = PortAssignment.objects.filter(q_filter)
|
||||||
raise UnsupportedCablePath(_("Remote termination position filter is missing"))
|
|
||||||
front_ports = FrontPort.objects.filter(q_filter)
|
|
||||||
# Obtain the individual front ports based on the termination and position
|
|
||||||
elif position_stack:
|
|
||||||
front_ports = FrontPort.objects.filter(
|
|
||||||
rear_port_id=remote_terminations[0].pk,
|
|
||||||
rear_port_position__in=position_stack.pop()
|
|
||||||
)
|
|
||||||
# If all rear ports have a single position, we can just get the front ports
|
|
||||||
elif all([rp.positions == 1 for rp in remote_terminations]):
|
|
||||||
front_ports = FrontPort.objects.filter(rear_port_id__in=[rp.pk for rp in remote_terminations])
|
|
||||||
|
|
||||||
if len(front_ports) != len(remote_terminations):
|
|
||||||
# Some rear ports does not have a front port
|
|
||||||
is_split = True
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
# No position indicated: path has split, so we stop at the RearPorts
|
port_assignments = PortAssignment.objects.filter(front_port__in=remote_terminations)
|
||||||
is_split = True
|
|
||||||
break
|
|
||||||
|
|
||||||
terminations = front_ports
|
if not port_assignments:
|
||||||
|
print('No front-to-rear port assignments found')
|
||||||
|
break
|
||||||
|
position_stack.append([assignment.rear_port_position for assignment in port_assignments])
|
||||||
|
terminations = [assignment.rear_port for assignment in port_assignments]
|
||||||
|
|
||||||
|
elif isinstance(remote_terminations[0], RearPort):
|
||||||
|
# Follow RearPorts to their corresponding FrontPorts
|
||||||
|
if position_stack:
|
||||||
|
positions = position_stack.pop()
|
||||||
|
q_filter = Q()
|
||||||
|
for rt in remote_terminations:
|
||||||
|
position = positions.pop()
|
||||||
|
q_filter |= Q(rear_port=rt, rear_port_position=position)
|
||||||
|
port_assignments = PortAssignment.objects.filter(q_filter)
|
||||||
|
else:
|
||||||
|
port_assignments = PortAssignment.objects.filter(rear_port__in=remote_terminations)
|
||||||
|
|
||||||
|
if not port_assignments:
|
||||||
|
print('No rear-to-front port assignments found')
|
||||||
|
break
|
||||||
|
position_stack.append([assignment.front_port_position for assignment in port_assignments])
|
||||||
|
terminations = [assignment.front_port for assignment in port_assignments]
|
||||||
|
|
||||||
|
# if len(remote_terminations) == 1 and remote_terminations[0].positions == 1:
|
||||||
|
# front_ports = FrontPort.objects.filter(
|
||||||
|
# rear_port_id__in=[rp.pk for rp in remote_terminations],
|
||||||
|
# rear_port_position=1
|
||||||
|
# )
|
||||||
|
# # Obtain the individual front ports based on the termination and all positions
|
||||||
|
# elif len(remote_terminations) > 1 and position_stack:
|
||||||
|
# positions = position_stack.pop()
|
||||||
|
#
|
||||||
|
# # Ensure we have a number of positions equal to the amount of remote terminations
|
||||||
|
# if len(remote_terminations) != len(positions):
|
||||||
|
# raise UnsupportedCablePath(
|
||||||
|
# _("All positions counts within the path on opposite ends of links must match")
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# # Get our front ports
|
||||||
|
# q_filter = Q()
|
||||||
|
# for rt in remote_terminations:
|
||||||
|
# position = positions.pop()
|
||||||
|
# q_filter |= Q(rear_port_id=rt.pk, rear_port_position=position)
|
||||||
|
# if q_filter is Q():
|
||||||
|
# raise UnsupportedCablePath(_("Remote termination position filter is missing"))
|
||||||
|
# front_ports = FrontPort.objects.filter(q_filter)
|
||||||
|
# # Obtain the individual front ports based on the termination and position
|
||||||
|
# elif position_stack:
|
||||||
|
# front_ports = FrontPort.objects.filter(
|
||||||
|
# rear_port_id=remote_terminations[0].pk,
|
||||||
|
# rear_port_position__in=position_stack.pop()
|
||||||
|
# )
|
||||||
|
# # If all rear ports have a single position, we can just get the front ports
|
||||||
|
# elif all([rp.positions == 1 for rp in remote_terminations]):
|
||||||
|
# front_ports = FrontPort.objects.filter(rear_port_id__in=[rp.pk for rp in remote_terminations])
|
||||||
|
#
|
||||||
|
# if len(front_ports) != len(remote_terminations):
|
||||||
|
# # Some rear ports does not have a front port
|
||||||
|
# is_split = True
|
||||||
|
# break
|
||||||
|
# else:
|
||||||
|
# # No position indicated: path has split, so we stop at the RearPorts
|
||||||
|
# is_split = True
|
||||||
|
# break
|
||||||
|
#
|
||||||
|
# terminations = front_ports
|
||||||
|
|
||||||
elif isinstance(remote_terminations[0], CircuitTermination):
|
elif isinstance(remote_terminations[0], CircuitTermination):
|
||||||
# Follow a CircuitTermination to its corresponding CircuitTermination (A to Z or vice versa)
|
# Follow a CircuitTermination to its corresponding CircuitTermination (A to Z or vice versa)
|
||||||
|
|||||||
@@ -281,9 +281,13 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
PortAssignment.objects.create(
|
||||||
|
front_port=frontport1,
|
||||||
|
front_port_position=1,
|
||||||
|
rear_port=rearport1,
|
||||||
|
rear_port_position=1
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create cable 1
|
# Create cable 1
|
||||||
@@ -340,9 +344,13 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
PortAssignment.objects.create(
|
||||||
|
front_port=frontport1,
|
||||||
|
front_port_position=1,
|
||||||
|
rear_port=rearport1,
|
||||||
|
rear_port_position=1
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create cable 1
|
# Create cable 1
|
||||||
@@ -403,18 +411,24 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport2_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_1 = FrontPort.objects.create(
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport2, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_2 = FrontPort.objects.create(
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport2_1, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_2, front_port_position=1, rear_port=rearport2, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2
|
# Create cables 1-2
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -521,18 +535,24 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface8 = Interface.objects.create(device=self.device, name='Interface 8')
|
interface8 = Interface.objects.create(device=self.device, name='Interface 8')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport2_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_1 = FrontPort.objects.create(
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport2, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_2 = FrontPort.objects.create(
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport2_1, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_2, front_port_position=1, rear_port=rearport2, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2
|
# Create cables 1-2
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -680,27 +700,35 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=4)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
frontport4_1 = FrontPort.objects.create(device=self.device, name='Front Port 4:1')
|
||||||
)
|
frontport4_2 = FrontPort.objects.create(device=self.device, name='Front Port 4:2')
|
||||||
frontport2 = FrontPort.objects.create(
|
PortAssignment.objects.bulk_create([
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
frontport3 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
frontport4_1 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 4:1', rear_port=rearport4, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
frontport4_2 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 4:2', rear_port=rearport4, rear_port_position=2
|
PortAssignment(
|
||||||
)
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4_1, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4_2, front_port_position=1, rear_port=rearport4, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2, 6-7
|
# Create cables 1-2, 6-7
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -801,30 +829,40 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=4)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=4)
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=4)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport2_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
frontport3_1 = FrontPort.objects.create(device=self.device, name='Front Port 3:1')
|
||||||
)
|
frontport3_2 = FrontPort.objects.create(device=self.device, name='Front Port 3:2')
|
||||||
frontport2_1 = FrontPort.objects.create(
|
frontport4_1 = FrontPort.objects.create(device=self.device, name='Front Port 4:1')
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport2, rear_port_position=1
|
frontport4_2 = FrontPort.objects.create(device=self.device, name='Front Port 4:2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport2_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
frontport3_1 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 3:1', rear_port=rearport3, rear_port_position=1
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
)
|
),
|
||||||
frontport3_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 3:2', rear_port=rearport3, rear_port_position=2
|
front_port=frontport2_1, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
)
|
),
|
||||||
frontport4_1 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 4:1', rear_port=rearport4, rear_port_position=1
|
front_port=frontport2_2, front_port_position=1, rear_port=rearport2, rear_port_position=2,
|
||||||
)
|
),
|
||||||
frontport4_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 4:2', rear_port=rearport4, rear_port_position=2
|
front_port=frontport3_1, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport3_2, front_port_position=1, rear_port=rearport3, rear_port_position=2,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4_1, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4_2, front_port_position=1, rear_port=rearport4, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-3, 6-8
|
# Create cables 1-3, 6-8
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -928,23 +966,30 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 5', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 5')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 5')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport3_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
frontport3_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 5', rear_port=rearport2, rear_port_position=1
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
frontport3_1 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport3, rear_port_position=1
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
)
|
),
|
||||||
frontport3_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport3, rear_port_position=2
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport3_1, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport3_2, front_port_position=1, rear_port=rearport3, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2, 5-6
|
# Create cables 1-2, 5-6
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -1033,12 +1078,16 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport1_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1
|
# Create cables 1
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -1098,10 +1147,11 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2]
|
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2]
|
||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
PortAssignment.objects.create(
|
||||||
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create cables
|
# Create cables
|
||||||
@@ -1413,18 +1463,24 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport2_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport2_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_1 = FrontPort.objects.create(
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport2, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport2_2 = FrontPort.objects.create(
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport2_1, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_2, front_port_position=1, rear_port=rearport2, rear_port_position=2,
|
||||||
|
),
|
||||||
|
])
|
||||||
circuittermination1 = CircuitTermination.objects.create(
|
circuittermination1 = CircuitTermination.objects.create(
|
||||||
circuit=self.circuit,
|
circuit=self.circuit,
|
||||||
termination=self.site,
|
termination=self.site,
|
||||||
@@ -1601,22 +1657,28 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=1)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
frontport2 = FrontPort.objects.create(
|
frontport4 = FrontPort.objects.create(device=self.device, name='Front Port 4')
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport3 = FrontPort.objects.create(
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport4 = FrontPort.objects.create(
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 4', rear_port=rearport4, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2
|
# Create cables 1-2
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -1688,30 +1750,40 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=4)
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=4)
|
||||||
frontport1_1 = FrontPort.objects.create(
|
frontport1_1 = FrontPort.objects.create(device=self.device, name='Front Port 1:1')
|
||||||
device=self.device, name='Front Port 1:1', rear_port=rearport1, rear_port_position=1
|
frontport1_2 = FrontPort.objects.create(device=self.device, name='Front Port 1:2')
|
||||||
)
|
frontport1_3 = FrontPort.objects.create(device=self.device, name='Front Port 1:3')
|
||||||
frontport1_2 = FrontPort.objects.create(
|
frontport1_4 = FrontPort.objects.create(device=self.device, name='Front Port 1:4')
|
||||||
device=self.device, name='Front Port 1:2', rear_port=rearport1, rear_port_position=2
|
frontport2_1 = FrontPort.objects.create(device=self.device, name='Front Port 2:1')
|
||||||
)
|
frontport2_2 = FrontPort.objects.create(device=self.device, name='Front Port 2:2')
|
||||||
frontport1_3 = FrontPort.objects.create(
|
frontport2_3 = FrontPort.objects.create(device=self.device, name='Front Port 2:3')
|
||||||
device=self.device, name='Front Port 1:3', rear_port=rearport1, rear_port_position=3
|
frontport2_4 = FrontPort.objects.create(device=self.device, name='Front Port 2:4')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport1_4 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 1:4', rear_port=rearport1, rear_port_position=4
|
front_port=frontport1_1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
frontport2_1 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:1', rear_port=rearport2, rear_port_position=1
|
front_port=frontport1_2, front_port_position=1, rear_port=rearport1, rear_port_position=2,
|
||||||
)
|
),
|
||||||
frontport2_2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
|
front_port=frontport1_3, front_port_position=1, rear_port=rearport1, rear_port_position=3,
|
||||||
)
|
),
|
||||||
frontport2_3 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:3', rear_port=rearport2, rear_port_position=3
|
front_port=frontport1_4, front_port_position=1, rear_port=rearport1, rear_port_position=4,
|
||||||
)
|
),
|
||||||
frontport2_4 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2:4', rear_port=rearport2, rear_port_position=4
|
front_port=frontport2_1, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_2, front_port_position=1, rear_port=rearport2, rear_port_position=2,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_3, front_port_position=1, rear_port=rearport2, rear_port_position=3,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2_4, front_port_position=1, rear_port=rearport2, rear_port_position=4,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1-2
|
# Create cables 1-2
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -1858,22 +1930,28 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=1)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
frontport2 = FrontPort.objects.create(
|
frontport4 = FrontPort.objects.create(device=self.device, name='Front Port 4')
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport3 = FrontPort.objects.create(
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport4 = FrontPort.objects.create(
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 4', rear_port=rearport4, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
cable2 = Cable(
|
cable2 = Cable(
|
||||||
a_terminations=[rearport1],
|
a_terminations=[rearport1],
|
||||||
@@ -1937,22 +2015,28 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=1)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
frontport2 = FrontPort.objects.create(
|
frontport4 = FrontPort.objects.create(device=self.device, name='Front Port 4')
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport3 = FrontPort.objects.create(
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport4 = FrontPort.objects.create(
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
device=self.device, name='Front Port 4', rear_port=rearport4, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
cable2 = Cable(
|
cable2 = Cable(
|
||||||
a_terminations=[rearport1],
|
a_terminations=[rearport1],
|
||||||
@@ -2033,30 +2117,38 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=self.device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4', positions=1)
|
rearport4 = RearPort.objects.create(device=self.device, name='Rear Port 4')
|
||||||
rearport5 = RearPort.objects.create(device=self.device, name='Rear Port 5', positions=1)
|
rearport5 = RearPort.objects.create(device=self.device, name='Rear Port 5')
|
||||||
rearport6 = RearPort.objects.create(device=self.device, name='Rear Port 6', positions=1)
|
rearport6 = RearPort.objects.create(device=self.device, name='Rear Port 6')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
frontport2 = FrontPort.objects.create(
|
frontport4 = FrontPort.objects.create(device=self.device, name='Front Port 4')
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
frontport5 = FrontPort.objects.create(device=self.device, name='Front Port 5')
|
||||||
)
|
frontport6 = FrontPort.objects.create(device=self.device, name='Front Port 6')
|
||||||
frontport3 = FrontPort.objects.create(
|
PortAssignment.objects.bulk_create([
|
||||||
device=self.device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
frontport4 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 4', rear_port=rearport4, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
frontport5 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 5', rear_port=rearport5, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
frontport6 = FrontPort.objects.create(
|
),
|
||||||
device=self.device, name='Front Port 6', rear_port=rearport6, rear_port_position=1
|
PortAssignment(
|
||||||
)
|
front_port=frontport4, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport5, front_port_position=1, rear_port=rearport5, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport6, front_port_position=1, rear_port=rearport6, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
cable2 = Cable(
|
cable2 = Cable(
|
||||||
a_terminations=[rearport1],
|
a_terminations=[rearport1],
|
||||||
@@ -2155,14 +2247,18 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
a_terminations=[interface1],
|
a_terminations=[interface1],
|
||||||
@@ -2200,14 +2296,18 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
|
||||||
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables
|
# Create cables
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -2246,14 +2346,18 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
PortAssignment.objects.bulk_create([
|
||||||
frontport2 = FrontPort.objects.create(
|
PortAssignment(
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
)
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cable 2
|
# Create cable 2
|
||||||
cable2 = Cable(
|
cable2 = Cable(
|
||||||
@@ -2299,10 +2403,13 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
"""
|
"""
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
# Create cables 1 and 2
|
# Create cables 1 and 2
|
||||||
cable1 = Cable(
|
cable1 = Cable(
|
||||||
@@ -2404,22 +2511,28 @@ class LegacyCablePathTests(CablePathTestCase):
|
|||||||
)
|
)
|
||||||
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
|
||||||
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
|
||||||
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1', positions=1)
|
rearport1 = RearPort.objects.create(device=self.device, name='Rear Port 1')
|
||||||
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2', positions=1)
|
rearport2 = RearPort.objects.create(device=self.device, name='Rear Port 2')
|
||||||
rearport3 = RearPort.objects.create(device=device, name='Rear Port 3', positions=1)
|
rearport3 = RearPort.objects.create(device=device, name='Rear Port 3')
|
||||||
rearport4 = RearPort.objects.create(device=device, name='Rear Port 4', positions=1)
|
rearport4 = RearPort.objects.create(device=device, name='Rear Port 4')
|
||||||
frontport1 = FrontPort.objects.create(
|
frontport1 = FrontPort.objects.create(device=self.device, name='Front Port 1')
|
||||||
device=self.device, name='Front Port 1', rear_port=rearport1, rear_port_position=1
|
frontport2 = FrontPort.objects.create(device=self.device, name='Front Port 2')
|
||||||
)
|
frontport3 = FrontPort.objects.create(device=self.device, name='Front Port 3')
|
||||||
frontport2 = FrontPort.objects.create(
|
frontport4 = FrontPort.objects.create(device=self.device, name='Front Port 4')
|
||||||
device=self.device, name='Front Port 2', rear_port=rearport2, rear_port_position=1
|
PortAssignment.objects.bulk_create([
|
||||||
)
|
PortAssignment(
|
||||||
frontport3 = FrontPort.objects.create(
|
front_port=frontport1, front_port_position=1, rear_port=rearport1, rear_port_position=1,
|
||||||
device=device, name='Front Port 3', rear_port=rearport3, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
frontport4 = FrontPort.objects.create(
|
front_port=frontport2, front_port_position=1, rear_port=rearport2, rear_port_position=1,
|
||||||
device=device, name='Front Port 4', rear_port=rearport4, rear_port_position=1
|
),
|
||||||
)
|
PortAssignment(
|
||||||
|
front_port=frontport3, front_port_position=1, rear_port=rearport3, rear_port_position=1,
|
||||||
|
),
|
||||||
|
PortAssignment(
|
||||||
|
front_port=frontport4, front_port_position=1, rear_port=rearport4, rear_port_position=1,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
cable2 = Cable(
|
cable2 = Cable(
|
||||||
a_terminations=[rearport1],
|
a_terminations=[rearport1],
|
||||||
|
|||||||
Reference in New Issue
Block a user