mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
fixed #2584 - validation for connecting front port to corresponding rear port
This commit is contained in:
parent
bc8dbfde7c
commit
9543b5e716
@ -2530,9 +2530,19 @@ class Cable(ChangeLoggedModel):
|
|||||||
|
|
||||||
# A termination point cannot be connected to itself
|
# A termination point cannot be connected to itself
|
||||||
if self.termination_a == self.termination_b:
|
if self.termination_a == self.termination_b:
|
||||||
print("Validation failed: same interface")
|
|
||||||
raise ValidationError("Cannot connect {} to itself".format(self.termination_a_type))
|
raise ValidationError("Cannot connect {} to itself".format(self.termination_a_type))
|
||||||
|
|
||||||
|
# A front port cannot be connected to its corresponding rear port
|
||||||
|
if (
|
||||||
|
type_a in ['frontport', 'rearport'] and
|
||||||
|
type_b in ['frontport', 'rearport'] and
|
||||||
|
(
|
||||||
|
getattr(self.termination_a, 'rear_port', None) == self.termination_b or
|
||||||
|
getattr(self.termination_b, 'rear_port', None) == self.termination_a
|
||||||
|
)
|
||||||
|
):
|
||||||
|
raise ValidationError("A front port cannot be connected to it corresponding rear port")
|
||||||
|
|
||||||
# Check for an existing Cable connected to either termination object
|
# Check for an existing Cable connected to either termination object
|
||||||
if self.termination_a.cable not in (None, self):
|
if self.termination_a.cable not in (None, self):
|
||||||
raise ValidationError("{} already has a cable attached (#{})".format(
|
raise ValidationError("{} already has a cable attached (#{})".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user