Skip to content

Commit bc812e4

Browse files
committed
Closes #5223: Remove the console/power/interface connections REST API endpoints
1 parent 38d7b83 commit bc812e4

File tree

4 files changed

+6
-62
lines changed

4 files changed

+6
-62
lines changed

docs/release-notes/version-3.0.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Support for queryset caching configuration (`caching_config`) has been removed from the plugins API (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
99
* The `cacheops_*` metrics have been removed from the Prometheus exporter (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
1010
* The `invalidate` management command has been removed.
11+
* The redundant REST API endpoints for console, power, and interface connections have been removed. The same data can be retrieved using the respective model endpoints with the `?connected=True` filter applied.
1112

1213
### New Features
1314

@@ -63,6 +64,7 @@ CustomValidator can also be subclassed to enforce more complex logic by overridi
6364

6465
### Other Changes
6566

67+
* [#5223](https://github.com/netbox-community/netbox/issues/5223) - Remove the console/power/interface connections REST API endpoints
6668
* [#5532](https://github.com/netbox-community/netbox/issues/5532) - Drop support for Python 3.6
6769
* [#5994](https://github.com/netbox-community/netbox/issues/5994) - Drop support for `display_field` argument on ObjectVar
6870
* [#6068](https://github.com/netbox-community/netbox/issues/6068) - Drop support for legacy static CSV export
@@ -79,6 +81,10 @@ CustomValidator can also be subclassed to enforce more complex logic by overridi
7981

8082
* Added the `/api/users/tokens/` endpoint
8183
* The `provision/` child endpoint can be used to provision new REST API tokens by supplying a valid username and password
84+
* Removed the following "connections" endpoints:
85+
* `/api/dcim/console-connections`
86+
* `/api/dcim/power-connections`
87+
* `/api/dcim/interface-connections`
8288
* dcim.Cable
8389
* `length` is now a decimal value
8490
* dcim.Device

netbox/dcim/api/serializers.py

-25
Original file line numberDiff line numberDiff line change
@@ -841,31 +841,6 @@ def get_path(self, obj):
841841
return ret
842842

843843

844-
#
845-
# Interface connections
846-
#
847-
848-
class InterfaceConnectionSerializer(ValidatedModelSerializer):
849-
interface_a = serializers.SerializerMethodField()
850-
interface_b = NestedInterfaceSerializer(source='_path.destination')
851-
connected_endpoint_reachable = serializers.SerializerMethodField(read_only=True)
852-
853-
class Meta:
854-
model = Interface
855-
fields = ['interface_a', 'interface_b', 'connected_endpoint_reachable']
856-
857-
@swagger_serializer_method(serializer_or_field=NestedInterfaceSerializer)
858-
def get_interface_a(self, obj):
859-
context = {'request': self.context['request']}
860-
return NestedInterfaceSerializer(instance=obj, context=context).data
861-
862-
@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
863-
def get_connected_endpoint_reachable(self, obj):
864-
if obj._path is not None:
865-
return obj._path.is_active
866-
return None
867-
868-
869844
#
870845
# Virtual chassis
871846
#

netbox/dcim/api/urls.py

-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
router.register('device-bays', views.DeviceBayViewSet)
4747
router.register('inventory-items', views.InventoryItemViewSet)
4848

49-
# Connections
50-
router.register('console-connections', views.ConsoleConnectionViewSet, basename='consoleconnections')
51-
router.register('power-connections', views.PowerConnectionViewSet, basename='powerconnections')
52-
router.register('interface-connections', views.InterfaceConnectionViewSet, basename='interfaceconnections')
53-
5449
# Cables
5550
router.register('cables', views.CableViewSet)
5651

netbox/dcim/api/views.py

-32
Original file line numberDiff line numberDiff line change
@@ -570,38 +570,6 @@ class InventoryItemViewSet(ModelViewSet):
570570
brief_prefetch_fields = ['device']
571571

572572

573-
#
574-
# Connections
575-
#
576-
577-
class ConsoleConnectionViewSet(ListModelMixin, GenericViewSet):
578-
queryset = ConsolePort.objects.prefetch_related('device', '_path').filter(
579-
_path__destination_id__isnull=False
580-
)
581-
serializer_class = serializers.ConsolePortSerializer
582-
filterset_class = filtersets.ConsoleConnectionFilterSet
583-
584-
585-
class PowerConnectionViewSet(ListModelMixin, GenericViewSet):
586-
queryset = PowerPort.objects.prefetch_related('device', '_path').filter(
587-
_path__destination_id__isnull=False
588-
)
589-
serializer_class = serializers.PowerPortSerializer
590-
filterset_class = filtersets.PowerConnectionFilterSet
591-
592-
593-
class InterfaceConnectionViewSet(ListModelMixin, GenericViewSet):
594-
queryset = Interface.objects.prefetch_related('device', '_path').filter(
595-
# Avoid duplicate connections by only selecting the lower PK in a connected pair
596-
_path__destination_type__app_label='dcim',
597-
_path__destination_type__model='interface',
598-
_path__destination_id__isnull=False,
599-
pk__lt=F('_path__destination_id')
600-
)
601-
serializer_class = serializers.InterfaceConnectionSerializer
602-
filterset_class = filtersets.InterfaceConnectionFilterSet
603-
604-
605573
#
606574
# Cables
607575
#

0 commit comments

Comments
 (0)