Przeglądaj źródła

Fixes #8465: Accept empty string values for Interface rf_channel in REST API

jeremystretch 4 lat temu
rodzic
commit
19fdd5e151

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

@@ -15,6 +15,7 @@
 
 
 * [#8377](https://github.com/netbox-community/netbox/issues/8377) - Fix calculation of absolute cable lengths when specified in fractional units
 * [#8377](https://github.com/netbox-community/netbox/issues/8377) - Fix calculation of absolute cable lengths when specified in fractional units
 * [#8456](https://github.com/netbox-community/netbox/issues/8456) - Fix redundant display of VRF RD in prefix view
 * [#8456](https://github.com/netbox-community/netbox/issues/8456) - Fix redundant display of VRF RD in prefix view
+* [#8465](https://github.com/netbox-community/netbox/issues/8465) - Accept empty string values for Interface `rf_channel` in REST API
 
 
 ---
 ---
 
 

+ 1 - 1
netbox/dcim/api/serializers.py

@@ -621,7 +621,7 @@ class InterfaceSerializer(PrimaryModelSerializer, LinkTerminationSerializer, Con
     lag = NestedInterfaceSerializer(required=False, allow_null=True)
     lag = NestedInterfaceSerializer(required=False, allow_null=True)
     mode = ChoiceField(choices=InterfaceModeChoices, allow_blank=True, required=False)
     mode = ChoiceField(choices=InterfaceModeChoices, allow_blank=True, required=False)
     rf_role = ChoiceField(choices=WirelessRoleChoices, required=False, allow_null=True)
     rf_role = ChoiceField(choices=WirelessRoleChoices, required=False, allow_null=True)
-    rf_channel = ChoiceField(choices=WirelessChannelChoices, required=False)
+    rf_channel = ChoiceField(choices=WirelessChannelChoices, required=False, allow_blank=True)
     untagged_vlan = NestedVLANSerializer(required=False, allow_null=True)
     untagged_vlan = NestedVLANSerializer(required=False, allow_null=True)
     tagged_vlans = SerializedPKRelatedField(
     tagged_vlans = SerializedPKRelatedField(
         queryset=VLAN.objects.all(),
         queryset=VLAN.objects.all(),

+ 16 - 5
netbox/dcim/tests/test_api.py

@@ -9,6 +9,7 @@ from dcim.models import *
 from ipam.models import ASN, RIR, VLAN
 from ipam.models import ASN, RIR, VLAN
 from utilities.testing import APITestCase, APIViewTestCases
 from utilities.testing import APITestCase, APIViewTestCases
 from virtualization.models import Cluster, ClusterType
 from virtualization.models import Cluster, ClusterType
+from wireless.choices import WirelessChannelChoices
 from wireless.models import WirelessLAN
 from wireless.models import WirelessLAN
 
 
 
 
@@ -1239,10 +1240,8 @@ class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
                 'name': 'Interface 4',
                 'name': 'Interface 4',
                 'type': '1000base-t',
                 'type': '1000base-t',
                 'mode': InterfaceModeChoices.MODE_TAGGED,
                 'mode': InterfaceModeChoices.MODE_TAGGED,
-                'tx_power': 10,
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'untagged_vlan': vlans[2].pk,
                 'untagged_vlan': vlans[2].pk,
-                'wireless_lans': [wireless_lans[0].pk, wireless_lans[1].pk],
             },
             },
             {
             {
                 'device': device.pk,
                 'device': device.pk,
@@ -1250,10 +1249,8 @@ class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
                 'type': '1000base-t',
                 'type': '1000base-t',
                 'mode': InterfaceModeChoices.MODE_TAGGED,
                 'mode': InterfaceModeChoices.MODE_TAGGED,
                 'bridge': interfaces[0].pk,
                 'bridge': interfaces[0].pk,
-                'tx_power': 10,
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'untagged_vlan': vlans[2].pk,
                 'untagged_vlan': vlans[2].pk,
-                'wireless_lans': [wireless_lans[0].pk, wireless_lans[1].pk],
             },
             },
             {
             {
                 'device': device.pk,
                 'device': device.pk,
@@ -1261,10 +1258,24 @@ class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
                 'type': 'virtual',
                 'type': 'virtual',
                 'mode': InterfaceModeChoices.MODE_TAGGED,
                 'mode': InterfaceModeChoices.MODE_TAGGED,
                 'parent': interfaces[1].pk,
                 'parent': interfaces[1].pk,
-                'tx_power': 10,
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'tagged_vlans': [vlans[0].pk, vlans[1].pk],
                 'untagged_vlan': vlans[2].pk,
                 'untagged_vlan': vlans[2].pk,
+            },
+            {
+                'device': device.pk,
+                'name': 'Interface 7',
+                'type': InterfaceTypeChoices.TYPE_80211A,
+                'tx_power': 10,
+                'wireless_lans': [wireless_lans[0].pk, wireless_lans[1].pk],
+                'rf_channel': WirelessChannelChoices.CHANNEL_5G_32,
+            },
+            {
+                'device': device.pk,
+                'name': 'Interface 8',
+                'type': InterfaceTypeChoices.TYPE_80211A,
+                'tx_power': 10,
                 'wireless_lans': [wireless_lans[0].pk, wireless_lans[1].pk],
                 'wireless_lans': [wireless_lans[0].pk, wireless_lans[1].pk],
+                'rf_channel': "",
             },
             },
         ]
         ]