10201 remove debugging code

This commit is contained in:
Arthur 2022-12-29 16:22:30 -08:00
parent cc5f0c9c28
commit 9671307a65
4 changed files with 0 additions and 66 deletions

View File

@ -119,10 +119,6 @@ class Cable(PrimaryModel):
@a_terminations.setter
def a_terminations(self, value):
if self.pk:
print(f"a_terminations setter a_terminations: {self.a_terminations} value: {value}")
else:
print("a_terminations setter no pk")
self._terminations_modified = True
self._a_terminations = value
@ -137,15 +133,10 @@ class Cable(PrimaryModel):
@b_terminations.setter
def b_terminations(self, value):
if self.pk:
print(f"b_terminations setter b_terminations: {self.b_terminations} value: {value}")
else:
print("b_terminations setter no pk")
self._terminations_modified = True
self._b_terminations = value
def clean(self):
print("cable clean")
super().clean()
# Validate length and length_unit
@ -177,31 +168,7 @@ class Cable(PrimaryModel):
for termination in self.b_terminations:
CableTermination(cable=self, cable_end='B', termination=termination).clean()
def _print_terminations(self, terminations):
if len(terminations) > 1:
print(f"terminations[0].link: {terminations[0].link}")
for termination in terminations:
print(f"{termination.id}: {termination}")
print(f"termination: {termination} termination.link: {termination.link}")
def print_a_terminations(self):
print("--- a termination ---")
self._print_terminations(self.a_terminations)
def print_b_terminations(self):
print("--- b termination ---")
self._print_terminations(self.b_terminations)
def print_paths(self):
print("--- cable paths ---")
for cablepath in CablePath.objects.filter(_nodes__contains=self):
print(f"{cablepath} - {cablepath.path}")
def save(self, *args, **kwargs):
print("cable save")
self.print_a_terminations()
self.print_b_terminations()
self.print_paths()
_created = self.pk is None
# Store the given length (if any) in meters for use in database ordering
@ -239,11 +206,6 @@ class Cable(PrimaryModel):
trace_paths.send(Cable, instance=self, created=_created)
print("cable save end")
self.print_a_terminations()
self.print_b_terminations()
self.print_paths()
def get_status_color(self):
return LinkStatusChoices.colors.get(self.status)
@ -351,7 +313,6 @@ class CableTermination(models.Model):
)
def delete(self, *args, **kwargs):
print("cable termination delete")
# Delete the cable association on the terminating object
termination_model = self.termination._meta.model
termination_model.objects.filter(pk=self.termination_id).update(
@ -438,12 +399,6 @@ class CablePath(models.Model):
def __str__(self):
return f"Path #{self.pk}: {len(self.path)} hops"
def dump(self):
print("")
print(f"Cable Path: {self}")
print(f"path: {self.path}")
print(f"_nodes: {self._nodes}")
def save(self, *args, **kwargs):
# Save the flattened nodes list
@ -511,9 +466,6 @@ class CablePath(models.Model):
# Ensure all originating terminations are attached to the same link
if len(terminations) > 1:
print(f"terminations[0]: {terminations[0]} terminations[0].link: {terminations[0].link}")
for t in terminations[1:]:
print(f"t: {t} t.link: {t.link}")
assert all(t.link == terminations[0].link for t in terminations[1:])
path = []
@ -657,8 +609,6 @@ class CablePath(models.Model):
"""
Retrace the path from the currently-defined originating termination(s)
"""
print(f"retrace for cable path: {self.id}")
print(f"self.origins: {self.origins}")
_new = self.from_origin(self.origins)
if _new:
self.path = _new.path

View File

@ -859,10 +859,6 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
def l2vpn_termination(self):
return self.l2vpn_terminations.first()
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
print(f"Interface: {self} link: {self.link}")
#
# Pass-through ports

View File

@ -84,13 +84,10 @@ def create_or_rebuild_paths(nodes, in_path):
if isinstance(nodes[0], PathEndpoint):
if in_path:
print(f"rebuild_paths1 for: {nodes}")
rebuild_paths(nodes, True)
else:
print(f"create_cablepath for: {nodes}")
create_cablepath(nodes)
else:
print(f"rebuild_paths2 for: {nodes}")
rebuild_paths(nodes)
@ -99,7 +96,6 @@ def update_connected_endpoints(instance, created, raw=False, **kwargs):
"""
When a Cable is saved with new terminations, retrace any affected cable paths.
"""
print("update_connected_endpoints")
logger = logging.getLogger('netbox.dcim.cable')
if raw:
logger.debug(f"Skipping endpoint updates for imported cable {instance}")
@ -115,8 +111,6 @@ def update_connected_endpoints(instance, created, raw=False, **kwargs):
else:
b_terminations.append(t.termination)
print(f"a_terminations: {a_terminations}")
print(f"b_terminations: {b_terminations}")
a_terminations_in_path = termination_in_path(a_terminations, instance)
b_terminations_in_path = termination_in_path(b_terminations, instance)
@ -136,7 +130,6 @@ def retrace_cable_paths(instance, **kwargs):
"""
When a Cable is deleted, check for and update its connected endpoints
"""
print("retrace_cable_paths")
for cablepath in CablePath.objects.filter(_nodes__contains=instance):
cablepath.retrace()
@ -146,14 +139,10 @@ def nullify_connected_endpoints(instance, **kwargs):
"""
Disassociate the Cable from the termination object, and retrace any affected CablePaths.
"""
print("nullify_connected_endpoints")
model = instance.termination_type.model_class()
model.objects.filter(pk=instance.termination_id).update(cable=None, cable_end='')
# for cablepath in CablePath.objects.filter(_nodes__contains=instance.cable):
# print(f"_nodes before: {cablepath._nodes}")
# cablepath._nodes.remove(instance)
# print(f"_nodes after: {cablepath._nodes}")
# cablepath.retrace()

View File

@ -56,6 +56,5 @@ def rebuild_paths(terminations, endpoint=False):
with transaction.atomic():
for cp in cable_paths:
cp.dump()
cp.delete()
create_cablepath(terminations if endpoint else cp.origins)