Procházet zdrojové kódy

Fixes #2127: Prevent non-conntectable interfaces from being connected

Jeremy Stretch před 7 roky
rodič
revize
643b0eaf65
1 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. 12 0
      netbox/dcim/models.py

+ 12 - 0
netbox/dcim/models.py

@@ -1536,6 +1536,18 @@ class InterfaceConnection(models.Model):
                 raise ValidationError({
                 raise ValidationError({
                     'interface_b': "Cannot connect an interface to itself."
                     'interface_b': "Cannot connect an interface to itself."
                 })
                 })
+            if self.interface_a.form_factor in NONCONNECTABLE_IFACE_TYPES:
+                raise ValidationError({
+                    'interface_a': '{} is not a connectable interface type.'.format(
+                        self.interface_a.get_form_factor_display()
+                    )
+                })
+            if self.interface_b.form_factor in NONCONNECTABLE_IFACE_TYPES:
+                raise ValidationError({
+                    'interface_b': '{} is not a connectable interface type.'.format(
+                        self.interface_b.get_form_factor_display()
+                    )
+                })
         except ObjectDoesNotExist:
         except ObjectDoesNotExist:
             pass
             pass