mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fixes #7647: Require interface assignment when designating IP address as primary for device/VM during CSV import
This commit is contained in:
parent
e84f2e3ad2
commit
dfdeac4968
@ -9,6 +9,7 @@
|
|||||||
* [#7628](https://github.com/netbox-community/netbox/issues/7628) - Fix `load_yaml` method for custom scripts
|
* [#7628](https://github.com/netbox-community/netbox/issues/7628) - Fix `load_yaml` method for custom scripts
|
||||||
* [#7643](https://github.com/netbox-community/netbox/issues/7643) - Fix circuit assignment when creating multiple terminations simultaneously
|
* [#7643](https://github.com/netbox-community/netbox/issues/7643) - Fix circuit assignment when creating multiple terminations simultaneously
|
||||||
* [#7644](https://github.com/netbox-community/netbox/issues/7644) - Prevent inadvertent deletion of prior change records when deleting objects (#7333 revisited)
|
* [#7644](https://github.com/netbox-community/netbox/issues/7644) - Prevent inadvertent deletion of prior change records when deleting objects (#7333 revisited)
|
||||||
|
* [#7647](https://github.com/netbox-community/netbox/issues/7647) - Require interface assignment when designating IP address as primary for device/VM during CSV import
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -257,11 +257,18 @@ class IPAddressCSVForm(CustomFieldModelCSVForm):
|
|||||||
|
|
||||||
device = self.cleaned_data.get('device')
|
device = self.cleaned_data.get('device')
|
||||||
virtual_machine = self.cleaned_data.get('virtual_machine')
|
virtual_machine = self.cleaned_data.get('virtual_machine')
|
||||||
|
interface = self.cleaned_data.get('interface')
|
||||||
is_primary = self.cleaned_data.get('is_primary')
|
is_primary = self.cleaned_data.get('is_primary')
|
||||||
|
|
||||||
# Validate is_primary
|
# Validate is_primary
|
||||||
if is_primary and not device and not virtual_machine:
|
if is_primary and not device and not virtual_machine:
|
||||||
raise forms.ValidationError("No device or virtual machine specified; cannot set as primary IP")
|
raise forms.ValidationError({
|
||||||
|
"is_primary": "No device or virtual machine specified; cannot set as primary IP"
|
||||||
|
})
|
||||||
|
if is_primary and not interface:
|
||||||
|
raise forms.ValidationError({
|
||||||
|
"is_primary": "No interface specified; cannot set as primary IP"
|
||||||
|
})
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user