Skip to content

Commit

Permalink
Closes #5223: Remove the console/power/interface connections REST API…
Browse files Browse the repository at this point in the history
… endpoints
  • Loading branch information
jeremystretch committed Jul 8, 2021
1 parent 38d7b83 commit bc812e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 62 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes/version-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Support for queryset caching configuration (`caching_config`) has been removed from the plugins API (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
* The `cacheops_*` metrics have been removed from the Prometheus exporter (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
* The `invalidate` management command has been removed.
* 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.

### New Features

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

### Other Changes

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

* Added the `/api/users/tokens/` endpoint
* The `provision/` child endpoint can be used to provision new REST API tokens by supplying a valid username and password
* Removed the following "connections" endpoints:
* `/api/dcim/console-connections`
* `/api/dcim/power-connections`
* `/api/dcim/interface-connections`
* dcim.Cable
* `length` is now a decimal value
* dcim.Device
Expand Down
25 changes: 0 additions & 25 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,31 +841,6 @@ def get_path(self, obj):
return ret


#
# Interface connections
#

class InterfaceConnectionSerializer(ValidatedModelSerializer):
interface_a = serializers.SerializerMethodField()
interface_b = NestedInterfaceSerializer(source='_path.destination')
connected_endpoint_reachable = serializers.SerializerMethodField(read_only=True)

class Meta:
model = Interface
fields = ['interface_a', 'interface_b', 'connected_endpoint_reachable']

@swagger_serializer_method(serializer_or_field=NestedInterfaceSerializer)
def get_interface_a(self, obj):
context = {'request': self.context['request']}
return NestedInterfaceSerializer(instance=obj, context=context).data

@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
def get_connected_endpoint_reachable(self, obj):
if obj._path is not None:
return obj._path.is_active
return None


#
# Virtual chassis
#
Expand Down
5 changes: 0 additions & 5 deletions netbox/dcim/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
router.register('device-bays', views.DeviceBayViewSet)
router.register('inventory-items', views.InventoryItemViewSet)

# Connections
router.register('console-connections', views.ConsoleConnectionViewSet, basename='consoleconnections')
router.register('power-connections', views.PowerConnectionViewSet, basename='powerconnections')
router.register('interface-connections', views.InterfaceConnectionViewSet, basename='interfaceconnections')

# Cables
router.register('cables', views.CableViewSet)

Expand Down
32 changes: 0 additions & 32 deletions netbox/dcim/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,38 +570,6 @@ class InventoryItemViewSet(ModelViewSet):
brief_prefetch_fields = ['device']


#
# Connections
#

class ConsoleConnectionViewSet(ListModelMixin, GenericViewSet):
queryset = ConsolePort.objects.prefetch_related('device', '_path').filter(
_path__destination_id__isnull=False
)
serializer_class = serializers.ConsolePortSerializer
filterset_class = filtersets.ConsoleConnectionFilterSet


class PowerConnectionViewSet(ListModelMixin, GenericViewSet):
queryset = PowerPort.objects.prefetch_related('device', '_path').filter(
_path__destination_id__isnull=False
)
serializer_class = serializers.PowerPortSerializer
filterset_class = filtersets.PowerConnectionFilterSet


class InterfaceConnectionViewSet(ListModelMixin, GenericViewSet):
queryset = Interface.objects.prefetch_related('device', '_path').filter(
# Avoid duplicate connections by only selecting the lower PK in a connected pair
_path__destination_type__app_label='dcim',
_path__destination_type__model='interface',
_path__destination_id__isnull=False,
pk__lt=F('_path__destination_id')
)
serializer_class = serializers.InterfaceConnectionSerializer
filterset_class = filtersets.InterfaceConnectionFilterSet


#
# Cables
#
Expand Down

0 comments on commit bc812e4

Please sign in to comment.