From 9d085ad83a26aa90eeed4c36c123171bf6ae0c80 Mon Sep 17 00:00:00 2001 From: Saria Hajjar Date: Thu, 9 Jan 2020 16:48:26 +0000 Subject: [PATCH] Changed `NAPALM-` prefix to `X-NAPALM-` --- docs/additional-features/napalm.md | 10 +++++----- netbox/dcim/api/views.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/additional-features/napalm.md b/docs/additional-features/napalm.md index a7b91128b..c8e8b8b3a 100644 --- a/docs/additional-features/napalm.md +++ b/docs/additional-features/napalm.md @@ -17,15 +17,15 @@ GET /api/dcim/devices/1/napalm/?method=get_environment ## Authentication -By default, the [`NAPALM_USERNAME`](../../configuration/optional-settings/#napalm_username) and [`NAPALM_PASSWORD`](../../configuration/optional-settings/#napalm_password) are used for NAPALM authentication. They can be overridden for an individual API call through the `NAPALM-Username` and `NAPALM-Password` headers. +By default, the [`NAPALM_USERNAME`](../../configuration/optional-settings/#napalm_username) and [`NAPALM_PASSWORD`](../../configuration/optional-settings/#napalm_password) are used for NAPALM authentication. They can be overridden for an individual API call through the `X-NAPALM-Username` and `X-NAPALM-Password` headers. ``` $ curl "http://localhost/api/dcim/devices/1/napalm/?method=get_environment" \ -H "Authorization: Token f4b378553dacfcfd44c5a0b9ae49b57e29c552b5" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ --H "NAPALM-Username: foo" \ --H "NAPALM-Password: bar" +-H "X-NAPALM-Username: foo" \ +-H "X-NAPALM-Password: bar" ``` ## Method Support @@ -51,7 +51,7 @@ GET /api/dcim/devices/1/napalm/?method=get_ntp_servers&method=get_ntp_peers ## Optional Arguments -The behavior of NAPALM drivers can be adjusted according to the [optional arguments](https://napalm.readthedocs.io/en/latest/support/index.html#optional-arguments). NetBox exposes those arguments using headers prefixed with `NAPALM-`. +The behavior of NAPALM drivers can be adjusted according to the [optional arguments](https://napalm.readthedocs.io/en/latest/support/index.html#optional-arguments). NetBox exposes those arguments using headers prefixed with `X-NAPALM-`. For instance, the SSH port is changed to 2222 in this API call: @@ -61,5 +61,5 @@ $ curl "http://localhost/api/dcim/devices/1/napalm/?method=get_environment" \ -H "Authorization: Token f4b378553dacfcfd44c5a0b9ae49b57e29c552b5" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ --H "NAPALM-port: 2222" +-H "X-NAPALM-port: 2222" ``` diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 18da2f9a3..a7dfb39ff 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -404,10 +404,10 @@ class DeviceViewSet(CustomFieldModelViewSet): # Update NAPALM parameters according to the request headers for header in request.headers: - if header[:7].lower() != 'napalm-': + if header[:9].lower() != 'x-napalm-': continue - key = header[7:] + key = header[9:] if key.lower() == 'username': username = request.headers[header] elif key.lower() == 'password':