Use of openacs tr-069 parameters

OpenACS

Configurations script

OpenACS supports configuration scripts written in JavaScript. If you want to use scripts to configure CPE you must have a script named 'Default' because this is the script the server will try to run on CPE Inform request when it has no configuration files or firmware update requests pending.

Functions

logger

Function provides access to standard application server logger facility.

logger ('My message'); // message with default severity WARNING is logged. logger ('severe', 'Error message'); logger ('warning', 'Warning message'); logger ('info', 'Informational message'); ~~~~~~ #### call #### Function lets to run another script.

call ('script_name');

Variables ------ #### cpedb #### cpedbglobalvariableprovidesaccestoCPEbeanindatabase, namelytopropertiesfield.Theycanbeaccessedasusualjavascriptproperties.TosavethembacktodatabasemethodSaveshouldbeused.Thisobjectisintended~ave_spedom.Thisobjectisintended ~ 'vave_configurationproperties =; ~~~~ #### cpe #### cpeglobalvariableprovidesaccesstoalltheCPEvariablesandRPCcallsspecifiedinTR-069. ##### Properties ##### ** Inform ** - exposesInformrequestwhichtriggeredconfigurationscripttorun. ##### Methods ##### ** () ** - returnarraysofmethodssupportedbyCPE. ~~~~ // thiswilloutputsupportedmethodstoserverconsolevarmethods = cpe.GetRPCMethods (); for (i = 0; i
** AddObject (top_object_name, parameterKey) ** - creates new object instance. Returns object with properties * Status * and * InstanceNumber *. ** DeleteObject (object_name, parameterKey) ** - delete object. Returns integer status. ** SetParameterAttributes (params_array) ** - set attributes for parameters. Returns nothing.

var parameters = new Array ();
parameters [0] = new Object;
parameters [0] .Name = 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions';
parameters [0] .Notification = 0;
parameters [0] .NotificationChange = true;
parameters [0] .AccessListChange = true;
parameters [0] .AccessList = new Array ();
parameters [0] .AccessList [0] = 'subscriber';
cpe.SetParameterAttributes (parameters);

** GetParameterAttributes (parameter_names_array) **

var p = new Array ();
p [0] = 'InternetGatewayDevice.ManagementServer.PeriodicInformEnable';
var r = cpe.GetParameterAttributes (p);

** Reboot (commandKey) ** - reboots cpe.

cpe.Reboot ("commandKey");

** FactoryReset ** - resets cpe to factory default settings. Method is optional in cpe so not all of them has support for it.

cpe.FactoryReset ();

** ScheduleInform (seconds_to_delay, commandKey) ** - request the CPE to schedule a one-time Inform method call (separate from its periodic Inform method calls) sometime in the future. Method is optional in cpe so not all of them has support for it.

cpe.ScheduleInform (3600, "commandKey"); // schedule inform in one hour

** X_00000C_ShowStatus (array_of_show_commands) ** - Cisco proprietary method to run several show commands and get their output. ~~~~~ var commands = new Array (); commands [0] = "show version"; commands [1] = "show running"; var response = cpe.X_00000C_ShowStatus (commands); var thecommand = response [0] .Command; var itsoutput = response [0] .Response;

X_JUNGO_COM_RGCommand (telnet_command) - jungo.com OpenRG based firmware proprietary method to run command.

var response = cpe.X_JUNGO_COM_RGCommand ("net ifconfig"); var result = response.Result; // output of command var status = response.Status; // status - 0 if succes

SyncParameterValues - check and synchronize parameter values ​​on cpe.

varparameters = newArray (); parameters [0] = {Name: 'InternetGatewayDevice.ManagementServer.PeriodicInformEnable', Value: '1'}; parameters [1] = {Name: 'InternetGatewayDevice.ManagementServer.PeriodicInformInterval', Value: '300' }; cpe.SyncParameterValues ​​(parameters);

db

This object allows to work with database. The database can be the same the openacs uses to store data as well as external datasource configured similar to datasource in [1] step 3

This would run SELECT query on datasource named the data_source_name.

db.Query (data_source_name, select_statement)

This would run query on openacs datasource "java: ACS".

db.Query (select_statement)

it is equivalent to

db.Query ("java: ACS", select_statement)

returns array of objects with fields name as in query e.g.

try {var rs = db.Query ("SELECT id, serialno FROM hostsbean") logger ("Rows found =" + rs.length) for (i = 0; i

To run INSERT or UPDATE queries use Update function.

db.Update (data_source_name, update_statement)

This would run query on openacs datasource "java: ACS".

db.Update (select_statement)

returns count of rows affected e.g.

try {var rs = db.Update ("INSERT id, serialno INTO hostsbean VALUES (NULL, '12345')")} catch (e) {logger ("DS exception:" + e.message)}