From b846f631a40d8d3162254ac883b2435270c56bb0 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 5 Oct 2020 11:32:39 -0400 Subject: [PATCH] Rename connection_status to connected_endpoint_reachable --- docs/release-notes/version-2.10.md | 6 ++++++ netbox/circuits/api/serializers.py | 2 +- netbox/dcim/api/serializers.py | 19 +++++++++---------- netbox/dcim/constants.py | 6 ------ netbox/dcim/tests/test_views.py | 5 ----- netbox/utilities/custom_inspectors.py | 4 ++-- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/docs/release-notes/version-2.10.md b/docs/release-notes/version-2.10.md index c49283d14..b43662a3e 100644 --- a/docs/release-notes/version-2.10.md +++ b/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` diff --git a/netbox/circuits/api/serializers.py b/netbox/circuits/api/serializers.py index 10ae5e5ee..03c9012af 100644 --- a/netbox/circuits/api/serializers.py +++ b/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', ] diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 144e764dc..42018c046 100644 --- a/netbox/dcim/api/serializers.py +++ b/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): diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index 961c458e0..804e5be03 100644 --- a/netbox/dcim/constants.py +++ b/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=( diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 83d8841df..f3d942112 100644 --- a/netbox/dcim/tests/test_views.py +++ b/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 = ( diff --git a/netbox/utilities/custom_inspectors.py b/netbox/utilities/custom_inspectors.py index 1d5c9c0a0..063d30016 100644 --- a/netbox/utilities/custom_inspectors.py +++ b/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