From a32d185ff0308cfdbf1244e962128f8fd8dd015e Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 31 Jul 2019 10:12:07 -0400 Subject: [PATCH] Fixes #3018: Components connected via a cable must have an equal number of positions --- CHANGELOG.md | 1 + netbox/dcim/models.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0510f783f9b..f3e26510bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v2.6.2 (FUTURE) ## Bug Fixes +* [#3018](https://github.com/netbox-community/netbox/issues/3018) - Components connected via a cable must have an equal number of positions * [#3289](https://github.com/netbox-community/netbox/issues/3289) - Prevent position from being nullified when moving a device to a new rack * [#3293](https://github.com/netbox-community/netbox/issues/3293) - Enable filtering device components by multiple device IDs * [#3315](https://github.com/netbox-community/netbox/issues/3315) - Enable filtering devices/interfaces by multiple MAC addresses diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index a73e62ff6a9..0a1b5297969 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -2772,6 +2772,16 @@ def clean(self): self.termination_a_type, self.termination_b_type )) + # A component with multiple positions must be connected to a component with an equal number of positions + term_a_positions = getattr(self.termination_a, 'positions', 1) + term_b_positions = getattr(self.termination_b, 'positions', 1) + if term_a_positions != term_b_positions: + raise ValidationError( + "{} has {} positions and {} has {}. Both terminations must have the same number of positions.".format( + self.termination_a, term_a_positions, self.termination_b, term_b_positions + ) + ) + # A termination point cannot be connected to itself if self.termination_a == self.termination_b: raise ValidationError("Cannot connect {} to itself".format(self.termination_a_type))