1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Handle traces which split at a RearPort

This commit is contained in:
Jeremy Stretch
2020-10-08 13:45:47 -04:00
parent 29eebf9fbe
commit 0c5efa243d
5 changed files with 82 additions and 29 deletions

View File

@@ -172,9 +172,11 @@ class PathEndpoint(models.Model):
return []
# Construct the complete path
path = [self, *[path_node_to_object(obj) for obj in self._path.path], self._path.destination]
assert not len(path) % 3,\
f"Invalid path length for CablePath #{self.pk}: {len(self._path.path)} elements in path"
path = [self, *[path_node_to_object(obj) for obj in self._path.path]]
while (len(path) + 1) % 3:
# Pad to ensure we have complete three-tuples (e.g. for paths that end at a RearPort)
path.append(None)
path.append(self._path.destination)
# Return the path as a list of three-tuples (A termination, cable, B termination)
return list(zip(*[iter(path)] * 3))