Jelajahi Sumber

Fixes #5045: Allow assignment of interfaces to non-master VC peer LAG during import

Jeremy Stretch 5 tahun lalu
induk
melakukan
df97eb2f72
2 mengubah file dengan 10 tambahan dan 4 penghapusan
  1. 1 0
      docs/release-notes/version-2.9.md
  2. 9 4
      netbox/dcim/forms.py

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

@@ -9,6 +9,7 @@
 * [#5040](https://github.com/netbox-community/netbox/issues/5040) - Limit SLAAC status to IPv6 addresses
 * [#5041](https://github.com/netbox-community/netbox/issues/5041) - Fix form tabs when assigning an IP to a VM interface
 * [#5042](https://github.com/netbox-community/netbox/issues/5042) - Fix display of SLAAC label for IP addresses status
+* [#5045](https://github.com/netbox-community/netbox/issues/5045) - Allow assignment of interfaces to non-master VC peer LAG during import
 
 ---
 

+ 9 - 4
netbox/dcim/forms.py

@@ -2879,17 +2879,22 @@ class InterfaceCSVForm(CSVModelForm):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
-        # Limit LAG choices to interfaces belonging to this device (or VC master)
+        # Limit LAG choices to interfaces belonging to this device (or virtual chassis)
         device = None
         if self.is_bound and 'device' in self.data:
             try:
                 device = self.fields['device'].to_python(self.data['device'])
             except forms.ValidationError:
                 pass
-
-        if device:
+        if device and device.virtual_chassis:
             self.fields['lag'].queryset = Interface.objects.filter(
-                device__in=[device, device.get_vc_master()], type=InterfaceTypeChoices.TYPE_LAG
+                Q(device=device) | Q(device__virtual_chassis=device.virtual_chassis),
+                type=InterfaceTypeChoices.TYPE_LAG
+            )
+        elif device:
+            self.fields['lag'].queryset = Interface.objects.filter(
+                device=device,
+                type=InterfaceTypeChoices.TYPE_LAG
             )
         else:
             self.fields['lag'].queryset = Interface.objects.none()