cnMaestro APIs can be used by the billing system to provision new subscribers. The billing system would need to know the MAC address of the subscriber’s SM so it can configure the appropriate parameters. In this example, the billing system will configure the SM name and MIR.
Add “API Client”
First step is to add an “API client” for the billing system so it can securely communicate with cnMaestro.
Navigate to “Network Services > API Client” page and click on the “Add API Client” button.
Enter a name and description for the API client and click “Save”.
When you are ready to use the API in your script, you will have to download and use the credentials that are available on this page. For this exercise, we will use the built-in Swagger client, so this step can be skipped. Click on the “Close” button.
Launch Swagger to interactively try the APIs
Back on the “API Clients” page, you will see the new API client that you just created. Click on the “Try it now” button next to it to launch the Swagger client and exercise the API interactively.
Create a new template for PMP SM
The template that will be used to push configuration to the SM can be created manually in cnMaestro, but here we see how to do it using the API.
We will create a template named “BillingTemplate” for the 450 SM with the following configuration fragment. You can create your own configuration fragment file by exporting the configuration from the device and deleting everything in the “userParameters” section other than the items you want to push the device.
{
"userParameters": {
"qosConfig": {
"sustainedUplinkDataRate": ${UPLINK_MIR=25000},
"sustainedDownlinkDataRate": ${DOWNLINK_MIR=100000}
},
"configFileParameters": {
"rebootIfRequired": true
}
}
}
This sets both the uplink and downlink MIR on the SM. The default values are included in the template, but we will override these when we push the template.
Find the “[POST] /configuration/templates” item in Swagger and click “Try it out” button.
In the “Request body” field, enter the following text.
{
"name": "BillingTemplate",
"template": "{\"userParameters\": {\"qosConfig\": {\"sustainedUplinkDataRate\": ${UPLINK_MIR=25000}, \"sustainedDownlinkDataRate\": ${DOWNLINK_MIR=100000}}, \"configFileParameters\": {\"rebootIfRequired\": true}}",
"device_type": "pmp",
"device_mode": [
"sm"
]
}
Click the “Execute” button. You should get a “Success” response that looks like this.
If you get an “invalid client” error, please go to the top of the page, click “Authorize”, then “Logout” and then the “Authorize” button. Now try again.
In cnMaestro, navigate to “Configuration > Templates” screen, and you should be able to see the template named “BillingTemplate” that you just created.
Configure the SM
Now we will configure the SM name and MIR using the API. You may have noticed that the template above includes only MIR settings and not the SM name (called “Site name” in the SM GUI). This is because the SM name, latitude and longitude parameters are synched with cnMaestro settings. The API provides direct access to these parameters without needing a template. If you try to configure these parameters using a template, it will not work as cnMaestro will override the values with what in configured in cnMaestro before pushing the template.
On the Swagger page, locate the “[PUT] /devices/{mac}” section. You can click ”Schema” and then “pmp” to see the parameters applicable to PMP devices. We will be using “name”, “template” and “variables” parameter. We will set the name of the SM to “John Smith” and use the “BillingTemplate” file to configure downlink MIR or 200 Mbps and uplink MIR of 50 Mbps.
To use the API, click on “Try it out” button.
Enter the MAC address of the SM you want to configure in the “Device MAC” field.
Enter the following in the “Request body” field.
{
"name": "John Smith",
"template": "BillingTemplate",
"variables": {
"DOWNLINK_MIR": "200000",
"UPLINK_MIR": "50000"
}
}
This is telling cnMaestro to set the device name to “John Smith”, push the template named “BillingTemplate” and override the values for DOWNLINK_MIR and UPLINK_MIR variables in the template.
Click “Execute”.
You should see the following response with the message “Job created successfully. Please check the job’s status for details.”
You can now log in to cnMaestro and navigate to “Administration > Jobs” to see the configuration update job that was created by the API call. Wait for the “Status” to change to “Completed”.
In the device tree in cnMaestro, you will see that the name of the SM has changed.
You can also login to the device itself and verify that “Site name” has been updated under “Configuration > SNMP > Site Information” and that MIR values have also been updated under “Configuration > Quality of Service (QoS) > MIR Bandwidth Settings” section.