mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #2648: Include the connection_status field in nested represenations of connectable device components
This commit is contained in:
parent
71dee2758b
commit
64d37cd450
@ -42,12 +42,13 @@ NetBox now supports modeling physical cables for console, power, and interface c
|
|||||||
|
|
||||||
## Changes From v2.5-beta2
|
## Changes From v2.5-beta2
|
||||||
|
|
||||||
|
* [#2616](https://github.com/digitalocean/netbox/issues/2616) - Convert Rack `outer_unit` and Cable `length_unit` to integer-based choice fields
|
||||||
* [#2622](https://github.com/digitalocean/netbox/issues/2622) - Enable filtering cables by multiple types/colors
|
* [#2622](https://github.com/digitalocean/netbox/issues/2622) - Enable filtering cables by multiple types/colors
|
||||||
* [#2624](https://github.com/digitalocean/netbox/issues/2624) - Delete associated content type and permissions when removing InterfaceConnection model
|
* [#2624](https://github.com/digitalocean/netbox/issues/2624) - Delete associated content type and permissions when removing InterfaceConnection model
|
||||||
* [#2616](https://github.com/digitalocean/netbox/issues/2616) - Convert Rack `outer_unit` and Cable `length_unit` to integer-based choice fields
|
* [#2626](https://github.com/digitalocean/netbox/issues/2626) - Remove extraneous permissions generated from proxy models
|
||||||
* [#2632](https://github.com/digitalocean/netbox/issues/2632) - Change representation of null values from `0` to `null`
|
* [#2632](https://github.com/digitalocean/netbox/issues/2632) - Change representation of null values from `0` to `null`
|
||||||
* [#2639](https://github.com/digitalocean/netbox/issues/2639) - Fix preservation of length/dimensions unit for racks and cables
|
* [#2639](https://github.com/digitalocean/netbox/issues/2639) - Fix preservation of length/dimensions unit for racks and cables
|
||||||
* [#2626](https://github.com/digitalocean/netbox/issues/2626) - Remove extraneous permissions generated from proxy models
|
* [#2648](https://github.com/digitalocean/netbox/issues/2648) - Include the `connection_status` field in nested represenations of connectable device components
|
||||||
|
|
||||||
## API Changes
|
## API Changes
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from dcim.constants import CONNECTION_STATUS_CHOICES
|
||||||
from dcim.models import (
|
from dcim.models import (
|
||||||
Cable, ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceType, DeviceRole, FrontPort, FrontPortTemplate,
|
Cable, ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceType, DeviceRole, FrontPort, FrontPortTemplate,
|
||||||
Interface, Manufacturer, Platform, PowerOutlet, PowerPort, Rack, RackGroup, RackRole, RearPort, RearPortTemplate,
|
Interface, Manufacturer, Platform, PowerOutlet, PowerPort, Rack, RackGroup, RackRole, RearPort, RearPortTemplate,
|
||||||
Region, Site, VirtualChassis,
|
Region, Site, VirtualChassis,
|
||||||
)
|
)
|
||||||
from utilities.api import WritableNestedSerializer
|
from utilities.api import ChoiceField, WritableNestedSerializer
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'NestedCableSerializer',
|
'NestedCableSerializer',
|
||||||
@ -149,46 +150,51 @@ class NestedDeviceSerializer(WritableNestedSerializer):
|
|||||||
class NestedConsoleServerPortSerializer(WritableNestedSerializer):
|
class NestedConsoleServerPortSerializer(WritableNestedSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleserverport-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleserverport-detail')
|
||||||
device = NestedDeviceSerializer(read_only=True)
|
device = NestedDeviceSerializer(read_only=True)
|
||||||
|
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsoleServerPort
|
model = ConsoleServerPort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable']
|
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
||||||
|
|
||||||
|
|
||||||
class NestedConsolePortSerializer(WritableNestedSerializer):
|
class NestedConsolePortSerializer(WritableNestedSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleport-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleport-detail')
|
||||||
device = NestedDeviceSerializer(read_only=True)
|
device = NestedDeviceSerializer(read_only=True)
|
||||||
|
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable']
|
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
||||||
|
|
||||||
|
|
||||||
class NestedPowerOutletSerializer(WritableNestedSerializer):
|
class NestedPowerOutletSerializer(WritableNestedSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:poweroutlet-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:poweroutlet-detail')
|
||||||
device = NestedDeviceSerializer(read_only=True)
|
device = NestedDeviceSerializer(read_only=True)
|
||||||
|
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PowerOutlet
|
model = PowerOutlet
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable']
|
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
||||||
|
|
||||||
|
|
||||||
class NestedPowerPortSerializer(WritableNestedSerializer):
|
class NestedPowerPortSerializer(WritableNestedSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerport-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerport-detail')
|
||||||
device = NestedDeviceSerializer(read_only=True)
|
device = NestedDeviceSerializer(read_only=True)
|
||||||
|
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable']
|
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
||||||
|
|
||||||
|
|
||||||
class NestedInterfaceSerializer(WritableNestedSerializer):
|
class NestedInterfaceSerializer(WritableNestedSerializer):
|
||||||
device = NestedDeviceSerializer(read_only=True)
|
device = NestedDeviceSerializer(read_only=True)
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:interface-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='dcim-api:interface-detail')
|
||||||
|
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable']
|
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
||||||
|
|
||||||
|
|
||||||
class NestedRearPortSerializer(WritableNestedSerializer):
|
class NestedRearPortSerializer(WritableNestedSerializer):
|
||||||
|
@ -1951,7 +1951,7 @@ class ConsolePortTest(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(response.data['results'][0]),
|
sorted(response.data['results'][0]),
|
||||||
['cable', 'device', 'id', 'name', 'url']
|
['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_consoleport(self):
|
def test_create_consoleport(self):
|
||||||
@ -2064,7 +2064,7 @@ class ConsoleServerPortTest(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(response.data['results'][0]),
|
sorted(response.data['results'][0]),
|
||||||
['cable', 'device', 'id', 'name', 'url']
|
['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_consoleserverport(self):
|
def test_create_consoleserverport(self):
|
||||||
@ -2175,7 +2175,7 @@ class PowerPortTest(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(response.data['results'][0]),
|
sorted(response.data['results'][0]),
|
||||||
['cable', 'device', 'id', 'name', 'url']
|
['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_powerport(self):
|
def test_create_powerport(self):
|
||||||
@ -2288,7 +2288,7 @@ class PowerOutletTest(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(response.data['results'][0]),
|
sorted(response.data['results'][0]),
|
||||||
['cable', 'device', 'id', 'name', 'url']
|
['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_poweroutlet(self):
|
def test_create_poweroutlet(self):
|
||||||
@ -2425,7 +2425,7 @@ class InterfaceTest(APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(response.data['results'][0]),
|
sorted(response.data['results'][0]),
|
||||||
['cable', 'device', 'id', 'name', 'url']
|
['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_interface(self):
|
def test_create_interface(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user