From 87c600aa7cc3da60019a34b2c75162baefa4e40f Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 25 Jan 2021 14:19:32 -0500 Subject: [PATCH] Fixes #5665: Validate rack group is assigned to same site when creating a rack --- docs/release-notes/version-2.10.md | 1 + netbox/dcim/models/racks.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/release-notes/version-2.10.md b/docs/release-notes/version-2.10.md index 27d9fef49..98595ff4a 100644 --- a/docs/release-notes/version-2.10.md +++ b/docs/release-notes/version-2.10.md @@ -17,6 +17,7 @@ * [#5603](https://github.com/netbox-community/netbox/issues/5603) - Fix display of white cables in trace view * [#5639](https://github.com/netbox-community/netbox/issues/5639) - Fix filtering connection lists by device name * [#5640](https://github.com/netbox-community/netbox/issues/5640) - Fix permissions assessment when adding VM interfaces in bulk +* [#5665](https://github.com/netbox-community/netbox/issues/5665) - Validate rack group is assigned to same site when creating a rack --- diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index ccc775954..dfaf7da61 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -299,6 +299,10 @@ class Rack(ChangeLoggedModel, CustomFieldModel): def clean(self): super().clean() + # Validate group/site assignment + if self.site and self.group and self.group.site != self.site: + raise ValidationError(f"Assigned rack group must belong to parent site ({self.site}).") + # Validate outer dimensions and unit if (self.outer_width is not None or self.outer_depth is not None) and not self.outer_unit: raise ValidationError("Must specify a unit when setting an outer width/depth")