mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Remove legacy connection_status fields
This commit is contained in:
parent
079c42291c
commit
df73737128
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1 on 2020-10-05 13:56
|
# Generated by Django 3.1 on 2020-10-05 14:07
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
@ -14,4 +14,8 @@ class Migration(migrations.Migration):
|
|||||||
model_name='circuittermination',
|
model_name='circuittermination',
|
||||||
name='connected_endpoint',
|
name='connected_endpoint',
|
||||||
),
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='circuittermination',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -2,7 +2,6 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from taggit.managers import TaggableManager
|
from taggit.managers import TaggableManager
|
||||||
|
|
||||||
from dcim.constants import CONNECTION_STATUS_CHOICES
|
|
||||||
from dcim.fields import ASNField
|
from dcim.fields import ASNField
|
||||||
from dcim.models import CableTermination, PathEndpoint
|
from dcim.models import CableTermination, PathEndpoint
|
||||||
from extras.models import ChangeLoggedModel, CustomFieldModel, ObjectChange, TaggedItem
|
from extras.models import ChangeLoggedModel, CustomFieldModel, ObjectChange, TaggedItem
|
||||||
@ -248,11 +247,6 @@ class CircuitTermination(PathEndpoint, CableTermination):
|
|||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
related_name='circuit_terminations'
|
related_name='circuit_terminations'
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
port_speed = models.PositiveIntegerField(
|
port_speed = models.PositiveIntegerField(
|
||||||
verbose_name='Port speed (Kbps)'
|
verbose_name='Port speed (Kbps)'
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from dcim.constants import CONNECTION_STATUS_CHOICES
|
|
||||||
from dcim import models
|
from dcim import models
|
||||||
from utilities.api import ChoiceField, WritableNestedSerializer
|
from utilities.api import WritableNestedSerializer
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'NestedCableSerializer',
|
'NestedCableSerializer',
|
||||||
@ -228,51 +227,46 @@ 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 = models.ConsoleServerPort
|
model = models.ConsoleServerPort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
fields = ['id', 'url', 'device', 'name', 'cable']
|
||||||
|
|
||||||
|
|
||||||
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 = models.ConsolePort
|
model = models.ConsolePort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
fields = ['id', 'url', 'device', 'name', 'cable']
|
||||||
|
|
||||||
|
|
||||||
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 = models.PowerOutlet
|
model = models.PowerOutlet
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
fields = ['id', 'url', 'device', 'name', 'cable']
|
||||||
|
|
||||||
|
|
||||||
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 = models.PowerPort
|
model = models.PowerPort
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
fields = ['id', 'url', 'device', 'name', 'cable']
|
||||||
|
|
||||||
|
|
||||||
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 = models.Interface
|
model = models.Interface
|
||||||
fields = ['id', 'url', 'device', 'name', 'cable', 'connection_status']
|
fields = ['id', 'url', 'device', 'name', 'cable']
|
||||||
|
|
||||||
|
|
||||||
class NestedRearPortSerializer(WritableNestedSerializer):
|
class NestedRearPortSerializer(WritableNestedSerializer):
|
||||||
|
@ -33,8 +33,8 @@ class ConnectedEndpointSerializer(ValidatedModelSerializer):
|
|||||||
connection_status = serializers.SerializerMethodField(read_only=True)
|
connection_status = serializers.SerializerMethodField(read_only=True)
|
||||||
|
|
||||||
def get_connected_endpoint_type(self, obj):
|
def get_connected_endpoint_type(self, obj):
|
||||||
if obj.path is not None:
|
if obj._path is not None and obj._path.destination is not None:
|
||||||
return f'{obj.connected_endpoint._meta.app_label}.{obj.connected_endpoint._meta.model_name}'
|
return f'{obj._path.destination._meta.app_label}.{obj._path.destination._meta.model_name}'
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@swagger_serializer_method(serializer_or_field=serializers.DictField)
|
@swagger_serializer_method(serializer_or_field=serializers.DictField)
|
||||||
@ -42,17 +42,17 @@ class ConnectedEndpointSerializer(ValidatedModelSerializer):
|
|||||||
"""
|
"""
|
||||||
Return the appropriate serializer for the type of connected object.
|
Return the appropriate serializer for the type of connected object.
|
||||||
"""
|
"""
|
||||||
if obj.path is not None:
|
if obj._path is not None and obj._path.destination is not None:
|
||||||
serializer = get_serializer_for_model(obj.connected_endpoint, prefix='Nested')
|
serializer = get_serializer_for_model(obj._path.destination, prefix='Nested')
|
||||||
context = {'request': self.context['request']}
|
context = {'request': self.context['request']}
|
||||||
return serializer(obj.path.destination, context=context).data
|
return serializer(obj._path.destination, context=context).data
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# TODO: Tweak the representation for this field
|
# TODO: Tweak the representation for this field
|
||||||
@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
|
@swagger_serializer_method(serializer_or_field=serializers.BooleanField)
|
||||||
def get_connection_status(self, obj):
|
def get_connection_status(self, obj):
|
||||||
if obj.path is not None:
|
if obj._path is not None:
|
||||||
return obj.path.is_connected
|
return obj._path.is_connected
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ class TracedCableSerializer(serializers.ModelSerializer):
|
|||||||
class InterfaceConnectionSerializer(ValidatedModelSerializer):
|
class InterfaceConnectionSerializer(ValidatedModelSerializer):
|
||||||
interface_a = serializers.SerializerMethodField()
|
interface_a = serializers.SerializerMethodField()
|
||||||
interface_b = NestedInterfaceSerializer(source='connected_endpoint')
|
interface_b = NestedInterfaceSerializer(source='connected_endpoint')
|
||||||
connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, required=False)
|
# connection_status = ChoiceField(choices=CONNECTION_STATUS_CHOICES, required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
|
@ -760,11 +760,7 @@ class PathEndpointFilterSet(django_filters.FilterSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def filter_is_connected(self, queryset, name, value):
|
def filter_is_connected(self, queryset, name, value):
|
||||||
kwargs = {'connected_paths': 1 if value else 0}
|
return queryset.filter(_path__is_connected=True)
|
||||||
# TODO: Boolean rather than Count()?
|
|
||||||
return queryset.annotate(
|
|
||||||
connected_paths=Count('_paths', filter=Q(_paths__is_connected=True))
|
|
||||||
).filter(**kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ConsolePortFilterSet(BaseFilterSet, DeviceComponentFilterSet, PathEndpointFilterSet):
|
class ConsolePortFilterSet(BaseFilterSet, DeviceComponentFilterSet, PathEndpointFilterSet):
|
||||||
@ -1169,7 +1165,7 @@ class ConsoleConnectionFilterSet(BaseFilterSet):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
fields = ['name', 'connection_status']
|
fields = ['name']
|
||||||
|
|
||||||
# TODO: Fix filters
|
# TODO: Fix filters
|
||||||
# def filter_site(self, queryset, name, value):
|
# def filter_site(self, queryset, name, value):
|
||||||
@ -1201,7 +1197,7 @@ class PowerConnectionFilterSet(BaseFilterSet):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
fields = ['name', 'connection_status']
|
fields = ['name']
|
||||||
|
|
||||||
# TODO: Fix filters
|
# TODO: Fix filters
|
||||||
# def filter_site(self, queryset, name, value):
|
# def filter_site(self, queryset, name, value):
|
||||||
@ -1233,7 +1229,7 @@ class InterfaceConnectionFilterSet(BaseFilterSet):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['connection_status']
|
fields = []
|
||||||
|
|
||||||
# TODO: Fix filters
|
# TODO: Fix filters
|
||||||
# def filter_site(self, queryset, name, value):
|
# def filter_site(self, queryset, name, value):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1 on 2020-10-05 13:56
|
# Generated by Django 3.1 on 2020-10-05 14:07
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
@ -14,6 +14,14 @@ class Migration(migrations.Migration):
|
|||||||
model_name='consoleport',
|
model_name='consoleport',
|
||||||
name='connected_endpoint',
|
name='connected_endpoint',
|
||||||
),
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='consoleport',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='consoleserverport',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='interface',
|
model_name='interface',
|
||||||
name='_connected_circuittermination',
|
name='_connected_circuittermination',
|
||||||
@ -22,10 +30,22 @@ class Migration(migrations.Migration):
|
|||||||
model_name='interface',
|
model_name='interface',
|
||||||
name='_connected_interface',
|
name='_connected_interface',
|
||||||
),
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='interface',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='powerfeed',
|
model_name='powerfeed',
|
||||||
name='connected_endpoint',
|
name='connected_endpoint',
|
||||||
),
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='powerfeed',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='poweroutlet',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name='powerport',
|
model_name='powerport',
|
||||||
name='_connected_powerfeed',
|
name='_connected_powerfeed',
|
||||||
@ -34,4 +54,8 @@ class Migration(migrations.Migration):
|
|||||||
model_name='powerport',
|
model_name='powerport',
|
||||||
name='_connected_poweroutlet',
|
name='_connected_poweroutlet',
|
||||||
),
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='powerport',
|
||||||
|
name='connection_status',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -175,11 +175,6 @@ class ConsolePort(CableTermination, PathEndpoint, ComponentModel):
|
|||||||
blank=True,
|
blank=True,
|
||||||
help_text='Physical port type'
|
help_text='Physical port type'
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
tags = TaggableManager(through=TaggedItem)
|
tags = TaggableManager(through=TaggedItem)
|
||||||
|
|
||||||
csv_headers = ['device', 'name', 'label', 'type', 'description']
|
csv_headers = ['device', 'name', 'label', 'type', 'description']
|
||||||
@ -216,11 +211,6 @@ class ConsoleServerPort(CableTermination, PathEndpoint, ComponentModel):
|
|||||||
blank=True,
|
blank=True,
|
||||||
help_text='Physical port type'
|
help_text='Physical port type'
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
tags = TaggableManager(through=TaggedItem)
|
tags = TaggableManager(through=TaggedItem)
|
||||||
|
|
||||||
csv_headers = ['device', 'name', 'label', 'type', 'description']
|
csv_headers = ['device', 'name', 'label', 'type', 'description']
|
||||||
@ -269,11 +259,6 @@ class PowerPort(CableTermination, PathEndpoint, ComponentModel):
|
|||||||
validators=[MinValueValidator(1)],
|
validators=[MinValueValidator(1)],
|
||||||
help_text="Allocated power draw (watts)"
|
help_text="Allocated power draw (watts)"
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
tags = TaggableManager(through=TaggedItem)
|
tags = TaggableManager(through=TaggedItem)
|
||||||
|
|
||||||
csv_headers = ['device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description']
|
csv_headers = ['device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description']
|
||||||
@ -368,11 +353,6 @@ class PowerOutlet(CableTermination, PathEndpoint, ComponentModel):
|
|||||||
blank=True,
|
blank=True,
|
||||||
help_text="Phase (for three-phase feeds)"
|
help_text="Phase (for three-phase feeds)"
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
tags = TaggableManager(through=TaggedItem)
|
tags = TaggableManager(through=TaggedItem)
|
||||||
|
|
||||||
csv_headers = ['device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description']
|
csv_headers = ['device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description']
|
||||||
@ -448,11 +428,6 @@ class Interface(CableTermination, PathEndpoint, ComponentModel, BaseInterface):
|
|||||||
max_length=100,
|
max_length=100,
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
lag = models.ForeignKey(
|
lag = models.ForeignKey(
|
||||||
to='self',
|
to='self',
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
|
@ -88,11 +88,6 @@ class PowerFeed(ChangeLoggedModel, PathEndpoint, CableTermination, CustomFieldMo
|
|||||||
blank=True,
|
blank=True,
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
connection_status = models.BooleanField(
|
|
||||||
choices=CONNECTION_STATUS_CHOICES,
|
|
||||||
blank=True,
|
|
||||||
null=True
|
|
||||||
)
|
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=50
|
max_length=50
|
||||||
)
|
)
|
||||||
|
@ -977,7 +977,7 @@ class DeviceTest(APIViewTestCases.APIViewTestCase):
|
|||||||
|
|
||||||
class ConsolePortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class ConsolePortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
brief_fields = ['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
@ -1016,7 +1016,7 @@ class ConsolePortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCa
|
|||||||
|
|
||||||
class ConsoleServerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class ConsoleServerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
||||||
model = ConsoleServerPort
|
model = ConsoleServerPort
|
||||||
brief_fields = ['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
@ -1055,7 +1055,7 @@ class ConsoleServerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIView
|
|||||||
|
|
||||||
class PowerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class PowerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
brief_fields = ['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
@ -1094,7 +1094,7 @@ class PowerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
|
|||||||
|
|
||||||
class PowerOutletTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class PowerOutletTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
||||||
model = PowerOutlet
|
model = PowerOutlet
|
||||||
brief_fields = ['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
@ -1133,7 +1133,7 @@ class PowerOutletTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCa
|
|||||||
|
|
||||||
class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
||||||
model = Interface
|
model = Interface
|
||||||
brief_fields = ['cable', 'connection_status', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
@ -1189,7 +1189,7 @@ class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class FrontPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class FrontPortTest(APIViewTestCases.APIViewTestCase):
|
||||||
model = FrontPort
|
model = FrontPort
|
||||||
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
@ -1247,7 +1247,7 @@ class FrontPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class RearPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase):
|
class RearPortTest(APIViewTestCases.APIViewTestCase):
|
||||||
model = RearPort
|
model = RearPort
|
||||||
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
brief_fields = ['cable', 'device', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
|
@ -26,7 +26,7 @@ def trace_path(node):
|
|||||||
position_stack = []
|
position_stack = []
|
||||||
is_connected = True
|
is_connected = True
|
||||||
|
|
||||||
if node.cable is None:
|
if node is None or node.cable is None:
|
||||||
return [], None, False
|
return [], None, False
|
||||||
|
|
||||||
while node.cable is not None:
|
while node.cable is not None:
|
||||||
|
@ -1018,36 +1018,31 @@ class DeviceView(ObjectView):
|
|||||||
|
|
||||||
# Console ports
|
# Console ports
|
||||||
consoleports = ConsolePort.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
consoleports = ConsolePort.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
||||||
Prefetch('_paths', queryset=CablePath.objects.filter(destination_id__isnull=False)),
|
'cable', '_path',
|
||||||
'cable',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Console server ports
|
# Console server ports
|
||||||
consoleserverports = ConsoleServerPort.objects.restrict(request.user, 'view').filter(
|
consoleserverports = ConsoleServerPort.objects.restrict(request.user, 'view').filter(
|
||||||
device=device
|
device=device
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
Prefetch('_paths', queryset=CablePath.objects.filter(destination_id__isnull=False)),
|
'cable', '_path',
|
||||||
'cable',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Power ports
|
# Power ports
|
||||||
powerports = PowerPort.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
powerports = PowerPort.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
||||||
Prefetch('_paths', queryset=CablePath.objects.filter(destination_id__isnull=False)),
|
'cable', '_path',
|
||||||
'cable',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Power outlets
|
# Power outlets
|
||||||
poweroutlets = PowerOutlet.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
poweroutlets = PowerOutlet.objects.restrict(request.user, 'view').filter(device=device).prefetch_related(
|
||||||
Prefetch('_paths', queryset=CablePath.objects.filter(destination_id__isnull=False)),
|
'cable', 'power_port', '_path',
|
||||||
'cable', 'power_port',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Interfaces
|
# Interfaces
|
||||||
interfaces = device.vc_interfaces.restrict(request.user, 'view').prefetch_related(
|
interfaces = device.vc_interfaces.restrict(request.user, 'view').prefetch_related(
|
||||||
Prefetch('_paths', queryset=CablePath.objects.filter(destination_id__isnull=False)),
|
|
||||||
Prefetch('ip_addresses', queryset=IPAddress.objects.restrict(request.user)),
|
Prefetch('ip_addresses', queryset=IPAddress.objects.restrict(request.user)),
|
||||||
Prefetch('member_interfaces', queryset=Interface.objects.restrict(request.user)),
|
Prefetch('member_interfaces', queryset=Interface.objects.restrict(request.user)),
|
||||||
'lag', 'cable', 'tags',
|
'lag', 'cable', '_path', 'tags',
|
||||||
)
|
)
|
||||||
|
|
||||||
# Front ports
|
# Front ports
|
||||||
|
Loading…
Reference in New Issue
Block a user