ソースを参照

Closes #12320: Remove obsolete fields napalm_driver and napalm_args from Platform

jeremystretch 2 年 前
コミット
4208b79514

+ 5 - 0
docs/release-notes/version-3.6.md

@@ -2,6 +2,11 @@
 
 ## v3.6.0 (FUTURE)
 
+### Breaking Changes
+
+* The `napalm_driver` and `napalm_args` fields (which were deprecated in v3.5) have been removed from the platform model.
+
 ### Other Changes
 
 * [#11766](https://github.com/netbox-community/netbox/issues/11766) - Remove obsolete custom `ChoiceField` and `MultipleChoiceField` classes
+* [#12320](https://github.com/netbox-community/netbox/issues/12320) - Remove obsolete fields `napalm_driver` and `napalm_args` from Platform

+ 2 - 2
netbox/dcim/api/serializers.py

@@ -635,8 +635,8 @@ class PlatformSerializer(NetBoxModelSerializer):
     class Meta:
         model = Platform
         fields = [
-            'id', 'url', 'display', 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args',
-            'description', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
+            'id', 'url', 'display', 'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags',
+            'custom_fields', 'created', 'last_updated', 'device_count', 'virtualmachine_count',
         ]
 
 

+ 1 - 1
netbox/dcim/filtersets.py

@@ -811,7 +811,7 @@ class PlatformFilterSet(OrganizationalModelFilterSet):
 
     class Meta:
         model = Platform
-        fields = ['id', 'name', 'slug', 'napalm_driver', 'description']
+        fields = ['id', 'name', 'slug', 'description']
 
 
 class DeviceFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSet, LocalConfigContextFilterSet):

+ 2 - 6
netbox/dcim/forms/bulk_edit.py

@@ -471,10 +471,6 @@ class PlatformBulkEditForm(NetBoxModelBulkEditForm):
         queryset=Manufacturer.objects.all(),
         required=False
     )
-    napalm_driver = forms.CharField(
-        max_length=50,
-        required=False
-    )
     config_template = DynamicModelChoiceField(
         queryset=ConfigTemplate.objects.all(),
         required=False
@@ -486,9 +482,9 @@ class PlatformBulkEditForm(NetBoxModelBulkEditForm):
 
     model = Platform
     fieldsets = (
-        (None, ('manufacturer', 'config_template', 'napalm_driver', 'description')),
+        (None, ('manufacturer', 'config_template', 'description')),
     )
-    nullable_fields = ('manufacturer', 'config_template', 'napalm_driver', 'description')
+    nullable_fields = ('manufacturer', 'config_template', 'description')
 
 
 class DeviceBulkEditForm(NetBoxModelBulkEditForm):

+ 1 - 1
netbox/dcim/forms/bulk_import.py

@@ -365,7 +365,7 @@ class PlatformImportForm(NetBoxModelImportForm):
     class Meta:
         model = Platform
         fields = (
-            'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags',
+            'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags',
         )
 
 

+ 2 - 7
netbox/dcim/forms/model_forms.py

@@ -360,19 +360,14 @@ class PlatformForm(NetBoxModelForm):
     )
 
     fieldsets = (
-        ('Platform', (
-            'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags',
-        )),
+        ('Platform', ('name', 'slug', 'manufacturer', 'config_template', 'description', 'tags')),
     )
 
     class Meta:
         model = Platform
         fields = [
-            'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags',
+            'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags',
         ]
-        widgets = {
-            'napalm_args': forms.Textarea(),
-        }
 
 
 class DeviceForm(TenancyForm, NetBoxModelForm):

+ 19 - 0
netbox/dcim/migrations/0173_remove_napalm_fields.py

@@ -0,0 +1,19 @@
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dcim', '0172_larger_power_draw_values'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='platform',
+            name='napalm_args',
+        ),
+        migrations.RemoveField(
+            model_name='platform',
+            name='napalm_driver',
+        ),
+    ]

+ 2 - 15
netbox/dcim/models/devices.py

@@ -432,9 +432,8 @@ class DeviceRole(OrganizationalModel):
 
 class Platform(OrganizationalModel):
     """
-    Platform refers to the software or firmware running on a Device. For example, "Cisco IOS-XR" or "Juniper Junos".
-    NetBox uses Platforms to determine how to interact with devices when pulling inventory data or other information by
-    specifying a NAPALM driver.
+    Platform refers to the software or firmware running on a Device. For example, "Cisco IOS-XR" or "Juniper Junos". A
+    Platform may optionally be associated with a particular Manufacturer.
     """
     manufacturer = models.ForeignKey(
         to='dcim.Manufacturer',
@@ -451,18 +450,6 @@ class Platform(OrganizationalModel):
         blank=True,
         null=True
     )
