Fix bug with path padding

This commit is contained in:
jeremystretch 2022-06-27 15:28:03 -04:00
parent 7622d90c1d
commit 9d35a9d912
3 changed files with 5 additions and 7 deletions

View File

@ -205,14 +205,14 @@ class PathEndpoint(models.Model):
while (len(path)) % 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)
# by inserting empty entries immediately prior to the path's destination node(s) # by inserting empty entries immediately prior to the path's destination node(s)
path.insert(-1, [None]) path.append([])
# TODO: Add bridging support # TODO: Add bridging support
# # Check for bridge interface to continue the trace # # Check for bridge interface to continue the trace
# origin = getattr(origin._path.destination, 'bridge', None) # origin = getattr(origin._path.destination, 'bridge', None)
origin = 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)) return list(zip(*[iter(path)] * 3))
def get_trace_svg(self, base_url=None, width=None): def get_trace_svg(self, base_url=None, width=None):

View File

@ -429,7 +429,6 @@ class Rack(NetBoxModel):
""" """
powerfeeds = PowerFeed.objects.filter(rack=self) powerfeeds = PowerFeed.objects.filter(rack=self)
available_power_total = sum(pf.available_power for pf in powerfeeds) available_power_total = sum(pf.available_power for pf in powerfeeds)
print(f'available_power_total: {available_power_total}')
if not available_power_total: if not available_power_total:
return 0 return 0
@ -442,7 +441,6 @@ class Rack(NetBoxModel):
allocated_draw = 0 allocated_draw = 0
for powerport in powerports: for powerport in powerports:
allocated_draw += powerport.get_power_draw()['allocated'] allocated_draw += powerport.get_power_draw()['allocated']
print(f'allocated_draw: {allocated_draw}')
return int(allocated_draw / available_power_total * 100) return int(allocated_draw / available_power_total * 100)

View File

@ -321,7 +321,7 @@ class CableTraceSVG:
# Iterate through each (terms, cable, terms) segment in the path # Iterate through each (terms, cable, terms) segment in the path
for i, segment in enumerate(traced_path): for i, segment in enumerate(traced_path):
near_ends, link, far_ends = segment near_ends, links, far_ends = segment
# Near end parent # Near end parent
if i == 0: if i == 0:
@ -332,8 +332,8 @@ class CableTraceSVG:
terminations = self.draw_terminations(near_ends) terminations = self.draw_terminations(near_ends)
# Connector (a Cable or WirelessLink) # Connector (a Cable or WirelessLink)
link = link[0] # Remove Cable from list if links:
if link is not None: link = links[0] # Remove Cable from list
# Cable # Cable
if type(link) is Cable: if type(link) is Cable: