Ext for getting voiceservercies.username and password

Hi folks,
I want to read username and password of our voice services from an api for each device serial number.

i have written a script for now just returning a static username and password to see if it works.

script is /opt/genieacs/ext/test.js
“use strict”;
function GetSIP(args, callback) {
let sipdata = “username: test”+“, password:1234”;
callback(null, sipdata);
}
exports.GetSIP = GetSIP;


then in the provision the script is:-
const res = ext(“ext-GetSIP”, “GetSIP”, “arg1”, “arg2”);
log(res);

then i added this provision in the preset.

i can see in the logs that Script: username: test, password:1234 but i dont know how & where to set the other full parameter?
i want to set the values of the following to paramters.

InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthPassword
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthUserName

Can someone guide me how to return the username,password and how to use those 2 variables. I assume i have to add the above 2 paramters in the inform ? but what variables will get me username and password? Please note username and password will be returned from my /opt/genieacs/ext/test.js
thanks

If I’m understanding you correctly, you want to pass parameters into an extension script to pass along to an API? This is how I’ve accomplished that task:

// Provision script
const now = Date.now();
const serialNumber = declare('DeviceID.SerialNumber', {value: 1}).value[0];
const productClass = declare('DeviceID.ProductClass', {value: 1}).value[0];
const oui = declare('DeviceID.OUI', {value: 1}).value[0];
const deviceId = declare('DeviceID.ID', {value: 1}).value[0];
const params = {serial: serialNumber, productClass: productClass, oui: oui, deviceId: deviceId};

//Get the PPPoE creds
let config = ext('extensions', 'resetPppoe', JSON.stringify(params));

declare("InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthUserName", {value: now}, {value: config.username});
declare("InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthPassword", {value: now}, {value: config.password});
// Extension script
function resetPppoe(args, callback) {
    const params = JSON.parse(args[0]);

    const uri = `${API_URL}ResetPPPoECreds?serial=${params.serial}&productClass=${params.productClass}&oui=${params.oui}&deviceId=${encodeURIComponent(params.deviceId)}`;

    const options = buildHttpOptions(uri);

    const request = https.request(options, (response) => {
        if (response.statusCode === 404) {
            return callback(null, null);
        }

        if (response.statusCode >= 400) {
            const message = `Unexpected error resetting PPPoE credentials. Response Code: ${response.statusCode}. Status Message: ${response.statusMessage}. Response Type: ${typeof response.statusCode}`;
            return callback(new Error(message));
        }

        let data = '';
        response.on('data', d => data = data + d.toString());

        response.on('end', () => {
            let result = JSON.parse(data);

            // This data gets returned to the provision script in the config variable
            return callback(null, result);
        });
    });

    request.on('error', (err) => callback(err));

    request.end();
}

Thank you so much! i have figured it out.