diff --git a/netbox/dcim/api/nested_serializers.py b/netbox/dcim/api/nested_serializers.py index 327d26703..29881a548 100644 --- a/netbox/dcim/api/nested_serializers.py +++ b/netbox/dcim/api/nested_serializers.py @@ -475,4 +475,4 @@ class NestedVirtualDeviceContextSerializer(WritableNestedSerializer): class Meta: model = models.VirtualDeviceContext - fields = ['id', 'url', 'display', 'name', 'identifier', 'device', 'vdc_type'] + fields = ['id', 'url', 'display', 'name', 'identifier', 'device'] diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 4eb5b417c..ce2b76f4d 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -317,7 +317,6 @@ class DeviceTypeSerializer(NetBoxModelSerializer): ) subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False) airflow = ChoiceField(choices=DeviceAirflowChoices, allow_blank=True, required=False) - vdc_type = ChoiceField(choices=VirtualDeviceContextTypeChoices, allow_blank=True, required=False) weight_unit = ChoiceField(choices=WeightUnitChoices, allow_blank=True, required=False) device_count = serializers.IntegerField(read_only=True) @@ -325,7 +324,7 @@ class DeviceTypeSerializer(NetBoxModelSerializer): model = DeviceType fields = [ 'id', 'url', 'display', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', - 'subdevice_role', 'vdc_type', 'airflow', 'weight', 'weight_unit', 'front_image', 'rear_image', 'comments', + 'subdevice_role', 'airflow', 'weight', 'weight_unit', 'front_image', 'rear_image', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', ] diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index e7221a893..2e384843c 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -435,9 +435,6 @@ class DeviceTypeFilterSet(NetBoxModelFilterSet): to_field_name='slug', label='Manufacturer (slug)', ) - vdc_type = django_filters.MultipleChoiceFilter( - choices=VirtualDeviceContextTypeChoices - ) has_front_image = django_filters.BooleanFilter( label='Has a front image', method='_has_front_image' @@ -486,7 +483,7 @@ class DeviceTypeFilterSet(NetBoxModelFilterSet): class Meta: model = DeviceType fields = [ - 'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight', 'weight_unit', 'vdc_type', + 'id', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight', 'weight_unit', ] def search(self, queryset, name, value): diff --git a/netbox/dcim/forms/filtersets.py b/netbox/dcim/forms/filtersets.py index ff10b8449..7714fb0d2 100644 --- a/netbox/dcim/forms/filtersets.py +++ b/netbox/dcim/forms/filtersets.py @@ -373,7 +373,7 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm): model = DeviceType fieldsets = ( (None, ('q', 'tag')), - ('Hardware', ('manufacturer_id', 'part_number', 'subdevice_role', 'airflow', 'vdc_type')), + ('Hardware', ('manufacturer_id', 'part_number', 'subdevice_role', 'airflow')), ('Images', ('has_front_image', 'has_rear_image')), ('Components', ( 'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces', @@ -397,10 +397,6 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm): choices=add_blank_choice(DeviceAirflowChoices), required=False ) - vdc_type = MultipleChoiceField( - choices=add_blank_choice(VirtualDeviceContextTypeChoices), - required=False - ) has_front_image = forms.NullBooleanField( required=False, label='Has a front image', diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 87eb078a9..d450a25d5 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -387,7 +387,7 @@ class DeviceTypeForm(NetBoxModelForm): 'manufacturer', 'model', 'slug', 'part_number', 'tags', )), ('Chassis', ( - 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'vdc_type' + 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', )), ('Attributes', ('weight', 'weight_unit')), ('Images', ('front_image', 'rear_image')), @@ -397,7 +397,7 @@ class DeviceTypeForm(NetBoxModelForm): model = DeviceType fields = [ 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', - 'vdc_type', 'weight', 'weight_unit', 'front_image', 'rear_image', 'comments', 'tags', + 'weight', 'weight_unit', 'front_image', 'rear_image', 'comments', 'tags', ] widgets = { 'airflow': StaticSelect(), @@ -1495,13 +1495,6 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm): 'rf_channel_width': "Populated by selected channel (if set)", } - def clean_vdc(self): - device = self.cleaned_data.get('device') - if device.device_type.vdc_type not in [VirtualDeviceContextTypeChoices.CISCO_ASA_CONTEXT, VirtualDeviceContextTypeChoices.CISCO_FTD_INSTANCE]\ - and len(self.cleaned_data.get('vdcs')) > 1: - raise forms.ValidationError(f"You cannot assign more then 1 VDC for {device.device_type}") - return self.cleaned_data.get('vdcs') - class FrontPortForm(ModularDeviceComponentForm): rear_port = DynamicModelChoiceField( diff --git a/netbox/dcim/migrations/0165_devicetype_vdc_type_virtualdevicecontext_and_more.py b/netbox/dcim/migrations/0165_virtualdevicecontexts.py similarity index 92% rename from netbox/dcim/migrations/0165_devicetype_vdc_type_virtualdevicecontext_and_more.py rename to netbox/dcim/migrations/0165_virtualdevicecontexts.py index 7a8632f1f..f72061005 100644 --- a/netbox/dcim/migrations/0165_devicetype_vdc_type_virtualdevicecontext_and_more.py +++ b/netbox/dcim/migrations/0165_virtualdevicecontexts.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.2 on 2022-11-01 19:38 +# Generated by Django 4.1.2 on 2022-11-02 13:24 from django.db import migrations, models import django.db.models.deletion @@ -16,11 +16,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AddField( - model_name='devicetype', - name='vdc_type', - field=models.CharField(blank=True, max_length=50), - ), migrations.CreateModel( name='VirtualDeviceContext', fields=[ diff --git a/netbox/dcim/migrations/0166_virtualdevicecontext_and_more.py b/netbox/dcim/migrations/0166_virtualdevicecontext_and_more.py deleted file mode 100644 index 62d2286d6..000000000 --- a/netbox/dcim/migrations/0166_virtualdevicecontext_and_more.py +++ /dev/null @@ -1,142 +0,0 @@ -# Generated by Django 4.1.1 on 2022-11-01 18:05 - -from django.db import migrations, models -import django.db.models.deletion -import taggit.managers -import utilities.json - - -class Migration(migrations.Migration): - - dependencies = [ - ('extras', '0082_exporttemplate_content_types'), - ('tenancy', '0008_unique_constraints'), - ('ipam', '0062_unique_constraints'), - ('dcim', '0165_remove_consoleport_dcim_consoleport_unique_device_name_and_more'), - ] - - operations = [ - migrations.CreateModel( - name='VirtualDeviceContext', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)), - ('created', models.DateTimeField(auto_now_add=True, null=True)), - ('last_updated', models.DateTimeField(auto_now=True, null=True)), - ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)), - ('name', models.CharField(max_length=64)), - ('status', models.CharField(blank=True, max_length=50)), - ('identifier', models.PositiveSmallIntegerField(blank=True, null=True)), - ('comments', models.TextField(blank=True)), - ], - options={ - 'ordering': ['name'], - }, - ), - migrations.RemoveConstraint( - model_name='consoleport', - name='dcim_consoleport_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='consoleserverport', - name='dcim_consoleserverport_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='devicebay', - name='dcim_devicebay_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='interface', - name='dcim_interface_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='modulebay', - name='dcim_modulebay_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='poweroutlet', - name='dcim_poweroutlet_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='powerport', - name='dcim_powerport_unique_device_name', - ), - migrations.RemoveConstraint( - model_name='rearport', - name='dcim_rearport_unique_device_name', - ), - migrations.AddField( - model_name='devicetype', - name='vdc_type', - field=models.CharField(blank=True, max_length=50), - ), - migrations.AddConstraint( - model_name='consoleport', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_consoleport_unique_device_name'), - ), - migrations.AddConstraint( - model_name='consoleserverport', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_consoleserverport_unique_device_name'), - ), - migrations.AddConstraint( - model_name='devicebay', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_devicebay_unique_device_name'), - ), - migrations.AddConstraint( - model_name='interface', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_interface_unique_device_name'), - ), - migrations.AddConstraint( - model_name='modulebay', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_modulebay_unique_device_name'), - ), - migrations.AddConstraint( - model_name='poweroutlet', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_poweroutlet_unique_device_name'), - ), - migrations.AddConstraint( - model_name='powerport', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_powerport_unique_device_name'), - ), - migrations.AddConstraint( - model_name='rearport', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_rearport_unique_device_name'), - ), - migrations.AddField( - model_name='virtualdevicecontext', - name='device', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vdcs', to='dcim.device'), - ), - migrations.AddField( - model_name='virtualdevicecontext', - name='primary_ip4', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='ipam.ipaddress'), - ), - migrations.AddField( - model_name='virtualdevicecontext', - name='primary_ip6', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='ipam.ipaddress'), - ), - migrations.AddField( - model_name='virtualdevicecontext', - name='tags', - field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'), - ), - migrations.AddField( - model_name='virtualdevicecontext', - name='tenant', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vdcs', to='tenancy.tenant'), - ), - migrations.AddField( - model_name='interface', - name='vdcs', - field=models.ManyToManyField(related_name='interfaces', to='dcim.virtualdevicecontext'), - ), - migrations.AddConstraint( - model_name='virtualdevicecontext', - constraint=models.UniqueConstraint(fields=('device', 'identifier'), name='dcim_virtualdevicecontext_device_identifiers', violation_error_message='A VDC with this identifier already exists on this device.'), - ), - migrations.AddConstraint( - model_name='virtualdevicecontext', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='dcim_virtualdevicecontext_name', violation_error_message='A VDC with this name already exists on this device.'), - ), - ] diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py index a2a1af489..244aab77a 100644 --- a/netbox/dcim/models/devices.py +++ b/netbox/dcim/models/devices.py @@ -129,12 +129,6 @@ class DeviceType(NetBoxModel, WeightMixin): choices=DeviceAirflowChoices, blank=True ) - vdc_type = models.CharField( - max_length=50, - blank=True, - choices=VirtualDeviceContextTypeChoices, - verbose_name='VDC Type' - ) front_image = models.ImageField( upload_to='devicetype-images', blank=True @@ -148,7 +142,7 @@ class DeviceType(NetBoxModel, WeightMixin): ) clone_fields = ( - 'manufacturer', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight', 'weight_unit', 'vdc_type' + 'manufacturer', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', 'weight', 'weight_unit' ) class Meta: @@ -1216,7 +1210,3 @@ class VirtualDeviceContext(NetBoxModel): return self.primary_ip4 else: return None - - @property - def vdc_type(self): - return self.device.device_type.vdc_type diff --git a/netbox/dcim/signals.py b/netbox/dcim/signals.py index 67f033073..e04708d2c 100644 --- a/netbox/dcim/signals.py +++ b/netbox/dcim/signals.py @@ -125,14 +125,3 @@ def nullify_connected_endpoints(instance, **kwargs): for cablepath in CablePath.objects.filter(_nodes__contains=instance.cable): cablepath.retrace() - - -@receiver(m2m_changed, sender=Interface.vdcs.through) -def enforce_vdc_type_restrictions(instance, **kwargs): - if 'action' == 'post_add': - device = instance.device - if device.device_type.vdc_type not in [VirtualDeviceContextTypeChoices.CISCO_ASA_CONTEXT, VirtualDeviceContextTypeChoices.CISCO_FTD_INSTANCE] \ - and len(instance.vdcs) > 1: - raise forms.ValidationError({ - 'vdcs': f"You cannot assign more then 1 VDC for {device.device_type}" - }) diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index 62b5c171f..458c74ac1 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -57,12 +57,6 @@ {{ object.get_airflow_display|placeholder }} - - VDC Type - - {{ object.get_vdc_type_display|placeholder }} - - Front Image diff --git a/netbox/templates/dcim/virtualdevicecontext.html b/netbox/templates/dcim/virtualdevicecontext.html index d7f73e293..013552842 100644 --- a/netbox/templates/dcim/virtualdevicecontext.html +++ b/netbox/templates/dcim/virtualdevicecontext.html @@ -37,10 +37,6 @@ {{ object.identifier|placeholder }} - - VDC Type - {{ object.device.device_type.get_vdc_type_display |placeholder }} - Primary IPv4