../../_images/openl2m_logo.png

Credentials Admin API

Credentials, aka Netmiko Profiles, are used for SSH, REST, and other access methods that require username and password.

There are two parts of the Credentials admin api:

Get Credential Profiles

The “/api/admin/switches/netmikoprofiles/” GET endpoint returns a list of all Netmiko/Credientials Profiles.

Here is an example call:

http http://localhost:8000/api/admin/switches/netmikoprofiles/ 'Authorization: Token ***34b'

The returned data will look similar to this:

HTTP/1.1 200 OK
...

[
    {
        "description": "",
        "device_type": "cisco",
        "enable_password": "enable_me",
        "id": 1,
        "name": "Department X SSH Creds",
        "password": "secret",
        "tcp_port": 22,
        "username": "admin",
        "verify_hostkey": false
    },
    ...
    more credentials
    ...
]

Add Credentials Profile

The “/api/admin/switches/netmikoprofiles/” POST endpoint allows you to create a new Credentials Profile. The new object will be returned if the call succeeds. Valid field names are as shown in the above output example.

Here is an example call.

http --form POST http://localhost:8000/api/admin/switches/netmikoprofiles/ 'Authorization: Token ***34b' name="Dept. Y SSH" description="Test SSH access" username="user" password="secret" tcp_port=2022

and the example output:

HTTP/1.1 201 Created
...

{
    "description": "Test SSH access",
    "device_type": "hp_comware",
    "enable_password": null,
    "id": 2,
    "name": "Dept. Y SSH",
    "password": "secret",
    "tcp_port": 2022,
    "username": "user",
    "verify_hostkey": false
}

For device_type you need to use a Netmiko device name that matches your device. See the supported list at https://github.com/openl2m/openl2m/blob/main/openl2m/switches/connect/netmiko/constants.py

Note

You will need the returned Profile id for future update calls.

Get Credentials Details

The “/api/admin/switches/netmikoprofiles/<id>/” GET endpoint returns the details about a specific Credential Profile object.

Valid field names are as shown in the above output example.

Example:

http http://localhost:8000/api/admin/switches/netmikoprofiles/3/ 'Authorization: Token ***34b'

Set Credential Profile Attributes

The “/api/admin/switches/netmikoprofiles/<id>/” POST (or PATCH) endpoint allows you to change attributes of a specific profile object. You can change one or more fields at the same time.

Valid field names are as shown in the above output example.

Example:

http --form POST http://localhost:8000/api/admin/switches/netmikoprofiles/3/ 'Authorization: Token ***34b' password="new_password"

and the returned data:

HTTP/1.1 200 OK
...
{
    "description": "Test SSH access",
    "device_type": "hp_comware",
    "enable_password": null,
    "id": 2,
    "name": "Dept. Y SSH",
    "password": "password",
    "tcp_port": 2022,
    "username": "user",
    "verify_hostkey": false
}