mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 03:56:53 -06:00
Update object trace() method
This commit is contained in:
parent
4c51dbba80
commit
3082c76ec6
@ -194,20 +194,22 @@ class PathEndpoint(models.Model):
|
|||||||
origin = self
|
origin = self
|
||||||
path = []
|
path = []
|
||||||
|
|
||||||
# Construct the complete path
|
# Construct the complete path (including e.g. bridged interfaces)
|
||||||
while origin is not None:
|
while origin is not None:
|
||||||
|
|
||||||
if origin._path is None:
|
if origin._path is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
path.extend([origin, *origin._path.get_path()])
|
path.extend(*origin._path.get_path())
|
||||||
while (len(path) + 1) % 3:
|
while (len(path)) % 3:
|
||||||
# Pad to ensure we have complete three-tuples (e.g. for paths that end at a non-connected FrontPort)
|
# Pad to ensure we have complete three-tuples (e.g. for paths that end at a non-connected FrontPort)
|
||||||
path.append(None)
|
# by inserting empty entries immediately prior to the path's destination node(s)
|
||||||
path.append(origin._path.destination)
|
path.insert(-1, [None])
|
||||||
|
|
||||||
# Check for bridge interface to continue the trace
|
# TODO: Add bridging support
|
||||||
origin = getattr(origin._path.destination, 'bridge', None)
|
# # Check for bridge interface to continue the trace
|
||||||
|
# origin = getattr(origin._path.destination, 'bridge', None)
|
||||||
|
origin = None
|
||||||
|
|
||||||
# Return the path as a list of three-tuples (A termination, cable, B termination)
|
# Return the path as a list of three-tuples (A termination, cable, B termination)
|
||||||
return list(zip(*[iter(path)] * 3))
|
return list(zip(*[iter(path)] * 3))
|
||||||
|
Loading…
Reference in New Issue
Block a user