mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixes #6695: Fix exception when importing device type with invalid front port definition
This commit is contained in:
parent
631d991d8d
commit
70585ff32e
@ -17,7 +17,8 @@
|
|||||||
* [#6640](https://github.com/netbox-community/netbox/issues/6640) - Disallow numeric values in custom text fields
|
* [#6640](https://github.com/netbox-community/netbox/issues/6640) - Disallow numeric values in custom text fields
|
||||||
* [#6652](https://github.com/netbox-community/netbox/issues/6652) - Fix exception when adding components in bulk to multiple devices
|
* [#6652](https://github.com/netbox-community/netbox/issues/6652) - Fix exception when adding components in bulk to multiple devices
|
||||||
* [#6676](https://github.com/netbox-community/netbox/issues/6676) - Fix device/VM counts per cluster under cluster type/group views
|
* [#6676](https://github.com/netbox-community/netbox/issues/6676) - Fix device/VM counts per cluster under cluster type/group views
|
||||||
* [#6680](https://github.com/netbox-community/netbox/issues/6680) - Allow setting custom field values for VM interfaces on intial creation
|
* [#6680](https://github.com/netbox-community/netbox/issues/6680) - Allow setting custom field values for VM interfaces on initial creation
|
||||||
|
* [#6695](https://github.com/netbox-community/netbox/issues/6695) - Fix exception when importing device type with invalid front port definition
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1878,8 +1878,7 @@ class FrontPortTemplateImportForm(ComponentTemplateImportForm):
|
|||||||
)
|
)
|
||||||
rear_port = forms.ModelChoiceField(
|
rear_port = forms.ModelChoiceField(
|
||||||
queryset=RearPortTemplate.objects.all(),
|
queryset=RearPortTemplate.objects.all(),
|
||||||
to_field_name='name',
|
to_field_name='name'
|
||||||
required=False
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -290,19 +290,24 @@ class FrontPortTemplate(ComponentTemplateModel):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
# Validate rear port assignment
|
try:
|
||||||
if self.rear_port.device_type != self.device_type:
|
|
||||||
raise ValidationError(
|
|
||||||
"Rear port ({}) must belong to the same device type".format(self.rear_port)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Validate rear port position assignment
|
# Validate rear port assignment
|
||||||
if self.rear_port_position > self.rear_port.positions:
|
if self.rear_port.device_type != self.device_type:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"Invalid rear port position ({}); rear port {} has only {} positions".format(
|
"Rear port ({}) must belong to the same device type".format(self.rear_port)
|
||||||
self.rear_port_position, self.rear_port.name, self.rear_port.positions
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
# Validate rear port position assignment
|
||||||
|
if self.rear_port_position > self.rear_port.positions:
|
||||||
|
raise ValidationError(
|
||||||
|
"Invalid rear port position ({}); rear port {} has only {} positions".format(
|
||||||
|
self.rear_port_position, self.rear_port.name, self.rear_port.positions
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
except RearPortTemplate.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
def instantiate(self, device):
|
def instantiate(self, device):
|
||||||
if self.rear_port:
|
if self.rear_port:
|
||||||
|
Loading…
Reference in New Issue
Block a user