diff --git a/docs/administration/permissions.md b/docs/administration/permissions.md index 4b8556616..48abd5443 100644 --- a/docs/administration/permissions.md +++ b/docs/administration/permissions.md @@ -20,7 +20,7 @@ There are four core actions that can be permitted for each type of object within * **Change** - Modify an existing object * **Delete** - Delete an existing object -In addition to these, permissions can also grant custom actions that may be required by a specific model or plugin. For example, the `napalm_read` permission on the device model allows a user to execute NAPALM queries on a device via NetBox's REST API. These can be specified when granting a permission in the "additional actions" field. +In addition to these, permissions can also grant custom actions that may be required by a specific model or plugin. For example, the `run` permission for scripts allows a user to execute custom scripts. These can be specified when granting a permission in the "additional actions" field. !!! note Internally, all actions granted by a permission (both built-in and custom) are stored as strings in an array field named `actions`. diff --git a/docs/configuration/index.md b/docs/configuration/index.md index 4f8d102f7..70466d029 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -30,10 +30,6 @@ Some configuration parameters are primarily controlled via NetBox's admin interf * [`MAINTENANCE_MODE`](./miscellaneous.md#maintenance_mode) * [`MAPS_URL`](./miscellaneous.md#maps_url) * [`MAX_PAGE_SIZE`](./miscellaneous.md#max_page_size) -* [`NAPALM_ARGS`](./napalm.md#napalm_args) -* [`NAPALM_PASSWORD`](./napalm.md#napalm_password) -* [`NAPALM_TIMEOUT`](./napalm.md#napalm_timeout) -* [`NAPALM_USERNAME`](./napalm.md#napalm_username) * [`PAGINATE_COUNT`](./default-values.md#paginate_count) * [`POWERFEED_DEFAULT_AMPERAGE`](./default-values.md#powerfeed_default_amperage) * [`POWERFEED_DEFAULT_MAX_UTILIZATION`](./default-values.md#powerfeed_default_max_utilization) diff --git a/docs/configuration/napalm.md b/docs/configuration/napalm.md deleted file mode 100644 index e9fc91b72..000000000 --- a/docs/configuration/napalm.md +++ /dev/null @@ -1,53 +0,0 @@ -# NAPALM Parameters - -!!! **Note:** As of NetBox v3.5, NAPALM integration has been moved to a plugin and these configuration parameters are now deprecated. - -## NAPALM_USERNAME - -## NAPALM_PASSWORD - -!!! tip "Dynamic Configuration Parameter" - -NetBox will use these credentials when authenticating to remote devices via the supported [NAPALM integration](../integrations/napalm.md), if installed. Both parameters are optional. - -!!! note - If SSH public key authentication has been set up on the remote device(s) for the system account under which NetBox runs, these parameters are not needed. - ---- - -## NAPALM_ARGS - -!!! tip "Dynamic Configuration Parameter" - -A dictionary of optional arguments to pass to NAPALM when instantiating a network driver. See the NAPALM documentation for a [complete list of optional arguments](https://napalm.readthedocs.io/en/latest/support/#optional-arguments). An example: - -```python -NAPALM_ARGS = { - 'api_key': '472071a93b60a1bd1fafb401d9f8ef41', - 'port': 2222, -} -``` - -Some platforms (e.g. Cisco IOS) require an argument named `secret` to be passed in addition to the normal password. If desired, you can use the configured `NAPALM_PASSWORD` as the value for this argument: - -```python -NAPALM_USERNAME = 'username' -NAPALM_PASSWORD = 'MySecretPassword' -NAPALM_ARGS = { - 'secret': NAPALM_PASSWORD, - # Include any additional args here -} -``` - ---- - -## NAPALM_TIMEOUT - -!!! tip "Dynamic Configuration Parameter" - -Default: 30 seconds - -The amount of time (in seconds) to wait for NAPALM to connect to a device. - ---- - diff --git a/docs/features/api-integration.md b/docs/features/api-integration.md index c3b78de47..8c0843bfe 100644 --- a/docs/features/api-integration.md +++ b/docs/features/api-integration.md @@ -30,14 +30,6 @@ A webhook is a mechanism for conveying to some external system a change that too To learn more about this feature, check out the [webhooks documentation](../integrations/webhooks.md). -## NAPALM - -[NAPALM](https://github.com/napalm-automation/napalm) is a Python library which enables direct interaction with network devices of various platforms. When configured, NetBox supports fetching live operational and status data directly from network devices to be compared to what has been defined in NetBox. This allows for easily validating the device's operational state against its desired state. Additionally, NetBox's REST API can act as a sort of proxy for NAPALM commands, allowing external clients to interact with network devices by sending HTTP requests to the appropriate API endpoint. - -To learn more about this feature, check out the [NAPALM documentation](../integrations/napalm.md). - -As of NetBox v3.5, NAPALM integration has been moved to a plugin. Please see the [netbox_napalm_plugin](https://github.com/netbox-community/netbox-napalm) for installation instructions. - ## Prometheus Metrics NetBox includes a special `/metrics` view which exposes metrics for a [Prometheus](https://prometheus.io/) scraper, powered by the open source [django-prometheus](https://github.com/korfuri/django-prometheus) library. To learn more about this feature, check out the [Prometheus metrics documentation](../integrations/prometheus-metrics.md). diff --git a/docs/installation/upgrading.md b/docs/installation/upgrading.md index cc49cd30e..27401c3cf 100644 --- a/docs/installation/upgrading.md +++ b/docs/installation/upgrading.md @@ -97,7 +97,7 @@ sudo git pull origin master ## 4. Run the Upgrade Script -Once the new code is in place, verify that any optional Python packages required by your deployment (e.g. `napalm` or `django-auth-ldap`) are listed in `local_requirements.txt`. Then, run the upgrade script: +Once the new code is in place, verify that any optional Python packages required by your deployment (e.g. `django-auth-ldap`) are listed in `local_requirements.txt`. Then, run the upgrade script: ```no-highlight sudo ./upgrade.sh diff --git a/docs/integrations/napalm.md b/docs/integrations/napalm.md deleted file mode 100644 index e7e0f108c..000000000 --- a/docs/integrations/napalm.md +++ /dev/null @@ -1,3 +0,0 @@ -# NAPALM - -As of NetBox v3.5, NAPALM integration has been moved to a plugin. Please see the [netbox_napalm_plugin](https://github.com/netbox-community/netbox-napalm) for installation instructions. **Note:** All previously entered NAPALM configuration data will be saved and automatically imported by the new plugin. diff --git a/docs/introduction.md b/docs/introduction.md index bfa0900cb..640147395 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -37,7 +37,6 @@ NetBox was built specifically to serve the needs of network engineers and operat * Robust object-based permissions * Detailed, automatic change logging * Global search engine -* NAPALM integration ## What NetBox Is Not @@ -78,4 +77,3 @@ NetBox is built on the [Django](https://djangoproject.com/) Python framework and | Application | Django/Python | | Database | PostgreSQL 11+ | | Task queuing | Redis/django-rq | -| Live device access | NAPALM (optional) | diff --git a/docs/models/dcim/platform.md b/docs/models/dcim/platform.md index cea3efb55..875f4a88a 100644 --- a/docs/models/dcim/platform.md +++ b/docs/models/dcim/platform.md @@ -28,8 +28,14 @@ The default [configuration template](../extras/configtemplate.md) for devices as ### NAPALM Driver +!!! warning "Deprecated Field" + NAPALM integration was removed from NetBox core in v3.5 and is now available as a [plugin](https://github.com/netbox-community/netbox-napalm). This field will be removed in NetBox v3.6. + The [NAPALM driver](https://napalm.readthedocs.io/en/latest/support/index.html) associated with this platform. ### NAPALM Arguments +!!! warning "Deprecated Field" + NAPALM integration was removed from NetBox core in v3.5 and is now available as a [plugin](https://github.com/netbox-community/netbox-napalm). This field will be removed in NetBox v3.6. + Any additional arguments to send when invoking the NAPALM driver assigned to this platform. diff --git a/mkdocs.yml b/mkdocs.yml index ae7fcadf8..f7da976c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -108,7 +108,6 @@ nav: - Default Values: 'configuration/default-values.md' - Error Reporting: 'configuration/error-reporting.md' - Plugins: 'configuration/plugins.md' - - NAPALM: 'configuration/napalm.md' - Date & Time: 'configuration/date-time.md' - Miscellaneous: 'configuration/miscellaneous.md' - Development: 'configuration/development.md' @@ -124,7 +123,6 @@ nav: - GraphQL API: 'integrations/graphql-api.md' - Webhooks: 'integrations/webhooks.md' - Synchronized Data: 'integrations/synchronized-data.md' - - NAPALM: 'integrations/napalm.md' - Prometheus Metrics: 'integrations/prometheus-metrics.md' - Plugins: - Using Plugins: 'plugins/index.md' diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index 5f5804a92..207fb6d00 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -811,7 +811,7 @@ class PlatformFilterSet(OrganizationalModelFilterSet): class Meta: model = Platform - fields = ['id', 'name', 'slug', 'description'] + fields = ['id', 'name', 'slug', 'napalm_driver', 'description'] class DeviceFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSet, LocalConfigContextFilterSet): diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 0762c0a32..3e971caa5 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -470,6 +470,10 @@ 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 @@ -481,9 +485,9 @@ class PlatformBulkEditForm(NetBoxModelBulkEditForm): model = Platform fieldsets = ( - (None, ('manufacturer', 'config_template', 'description')), + (None, ('manufacturer', 'config_template', 'napalm_driver', 'description')), ) - nullable_fields = ('manufacturer', 'config_template', 'description') + nullable_fields = ('manufacturer', 'config_template', 'napalm_driver', 'description') class DeviceBulkEditForm(NetBoxModelBulkEditForm): diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index 73eda38fe..ad5826d1f 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -347,7 +347,7 @@ class PlatformImportForm(NetBoxModelImportForm): class Meta: model = Platform fields = ( - 'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags', + 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags', ) diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index ee1d57781..d756036f4 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -361,15 +361,18 @@ class PlatformForm(NetBoxModelForm): fieldsets = ( ('Platform', ( - 'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags', + 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags', )), ) class Meta: model = Platform fields = [ - 'name', 'slug', 'manufacturer', 'config_template', 'description', 'tags', + 'name', 'slug', 'manufacturer', 'config_template', 'napalm_driver', 'napalm_args', 'description', 'tags', ] + widgets = { + 'napalm_args': forms.Textarea(), + } class DeviceForm(TenancyForm, NetBoxModelForm): diff --git a/netbox/dcim/search.py b/netbox/dcim/search.py index f70c729f4..bae4f030f 100644 --- a/netbox/dcim/search.py +++ b/netbox/dcim/search.py @@ -172,6 +172,7 @@ class PlatformIndex(SearchIndex): fields = ( ('name', 100), ('slug', 110), + ('napalm_driver', 300), ('description', 500), ) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 8ce19bcde..8a39ee16c 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -133,11 +133,11 @@ class PlatformTable(NetBoxTable): class Meta(NetBoxTable.Meta): model = models.Platform fields = ( - 'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'config_template', 'description', - 'tags', 'actions', 'created', 'last_updated', + 'pk', 'id', 'name', 'manufacturer', 'device_count', 'vm_count', 'slug', 'config_template', 'napalm_driver', + 'napalm_args', 'description', 'tags', 'actions', 'created', 'last_updated', ) default_columns = ( - 'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'description', + 'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description', ) diff --git a/netbox/dcim/tests/test_filtersets.py b/netbox/dcim/tests/test_filtersets.py index 4b82e87bd..346b35005 100644 --- a/netbox/dcim/tests/test_filtersets.py +++ b/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], 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(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.objects.bulk_create(platforms) @@ -1516,6 +1516,10 @@ 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]} diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 886de5a25..bae5a8e0b 100644 --- a/netbox/dcim/tests/test_views.py +++ b/netbox/dcim/tests/test_views.py @@ -1591,6 +1591,8 @@ 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], } @@ -1610,6 +1612,7 @@ class PlatformTestCase(ViewTestCases.OrganizationalObjectViewTestCase): ) cls.bulk_edit_data = { + 'napalm_driver': 'ios', 'description': 'New description', } diff --git a/netbox/templates/dcim/platform.html b/netbox/templates/dcim/platform.html index a834ed7e9..80fdbd945 100644 --- a/netbox/templates/dcim/platform.html +++ b/netbox/templates/dcim/platform.html @@ -43,10 +43,36 @@
{{ object.napalm_args|json }}+