|
11 | 11 | from dcim.choices import * |
12 | 12 | from dcim.constants import * |
13 | 13 | from dcim.fields import WWNField |
| 14 | +from dcim.models.mixins import InterfaceValidationMixin |
14 | 15 | from netbox.choices import ColorChoices |
15 | 16 | from netbox.models import OrganizationalModel, NetBoxModel |
16 | 17 | from utilities.fields import ColorField, NaturalOrderingField |
@@ -676,7 +677,14 @@ def mac_address(self): |
676 | 677 | return self.primary_mac_address.mac_address |
677 | 678 |
|
678 | 679 |
|
679 | | -class Interface(ModularComponentModel, BaseInterface, CabledObjectModel, PathEndpoint, TrackingModelMixin): |
| 680 | +class Interface( |
| 681 | + InterfaceValidationMixin, |
| 682 | + ModularComponentModel, |
| 683 | + BaseInterface, |
| 684 | + CabledObjectModel, |
| 685 | + PathEndpoint, |
| 686 | + TrackingModelMixin, |
| 687 | +): |
680 | 688 | """ |
681 | 689 | A network interface within a Device. A physical Interface can connect to exactly one other Interface. |
682 | 690 | """ |
@@ -893,10 +901,6 @@ def clean(self): |
893 | 901 |
|
894 | 902 | # Bridge validation |
895 | 903 |
|
896 | | - # An interface cannot be bridged to itself |
897 | | - if self.pk and self.bridge_id == self.pk: |
898 | | - raise ValidationError({'bridge': _("An interface cannot be bridged to itself.")}) |
899 | | - |
900 | 904 | # A bridged interface belongs to the same device or virtual chassis |
901 | 905 | if self.bridge and self.bridge.device != self.device: |
902 | 906 | if self.device.virtual_chassis is None: |
@@ -942,29 +946,9 @@ def clean(self): |
942 | 946 | ) |
943 | 947 | }) |
944 | 948 |
|
945 | | - # PoE validation |
946 | | - |
947 | | - # Only physical interfaces may have a PoE mode/type assigned |
948 | | - if self.poe_mode and self.is_virtual: |
949 | | - raise ValidationError({ |
950 | | - 'poe_mode': _("Virtual interfaces cannot have a PoE mode.") |
951 | | - }) |
952 | | - if self.poe_type and self.is_virtual: |
953 | | - raise ValidationError({ |
954 | | - 'poe_type': _("Virtual interfaces cannot have a PoE type.") |
955 | | - }) |
956 | | - |
957 | | - # An interface with a PoE type set must also specify a mode |
958 | | - if self.poe_type and not self.poe_mode: |
959 | | - raise ValidationError({ |
960 | | - 'poe_type': _("Must specify PoE mode when designating a PoE type.") |
961 | | - }) |
962 | | - |
963 | 949 | # Wireless validation |
964 | 950 |
|
965 | | - # RF role & channel may only be set for wireless interfaces |
966 | | - if self.rf_role and not self.is_wireless: |
967 | | - raise ValidationError({'rf_role': _("Wireless role may be set only on wireless interfaces.")}) |
| 951 | + # RF channel may only be set for wireless interfaces |
968 | 952 | if self.rf_channel and not self.is_wireless: |
969 | 953 | raise ValidationError({'rf_channel': _("Channel may be set only on wireless interfaces.")}) |
970 | 954 |
|
|
0 commit comments