|
@@ -286,29 +286,6 @@ class DeviceViewSet(WritableSerializerMixin, CustomFieldModelViewSet):
|
|
|
return Response(response)
|
|
|
|
|
|
|
|
|
- @detail_route(url_path='lldp-neighbors')
|
|
|
- def lldp_neighbors(self, request, pk):
|
|
|
- """
|
|
|
- Retrieve live LLDP neighbors of a device
|
|
|
- """
|
|
|
- device = get_object_or_404(Device, pk=pk)
|
|
|
- if not device.primary_ip:
|
|
|
- raise ServiceUnavailable("No IP configured for this device.")
|
|
|
-
|
|
|
- RPC = device.get_rpc_client()
|
|
|
- if not RPC:
|
|
|
- raise ServiceUnavailable("No RPC client available for this platform ({}).".format(device.platform))
|
|
|
-
|
|
|
- # Connect to device and retrieve inventory info
|
|
|
- try:
|
|
|
- with RPC(device, username=settings.NETBOX_USERNAME, password=settings.NETBOX_PASSWORD) as rpc_client:
|
|
|
- lldp_neighbors = rpc_client.get_lldp_neighbors()
|
|
|
- except:
|
|
|
- raise ServiceUnavailable("Error connecting to the remote device.")
|
|
|
-
|
|
|
- return Response(lldp_neighbors)
|
|
|
-
|
|
|
-
|
|
|
#
|
|
|
# Device components
|
|
|
#
|