mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
Fixes #5224: Don't allow a rear port to have fewer positions than the number of mapped front ports
This commit is contained in:
parent
4896059162
commit
a2c012d2c4
@ -16,6 +16,7 @@
|
|||||||
* [#5218](https://github.com/netbox-community/netbox/issues/5218) - Raise validation error if a power port's `allocated_draw` exceeds its `maximum_draw`
|
* [#5218](https://github.com/netbox-community/netbox/issues/5218) - Raise validation error if a power port's `allocated_draw` exceeds its `maximum_draw`
|
||||||
* [#5220](https://github.com/netbox-community/netbox/issues/5220) - Fix API patch request against IP Address endpoint with null assigned_object_type
|
* [#5220](https://github.com/netbox-community/netbox/issues/5220) - Fix API patch request against IP Address endpoint with null assigned_object_type
|
||||||
* [#5221](https://github.com/netbox-community/netbox/issues/5221) - Fix bulk component creation for virtual machines
|
* [#5221](https://github.com/netbox-community/netbox/issues/5221) - Fix bulk component creation for virtual machines
|
||||||
|
* [#5224](https://github.com/netbox-community/netbox/issues/5224) - Don't allow a rear port to have fewer positions than the number of mapped front ports
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -851,17 +851,16 @@ class FrontPort(CableTermination, ComponentModel):
|
|||||||
|
|
||||||
# Validate rear port assignment
|
# Validate rear port assignment
|
||||||
if self.rear_port.device != self.device:
|
if self.rear_port.device != self.device:
|
||||||
raise ValidationError(
|
raise ValidationError({
|
||||||
"Rear port ({}) must belong to the same device".format(self.rear_port)
|
"rear_port": f"Rear port ({self.rear_port}) must belong to the same device"
|
||||||
)
|
})
|
||||||
|
|
||||||
# Validate rear port position assignment
|
# Validate rear port position assignment
|
||||||
if self.rear_port_position > self.rear_port.positions:
|
if self.rear_port_position > self.rear_port.positions:
|
||||||
raise ValidationError(
|
raise ValidationError({
|
||||||
"Invalid rear port position ({}); rear port {} has only {} positions".format(
|
"rear_port_position": f"Invalid rear port position ({self.rear_port_position}): Rear port "
|
||||||
self.rear_port_position, self.rear_port.name, self.rear_port.positions
|
f"{self.rear_port.name} has only {self.rear_port.positions} positions"
|
||||||
)
|
})
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@extras_features('webhooks')
|
@extras_features('webhooks')
|
||||||
@ -891,6 +890,16 @@ class RearPort(CableTermination, ComponentModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('dcim:rearport', kwargs={'pk': self.pk})
|
return reverse('dcim:rearport', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
|
||||||
|
# Check that positions count is greater than or equal to the number of associated FrontPorts
|
||||||
|
frontport_count = self.frontports.count()
|
||||||
|
if self.positions < frontport_count:
|
||||||
|
raise ValidationError({
|
||||||
|
"positions": f"The number of positions cannot be less than the number of mapped front ports "
|
||||||
|
f"({frontport_count})"
|
||||||
|
})
|
||||||
|
|
||||||
def to_csv(self):
|
def to_csv(self):
|
||||||
return (
|
return (
|
||||||
self.device.identifier,
|
self.device.identifier,
|
||||||
|
Loading…
Reference in New Issue
Block a user