فهرست منبع

Fixes #7647: Require interface assignment when designating IP address as primary for device/VM during CSV import

jeremystretch 4 سال پیش
والد
کامیت
dfdeac4968
2فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 8 1
      netbox/ipam/forms/bulk_import.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -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
 
 
 ---
 ---
 
 

+ 8 - 1
netbox/ipam/forms/bulk_import.py

@@ -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):