-    napalm_driver = models.CharField(
-        max_length=50,
-        blank=True,
-        verbose_name='NAPALM driver',
-        help_text=_('The name of the NAPALM driver to use when interacting with devices')
-    )
-    napalm_args = models.JSONField(
-        blank=True,
-        null=True,
-        verbose_name='NAPALM arguments',
-        help_text=_('Additional arguments to pass when initiating the NAPALM driver (JSON format)')
-    )
 
     def get_absolute_url(self):
         return reverse('dcim:platform', args=[self.pk])

+ 0 - 1
netbox/dcim/search.py

@@ -172,7 +172,6 @@ class PlatformIndex(SearchIndex):
     fields = (
         ('name', 100),
         ('slug', 110),
-        ('napalm_driver', 300),
         ('description', 500),
     )
 

+ 3 - 3
netbox/dcim/tables/devices.py

@@ -137,11 +137,11 @@ class PlatformTable(NetBoxTable):
     class Meta(NetBoxTable.Meta):
         model = models.Platform
         fields = (
-            'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'config_template', 'napalm_driver',
-            'napalm_args', 'description', 'tags', 'actions', 'created', 'last_updated',
+            'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'config_template', 'description',
+            'tags', 'actions', 'created', 'last_updated',
         )
         default_columns = (
-            'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description',
+            'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'description',
         )
 
 

+ 3 - 7
netbox/dcim/tests/test_filtersets.py

@@ -1498,9 +1498,9 @@ class PlatformTestCase(TestCase, ChangeLoggedFilterSetTests):
         Manufacturer.objects.bulk_create(manufacturers)
 
         platforms = (
-            Platform(name='Platform 1', slug='platform-1', manufacturer=manufacturers[0], napalm_driver='driver-1', description='A'),
-            Platform(name='Platform 2', slug='platform-2', manufacturer=manufacturers[1], napalm_driver='driver-2', description='B'),
-            Platform(name='Platform 3', slug='platform-3', manufacturer=manufacturers[2], napalm_driver='driver-3', description='C'),
+            Platform(name='Platform 1', slug='platform-1', manufacturer=manufacturers[0], description='A'),
+            Platform(name='Platform 2', slug='platform-2', manufacturer=manufacturers[1], description='B'),
+            Platform(name='Platform 3', slug='platform-3', manufacturer=manufacturers[2], description='C'),
         )
         Platform.objects.bulk_create(platforms)
 
@@ -1516,10 +1516,6 @@ class PlatformTestCase(TestCase, ChangeLoggedFilterSetTests):
         params = {'description': ['A', 'B']}
         self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
 
-    def test_napalm_driver(self):
-        params = {'napalm_driver': ['driver-1', 'driver-2']}
-        self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
-
     def test_manufacturer(self):
         manufacturers = Manufacturer.objects.all()[:2]
         params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]}

+ 0 - 3
netbox/dcim/tests/test_views.py

@@ -1609,8 +1609,6 @@ class PlatformTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
             'name': 'Platform X',
             'slug': 'platform-x',
             'manufacturer': manufacturer.pk,
-            'napalm_driver': 'junos',
-            'napalm_args': None,
             'description': 'A new platform',
             'tags': [t.pk for t in tags],
         }
@@ -1630,7 +1628,6 @@ class PlatformTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
         )
 
         cls.bulk_edit_data = {
-            'napalm_driver': 'ios',
             'description': 'New description',
         }
 

+ 0 - 15
netbox/templates/dcim/platform.html

@@ -53,26 +53,11 @@
                 title="This field has been deprecated, and will be removed in NetBox v3.6."
               ></i>
             </th>
-            <td>{{ object.napalm_driver|placeholder }}</td>
           </tr>
         </table>
       </div>
     </div>
     {% include 'inc/panels/tags.html' %}
-    <div class="card">
-      <h5 class="card-header">
-        NAPALM Arguments
-        <i
-          class="mdi mdi-alert-box text-warning"
-          data-bs-toggle="tooltip"
-          data-bs-placement="right"
-          title="This field has been deprecated, and will be removed in NetBox v3.6."
-        ></i>
-      </h5>
-      <div class="card-body">
-        <pre>{{ object.napalm_args|json }}</pre>
-      </div>
-    </div>
     {% plugin_left_page object %}
 	</div>
 	<div class="col col-md-6">