mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -06:00
verify devices can still fit if change rack starting_unit
This commit is contained in:
parent
ba9ef11522
commit
78e26ea591
@ -241,12 +241,25 @@ class Rack(PrimaryModel, WeightMixin):
|
|||||||
).order_by('-position').first()
|
).order_by('-position').first()
|
||||||
if top_device:
|
if top_device:
|
||||||
min_height = top_device.position + top_device.device_type.u_height - 1
|
min_height = top_device.position + top_device.device_type.u_height - 1
|
||||||
if self.u_height < min_height:
|
if self.u_height + self.start_unit < min_height:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'u_height': "Rack must be at least {}U tall to house currently installed devices.".format(
|
'u_height': "Rack must be at least {}U tall to house currently installed devices.".format(
|
||||||
min_height
|
min_height
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
# Validate the Rack starting_unit > position of any installed devices
|
||||||
|
first_device = Device.objects.filter(
|
||||||
|
rack=self
|
||||||
|
).exclude(
|
||||||
|
position__isnull=True
|
||||||
|
).order_by('position').first()
|
||||||
|
if first_device:
|
||||||
|
if self.starting_unit > first_device.position:
|
||||||
|
raise ValidationError({
|
||||||
|
'starting_unit': "Rack must have a staring unit at most {} to house currently installed devices.".format(
|
||||||
|
first_device.position
|
||||||
|
)
|
||||||
|
})
|
||||||
# Validate that Rack was assigned a Location of its same site, if applicable
|
# Validate that Rack was assigned a Location of its same site, if applicable
|
||||||
if self.location:
|
if self.location:
|
||||||
if self.location.site != self.site:
|
if self.location.site != self.site:
|
||||||
|
Loading…
Reference in New Issue
Block a user