Просмотр исходного кода

Rename connection_status to connected_endpoint_reachable

Jeremy Stretch 5 лет назад
Родитель
Сommit
b846f631a4

+ 6 - 0
docs/release-notes/version-2.10.md

@@ -61,10 +61,16 @@ All end-to-end cable paths are now cached using the new CablePath model. This al
 ### REST API Changes
 
 * Added support for `PUT`, `PATCH`, and `DELETE` operations on list endpoints
+* circuits.CircuitTermination: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
 * dcim.Cable: Added `custom_fields`
+* dcim.ConsolePort: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
+* dcim.ConsoleServerPort: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
 * dcim.FrontPort: Removed the `trace` endpoint
+* dcim.Interface: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
 * dcim.InventoryItem: The `_depth` field has been added to reflect MPTT positioning
+* dcim.PowerOutlet: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
 * dcim.PowerPanel: Added `custom_fields`
+* dcim.PowerPort: Replaced `connection_status` with `connected_endpoint_reachable` (boolean)
 * dcim.RackReservation: Added `custom_fields`
 * dcim.RearPort: Removed the `trace` endpoint
 * dcim.VirtualChassis: Added `custom_fields`

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

@@ -77,5 +77,5 @@ class CircuitTerminationSerializer(ConnectedEndpointSerializer):
         model = CircuitTermination
         fields = [
             'id', 'url', 'circuit', 'term_side', 'site', 'port_speed', 'upstream_speed', 'xconnect_id', 'pp_info',
-            'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable',
+            'description', 'connected_endpoint_type', 'connected_endpoint', 'connected_endpoint_reachable', 'cable',
         ]

+ 9 - 10
netbox/dcim/api/serializers.py

@@ -30,7 +30,7 @@ from .nested_serializers import *
 class ConnectedEndpointSerializer(ValidatedModelSerializer):
     connected_endpoint_type = serializers.SerializerMethodField(read_only=True)
     connected_endpoint = serializers.SerializerMethodField(read_only=True)
-    connection_status = serializers.SerializerMethodField(read_only=True)
+    connected_endpoint_reachable = serializers.SerializerMethodField(read_only=True)
 
     def get_connected_endpoint_type(self, obj):
         if obj._path is not None and obj._path.destination is not None:
@@ -48,9 +48,8 @@ class ConnectedEndpointSerializer(ValidatedModelSerializer):
             return serializer(obj._path.destination, context=context).data
         return None
 
-    # TODO: Tweak the representation for this field
     @swagger_serializer_method(serializer_or_field=serializers.BooleanField)
-    def get_connection_status(self, obj):
+    def get_connected_endpoint_reachable(self, obj):
         if obj._path is not None:
             return obj._path.is_active
         return None
@@ -467,7 +466,7 @@ class ConsoleServerPortSerializer(TaggedObjectSerializer, ConnectedEndpointSeria
         model = ConsoleServerPort
         fields = [
             'id', 'url', 'device', 'name', 'label', 'type', 'description', 'connected_endpoint_type',
-            'connected_endpoint', 'connection_status', 'cable', 'tags',
+            'connected_endpoint', 'connected_endpoint_reachable', 'cable', 'tags',
         ]
 
 
@@ -485,7 +484,7 @@ class ConsolePortSerializer(TaggedObjectSerializer, ConnectedEndpointSerializer)
         model = ConsolePort
         fields = [
             'id', 'url', 'device', 'name', 'label', 'type', 'description', 'connected_endpoint_type',
-            'connected_endpoint', 'connection_status', 'cable', 'tags',
+            'connected_endpoint', 'connected_endpoint_reachable', 'cable', 'tags',
         ]
 
 
@@ -513,7 +512,7 @@ class PowerOutletSerializer(TaggedObjectSerializer, ConnectedEndpointSerializer)
         model = PowerOutlet
         fields = [
             'id', 'url', 'device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description',
-            'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable', 'tags',
+            'connected_endpoint_type', 'connected_endpoint', 'connected_endpoint_reachable', 'cable', 'tags',
         ]
 
 
@@ -531,7 +530,7 @@ class PowerPortSerializer(TaggedObjectSerializer, ConnectedEndpointSerializer):
         model = PowerPort
         fields = [
             'id', 'url', 'device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description',
-            'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable', 'tags',
+            'connected_endpoint_type', 'connected_endpoint', 'connected_endpoint_reachable', 'cable', 'tags',
         ]
 
 
@@ -555,8 +554,8 @@ class InterfaceSerializer(TaggedObjectSerializer, ConnectedEndpointSerializer):
         model = Interface
         fields = [
             'id', 'url', 'device', 'name', 'label', 'type', 'enabled', 'lag', 'mtu', 'mac_address', 'mgmt_only',
-            'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable', 'mode',
-            'untagged_vlan', 'tagged_vlans', 'tags', 'count_ipaddresses',
+            'description', 'connected_endpoint_type', 'connected_endpoint', 'connected_endpoint_reachable', 'cable',
+            'mode', 'untagged_vlan', 'tagged_vlans', 'tags', 'count_ipaddresses',
         ]
 
     # TODO: This validation should be handled by Interface.clean()
@@ -720,7 +719,7 @@ class InterfaceConnectionSerializer(ValidatedModelSerializer):
 
     class Meta:
         model = Interface
-        fields = ['interface_a', 'interface_b', 'connection_status']
+        fields = ['interface_a', 'interface_b']
 
     @swagger_serializer_method(serializer_or_field=NestedInterfaceSerializer)
     def get_interface_a(self, obj):

+ 0 - 6
netbox/dcim/constants.py

@@ -59,12 +59,6 @@ POWERFEED_MAX_UTILIZATION_DEFAULT = 80  # Percentage
 # Cabling and connections
 #
 
-# Console/power/interface connection statuses
-CONNECTION_STATUS_CHOICES = [
-    [False, 'Not Connected'],
-    [True, 'Connected'],
-]
-
 # Cable endpoint types
 CABLE_TERMINATION_MODELS = Q(
     Q(app_label='circuits', model__in=(

+ 0 - 5
netbox/dcim/tests/test_views.py

@@ -1714,11 +1714,6 @@ class PowerFeedTestCase(ViewTestCases.PrimaryObjectViewTestCase):
             'max_utilization': 50,
             'comments': 'New comments',
             'tags': [t.pk for t in tags],
-
-            # Connection
-            'cable': None,
-            'connected_endpoint': None,
-            'connection_status': None,
         }
 
         cls.csv_data = (

+ 2 - 2
netbox/utilities/custom_inspectors.py

@@ -62,8 +62,8 @@ class ChoiceFieldInspector(FieldInspector):
             value_schema = openapi.Schema(type=openapi.TYPE_STRING, enum=choice_value)
 
             if set([None] + choice_value) == {None, True, False}:
-                # DeviceType.subdevice_role, Device.face and InterfaceConnection.connection_status all need to be
-                # differentiated since they each have subtly different values in their choice keys.
+                # DeviceType.subdevice_role and Device.face need to be differentiated since they each have
+                # subtly different values in their choice keys.
                 # - subdevice_role and connection_status are booleans, although subdevice_role includes None
                 # - face is an integer set {0, 1} which is easily confused with {False, True}
                 schema_type = openapi.TYPE_STRING