NBI add object

Dan Morphis dan at milkcarton.com
Tue May 15 12:31:08 EDT 2018


Provision scripts will take care of adding object instances if needed. You
will have so many fewer issues if you switch to using provisioning scripts
and move away from using the API to add specific object instances. I went
from getting several emails a week about modems not working properly when
we used the old v1.0 way of configuring CPEs (manually adding/deleting
object instances, etc), to going over a year with no complaints about the
CPE provisioning process.

This right here is all the code in a provisioning script you need to ensure
that a PPPoE connection is created for the device. Add a few dozen lines in
your external script and whatever API code you need, and any device/mfgr
specific code to the provisioning script and you can easily have CPEs auto
provisioning in under 200 lines of code.

const now = Date.now();

let provisioned = declare("Tags.Provisioned", {value: 1});
if (provisioned.value !== undefined) {
  log('CPE is provisioned, returning');
  return;
}

let model = declare("InternetGatewayDevice.DeviceInfo.ModelName", {value:
1}).value[0];
let serialNumber = declare("DeviceID.SerialNumber", {value: 1}).value[0];
let productClass = declare("DeviceID.ProductClass", {value: 1}).value[0];
let oui = declare("DeviceID.OUI", {value: 1}).value[0];
let args = {serial: serialNumber, productClass: productClass, oui: oui};

//Get the PPPoE creds from our external script which calls out to our API
let config = ext('cpe-config', 'resetPppoe', JSON.stringify(args));
if (!config) {
  log('SmartRG_Managed - No config returned from API');
  return;
}

//Ensure we have 1 WANPPPConnection instance on the ATM device
log('SmartRG_Managed - Creating WANPPPConnection (if necessary)');
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*",
null, {path: 1});

log('SmartRG_Managed - Setting up WANPPPConnection');
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*",
{path: now}); //Refresh the node...

declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Name",
{value: now}, {value: "Internet"});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.ConnectionType",
{value: now}, {value: "IP_Routed"});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_IfName",
{value: now}, {value: "ppp0.1"});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.NATEnabled",
{value: now}, {value: true});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_FirewallEnabled",
{value: now}, {value: true});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Enable",
{value: now}, {value: true});
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.PPPoEServiceName",
{value: now}, {value: "broadband"});


//{value: now} forces GenieACS to update the value of the username/password
log('SmartRG_Managed - Setting un: ' + config.username + ', pw: ' +
config.password);
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username",
{value: now}, {value: config.username});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password",
{value: now}, {value: config.password});

log('Done configuring. Setting tags');
declare("Tags.Provisioned", null, {value: true});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20180515/18ed8093/attachment.html>


More information about the Users mailing list