From 9d35a9d9128f40c09687c50283f06c535329688e Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 27 Jun 2022 15:28:03 -0400 Subject: [PATCH] Fix bug with path padding --- netbox/dcim/models/device_components.py | 4 ++-- netbox/dcim/models/racks.py | 2 -- netbox/dcim/svg/cables.py | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index c41192688..c2cd31a2a 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -205,14 +205,14 @@ class PathEndpoint(models.Model): while (len(path)) % 3: # Pad to ensure we have complete three-tuples (e.g. for paths that end at a non-connected FrontPort) # by inserting empty entries immediately prior to the path's destination node(s) - path.insert(-1, [None]) + path.append([]) # TODO: Add bridging support # # 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(s), cable(s), B termination(s)) return list(zip(*[iter(path)] * 3)) def get_trace_svg(self, base_url=None, width=None): diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index 22b134785..3bbf38b6a 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -429,7 +429,6 @@ class Rack(NetBoxModel): """ powerfeeds = PowerFeed.objects.filter(rack=self) available_power_total = sum(pf.available_power for pf in powerfeeds) - print(f'available_power_total: {available_power_total}') if not available_power_total: return 0 @@ -442,7 +441,6 @@ class Rack(NetBoxModel): allocated_draw = 0 for powerport in powerports: allocated_draw += powerport.get_power_draw()['allocated'] - print(f'allocated_draw: {allocated_draw}') return int(allocated_draw / available_power_total * 100) diff --git a/netbox/dcim/svg/cables.py b/netbox/dcim/svg/cables.py index d26bc5ff5..b9d7c42ed 100644 --- a/netbox/dcim/svg/cables.py +++ b/netbox/dcim/svg/cables.py @@ -321,7 +321,7 @@ class CableTraceSVG: # Iterate through each (terms, cable, terms) segment in the path for i, segment in enumerate(traced_path): - near_ends, link, far_ends = segment + near_ends, links, far_ends = segment # Near end parent if i == 0: @@ -332,8 +332,8 @@ class CableTraceSVG: terminations = self.draw_terminations(near_ends) # Connector (a Cable or WirelessLink) - link = link[0] # Remove Cable from list - if link is not None: + if links: + link = links[0] # Remove Cable from list # Cable if type(link) is Cable: