Using Custom Configuration Templates using an API for PMP Devices?


Summary:

       This article demonstrates how to use the “Custom ConfigurationTemplate” for PMP Devices using an API Client

Solution:

This can be achieved by two client applications as stated below:

  • Use of POSTMAN application
  • Use of CURL command


Method-1 POSTMAN application based template push:-


Prerequisites:

  • Create the template on cnMaestro that you wish to push to the PMP devices
  • Generate Client ID & Client Secret on cnMaestro
  • Configure the Client ID & Client Secret on POSTMAN application
  • Fetch the Access Token using POST API and configure it on POSTMAN application
    • https://{{server}}/api/v1/access/token
  • Below commands are applicable for devices that are already on-boarded not before on-boarding.

Please refer to the below community link that would help us to configure the POSTMAN with Client ID, Client Secret and the Access Token.

https://community.cambiumnetworks.com/t5/cnMaestro/RESTful-API-configuration-and-support-on-cnMaestro/m-p/96123#M83

Command to execute the template push:

  • Use “PUT” command to push the custom template and here is the “Request” format.

                                PUT   https://{{server-ip}}/api/v1/devices/{{device-mac}}

  • {{server-ip}} is the IP address of your on-premises server
  • {{device-mac}} is the mac address of the PMP device


- Above command might result is an error asking for authorization and content type

       Please specify the “HTTP Headers and Body parameters” that is necessary to push the template without any error. 

       HTTP Headers:
                Authorization: Bearer <ACCESS_TOKEN>

                Content-Type: application/json

Below is an example:

Header.png


Body Parameters:

  • Inside the Body select “raw”, content type as “JSON format” and configure the template variable in JSON format as stated below.

Format: 

{

“template” : “<Template-Name>”

}

  • <Template-Name> is the name of the template preconfigured in the cnMaestro On-premises that you would like to push to PMP device.

Below is an example:


Body.png


- Once you have Header and Body parameters configured, please click on “Send” button available towards top right hand side requesting for the output.  

Below is an example:



- The response will be either HTTP 200 (for success), or an HTTP error code with a JSON body (see cnMaestro API User Guide for details). If success and template was specified, a Job is created and started.


Here is an Example Output for success Job creation:

Job.png


Note: 

    The Job can be tracked using the job_id, to determine if it completes successfully.

Method-2 Using CURL command to push the Template:-

 Command to execute the template push:

              Curl https://{{server-ip}}/api/v1/devices/{{Device-Mac}} -X PUT -d '{"template":"< template-name>"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer <Access-Token>"

  • Server-ip is the IP address of your on-premises server
  • Device-Mac is the mac address of the PMP device
  • Template-name is the name of the template preconfigured in the cnMaestro On-premises that you would like to push to PMP device.
  • Access-Token is the access token that we need to fetch from the on-premises server using the below command.
    • POST https://{{server}}/api/v1/access/token

Here is an example Output:


Curl https://10.120.200.210/api/v1/devices/0A:00:00:00:00:00  -X PUT -d '{"template":"SM QOS config"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer c27dcdf53ebb6237fad1773d70ba4939da5476c4"


Example Response:


- All available parameters are defined in the RESTful API guide (cnMaestro 2.2.0 RESTful API) which is available in our support web site.

https://support.cambiumnetworks.com/files/cnmaestro/


- Here is the other reference link on how to fetch Performance and Statistics Data.

https://community.cambiumnetworks.com/t5/cnMaestro/cnMaestro-Performance-and-Statistics-RESTful-API-behavior/m-p/93145#M82

1 Like