mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 09:53:34 -06:00
Extend Interface.link_peers() to support WirelessLinks
This commit is contained in:
parent
9a7f3f8c1a
commit
13ef5dc0b3
@ -143,13 +143,19 @@ class CabledObjectModel(models.Model):
|
|||||||
"mark_connected": "Cannot mark as connected with a cable attached."
|
"mark_connected": "Cannot mark as connected with a cable attached."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@property
|
||||||
|
def link(self):
|
||||||
|
"""
|
||||||
|
Generic wrapper for a Cable, WirelessLink, or some other relation to a connected termination.
|
||||||
|
"""
|
||||||
|
return self.cable
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link_peers(self):
|
def link_peers(self):
|
||||||
# TODO: Support WirelessLinks
|
if self.cable:
|
||||||
if not self.cable:
|
peers = self.cable.terminations.exclude(cable_end=self.cable_end).prefetch_related('termination')
|
||||||
return []
|
return [peer.termination for peer in peers]
|
||||||
peer_terminations = self.cable.terminations.exclude(cable_end=self.cable_end).prefetch_related('termination')
|
return []
|
||||||
return [ct.termination for ct in peer_terminations]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _occupied(self):
|
def _occupied(self):
|
||||||
@ -165,14 +171,6 @@ class CabledObjectModel(models.Model):
|
|||||||
return None
|
return None
|
||||||
return CableEndChoices.SIDE_A if self.cable_end == CableEndChoices.SIDE_B else CableEndChoices.SIDE_B
|
return CableEndChoices.SIDE_A if self.cable_end == CableEndChoices.SIDE_B else CableEndChoices.SIDE_B
|
||||||
|
|
||||||
@property
|
|
||||||
def link(self):
|
|
||||||
"""
|
|
||||||
Generic wrapper for a Cable, WirelessLink, or some other relation to a connected termination.
|
|
||||||
"""
|
|
||||||
# TODO: Support WirelessLinks
|
|
||||||
return self.cable
|
|
||||||
|
|
||||||
|
|
||||||
class PathEndpoint(models.Model):
|
class PathEndpoint(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -832,6 +830,18 @@ class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEnd
|
|||||||
def link(self):
|
def link(self):
|
||||||
return self.cable or self.wireless_link
|
return self.cable or self.wireless_link
|
||||||
|
|
||||||
|
@property
|
||||||
|
def link_peers(self):
|
||||||
|
if self.cable:
|
||||||
|
return super().link_peers
|
||||||
|
if self.wireless_link:
|
||||||
|
# Return the opposite side of the attached wireless link
|
||||||
|
if self.wireless_link.interface_a == self:
|
||||||
|
return [self.wireless_link.interface_b]
|
||||||
|
else:
|
||||||
|
return [self.wireless_link.interface_a]
|
||||||
|
return []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def l2vpn_termination(self):
|
def l2vpn_termination(self):
|
||||||
return self.l2vpn_terminations.first()
|
return self.l2vpn_terminations.first()
|
||||||
|
Loading…
Reference in New Issue
Block a user