mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Changed NAPALM-
prefix to X-NAPALM-
This commit is contained in:
parent
60e4812b32
commit
9d085ad83a
@ -17,15 +17,15 @@ GET /api/dcim/devices/1/napalm/?method=get_environment
|
|||||||
|
|
||||||
## Authentication
|
## 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" \
|
$ curl "http://localhost/api/dcim/devices/1/napalm/?method=get_environment" \
|
||||||
-H "Authorization: Token f4b378553dacfcfd44c5a0b9ae49b57e29c552b5" \
|
-H "Authorization: Token f4b378553dacfcfd44c5a0b9ae49b57e29c552b5" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json; indent=4" \
|
-H "Accept: application/json; indent=4" \
|
||||||
-H "NAPALM-Username: foo" \
|
-H "X-NAPALM-Username: foo" \
|
||||||
-H "NAPALM-Password: bar"
|
-H "X-NAPALM-Password: bar"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Method Support
|
## Method Support
|
||||||
@ -51,7 +51,7 @@ GET /api/dcim/devices/1/napalm/?method=get_ntp_servers&method=get_ntp_peers
|
|||||||
|
|
||||||
## Optional Arguments
|
## 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:
|
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 "Authorization: Token f4b378553dacfcfd44c5a0b9ae49b57e29c552b5" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json; indent=4" \
|
-H "Accept: application/json; indent=4" \
|
||||||
-H "NAPALM-port: 2222"
|
-H "X-NAPALM-port: 2222"
|
||||||
```
|
```
|
||||||
|
@ -404,10 +404,10 @@ class DeviceViewSet(CustomFieldModelViewSet):
|
|||||||
|
|
||||||
# Update NAPALM parameters according to the request headers
|
# Update NAPALM parameters according to the request headers
|
||||||
for header in request.headers:
|
for header in request.headers:
|
||||||
if header[:7].lower() != 'napalm-':
|
if header[:9].lower() != 'x-napalm-':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
key = header[7:]
|
key = header[9:]
|
||||||
if key.lower() == 'username':
|
if key.lower() == 'username':
|
||||||
username = request.headers[header]
|
username = request.headers[header]
|
||||||
elif key.lower() == 'password':
|
elif key.lower() == 'password':
|
||||||
|
Loading…
Reference in New Issue
Block a user