How to pass JSON object to provisioning script

Hi,
I would like to pass a JSON object to my provisioning script:
like this:

"internet": {
        "vlan": 7,
        "connection_mode_identifier": "ds_priv",
        "bandwidth_down": 100000,
        "bandwidth_up": 50000,
        "protocol": "PPPoE",
        "pppoe_username": "ECHTS.20000001",
        "pppoe_password": "super_secret_internet_password"
    }

And then parse the input string to an object, but the preset arguments is saved with additional quotation marks.

So I wanted to ask what’s the best practise to pass an object as argument to the script?

thanks for the help

How are you passing this data to your provisioning script? Via an extension script? Via the arguments option when executing a provision script via a preset?

FWIW, I pass data from my provision script by doing let config = ext('cpe-config', 'resetPppoe', JSON.stringify(params));

config is the output from the ext script, and is a json object.

Here is the part of my ext script that makes the call to our subscriber management system and returns the data to the provisioning script. Notice the line towards the bottom that parses the incoming data from a string into a JSON object and then returns that data via the callback.

let request = http.get(options, function (response) {
    if (response.statusCode === 404) {
        return callback(null, null);
    }

    if (response.statusCode >= 400) {
        return callback(new Error("Unexpected error resetting PPPoE credentials. Response Code: " + response.statusCode + '. Status Message: ' + response.statusMessage + '. t: ' + typeof response.statusCode));
    }

    let data = "";
    response.on("data", function (d) {
        data = data + d.toString();
    });

    response.on("end", function () {
        let result = JSON.parse(data);

        console.log('Returning credentials to client', result);
        return callback(null, result);
    });
});

request.on("error", function (err) {
    console.log('args');
    console.log(arguments);
    callback(err);
});
1 Like

Using curl is the appropriate way to interoperate with GenieACS for ex. client login to WEB PANEL and then click button to change SSID on his router?

Why use curl, when you have everything you need within the Genie environment to accomplish your goals?

How could i do this?