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

Introduced 'cable' field on CableTermination to cache connected Cable

This commit is contained in:
Jeremy Stretch
2018-10-29 12:24:16 -04:00
parent dc67028bd9
commit e21b23cd98
9 changed files with 110 additions and 55 deletions

View File

@@ -66,6 +66,12 @@ class ComponentModel(models.Model):
class CableTermination(models.Model):
cable = models.ForeignKey(
to='dcim.Cable',
on_delete=models.SET_NULL,
blank=True,
null=True
)
class Meta:
abstract = True
@@ -2339,6 +2345,12 @@ class Cable(ChangeLoggedModel):
super(Cable, self).save(*args, **kwargs)
# Cache the Cable on its two termination points
self.termination_a.cable = self
self.termination_a.save()
self.termination_b.cable = self
self.termination_b.save()
def get_path_endpoints(self):
"""
Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be