Skip to content

Commit

Permalink
Closes #12320: Remove obsolete fields napalm_driver and napalm_args f…
Browse files Browse the repository at this point in the history
…rom Platform
  • Loading branch information
jeremystretch committed May 16, 2023
1 parent 02db0bc commit 4208b79
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 61 deletions.
5 changes: 5 additions & 0 deletions docs/release-notes/version-3.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]


Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 2 additions & 6 deletions netbox/dcim/forms/bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)


Expand Down
9 changes: 2 additions & 7 deletions netbox/dcim/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 19 additions & 0 deletions netbox/dcim/migrations/0173_remove_napalm_fields.py
Original file line number Diff line number Diff line change
@@ -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',
),
]
17 changes: 2 additions & 15 deletions netbox/dcim/models/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,8 @@ def get_absolute_url(self):

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',
Expand All @@ -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])
Expand Down
1 change: 0 additions & 1 deletion netbox/dcim/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ class PlatformIndex(SearchIndex):
fields = (
('name', 100),
('slug', 110),
('napalm_driver', 300),
('description', 500),
)

Expand Down
6 changes: 3 additions & 3 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)


Expand Down
10 changes: 3 additions & 7 deletions netbox/dcim/tests/test_filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,9 +1498,9 @@ def setUpTestData(cls):
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)

Expand All @@ -1516,10 +1516,6 @@ def test_description(self):
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]}
Expand Down
3 changes: 0 additions & 3 deletions netbox/dcim/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,8 +1609,6 @@ def setUpTestData(cls):
'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],
}
Expand All @@ -1630,7 +1628,6 @@ def setUpTestData(cls):
)

cls.bulk_edit_data = {
'napalm_driver': 'ios',
'description': 'New description',
}

Expand Down
15 changes: 0 additions & 15 deletions netbox/templates/dcim/platform.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,11 @@ <h5 class="card-header">
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">
Expand Down

0 comments on commit 4208b79

Please sign in to comment.