SM configuration through API

Maybe I'm missing something but it looks like we can't apply our JSON configuration templates using the API? This seems like a pretty key feature. We'd like to integrate our billing software so when a customer cancels service the ethernet port is shut down. Obviously there are tons of other uses for the ability to apply SM configuration through the API as well. Is this in the roadmap?

Yes, the ability to apply configuration via the NBI API is in development but is not currently availble.

can we get update regrading this ?

i also searching these kind of requirement

1 Like

Yes through override variable it’s supported via API in 2.1.0 release.

1 Like

Unless I'm missing something there's still no ability to change the QOS settings or disable the ethernet interface however. We are really waiting for those two features to allow our customer service groups to toggle those settings without logging into the SM or cnMaestro. As it stands right now, I have to resort to allowing my server full access to our SM VLAN in order to query/change via SNMP, rather than allowing it to just access cnMaestro and using the API to change SM settings. 

I have pass this info to our team, we will surely help out how to define them in override variables and update via API.

An existing JSON configuration template can be applied via the Update Device Configuration API.

PUT /api/v1/devices/{MAC Address}

{
    "template": "your_template_name",
"variables":{
"UNIQUE_PLACEMENT":"indoor",
"SSH_ENABLE":"true"
} }

Replacement variables set within the template can also specified using the "variables" object.

It looks like our documentation is missing the "template" parameter for this API.  I will work to ensure this information is updated.

If you need assistance in creating the template itself, please let us know.

2 Likes

Awesome! I'll give this a try and let you know.

1 Like

Hi! I'm triyng to send a custom template to SM with a couple of variables set but it doesn't seems to work.

My steps:

- I've created a template like this, called ROUTER_MODE:

{
    "device_props": {
        "dataVLANEnable": "0",
        "dataVLANVID": "31",
        "mgmtVLANVID": "30",
        "mgmtIFVLAN": "1",
        "mgmtIFVID": "111",
        "networkMode": "1",
        "networkWanPPPoEUsername": ${PPPOE_USERNAME},
        "networkWanPPPoEPassword": ${PPPOE_PASSWORD}
    }
}

- I've sent a request to cnmaestro with this syntax:

PUT /api/v1/devices/00:00:00:00:00:00

{
    "template": "ROUTER_MODE",
    "variables": {
        "PPPOE_USERNAME": "xxxxxxxxx",
        "PPPOE_PASSWORD": "12345678"
     }
}

And the server reply with:

{
    "error": {
        "cause":"InvalidInputError",
        "message":"Should not have additional properties. Reason: additionalProperty:variables[PPPOE_USERNAME] {  }"
    }
}

I've also created another template (called BRIDGE_MODE) with no variables and it works like a charm!

The cnmaestro server is obviously on premise and updated to the latest version (2.3.0)

Can I send a template with no variables and call another api to change specific configuration values (even if it doesn't seems to been the best approach)?

Thanks

Hi ceres,

I tested this on a 2.4.0 development build using the provided template and PUT payload but was unable to reproduce the issue.  I don't see any changes to validation used for the variables object since 2.3.0.

Do you get the same error when using the placeholder values in the PUT request?  I wonder if some special characters are causing a different result.

As a side-note, I think you will need to surround your replacement variable text in the template with double-quotes since those parameters should be Strings.

{
    "device_props": {
        "dataVLANEnable": "0",
        "dataVLANVID": "31",
        "mgmtVLANVID": "30",
        "mgmtIFVLAN": "1",
        "mgmtIFVID": "111",
        "networkMode": "1",
        "networkWanPPPoEUsername": "${PPPOE_USERNAME}",
        "networkWanPPPoEPassword": "${PPPOE_PASSWORD}"
    }
}

Regarding using the API to directly change configuration parameters, at this time only latitude and longitude are supported which are also changed via the "devices" API.

Hi Jordan,

I've added the double quotes in the template after sending the previous response.

I've also just found what the problem was, my client was sending the PUT data in a wrong format (urlencoded instead of json) now it works ok!

Thanks for the support and the advice!

1 Like

That's great!  Glad you were able to get it working.

A post was split to a new topic: API error: “Incompatible template and device types”