I am currently migrating from LibreACS to GenieACS and need guidance on adapting my existing LibreACS provisioning scripts to GenieACS. My current script handles various TR-069 methods like GetParameterValues, SetParameterValues, Reboot, Download, etc., and includes logic for handling events like BOOTSTRAP, BOOT, and PERIODIC.
Here’s a summary of my requirements:
Event Handling: In LibreACS, I use events like BOOTSTRAP, BOOT, and PERIODIC to trigger specific actions. How can I replicate this event-driven logic in GenieACS?
Database Queries: My script queries a database to fetch configuration data (e.g., WiFi settings, firmware URLs). Since GenieACS doesn’t support direct database queries in scripts, what’s the recommended approach?
Task Scheduling: I need to schedule tasks like SetParameterValues, Reboot, and Download based on conditions. How can I use declare('task', {...}) effectively for this purpose?
Firmware Upgrades: My script initiates firmware upgrades using the Download method. How can I implement this in GenieACS?
I would appreciate any guidance or examples on how to:
Translate event-driven logic into GenieACS scripts.
Replace database queries with GenieACS features like tags or presets.
Schedule and manage tasks like SetParameterValues, Reboot, and Download.
Thanks for your quick response. Please refer to the sample code from my existing script. What do you recommend for use? only the declare function? Apart from that, I have also used the AddObject and DeleteObject functions
With provision scripts, you do you instances differently. Here is a piece of code to add port forward entries, but you get the idea of how it works:
let keys = [
'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.PortMapping',
'Device.NAT.PortMapping'
];
for (let basePath of keys) {
// Tell GenieACS to remove any existing port mappings.
// No work will actually be done at this stage.
declare(basePath + '.[]', null, {path: 0});
// Each entry of portForwards is a JSON object. The keys/values are used to
// build the path expression for GenieACS
for (let forward of portForwards) {
const path = basePath + '.[' + Object.keys(forward).map(key => key + ':' + forward[key]).join(',') + ']';
log(`\r\n\r\nPortForwards - Updating - ${path}\r\n\r\n`, forward);
// Declare to GenieACS what the desired state is
declare(path, {path: 1}, {path: 1});
}
}
// When this script finishes executing is when the actual work of determining the
// delta and sending the necessary AddObject/DeleteObject/SPV/etc commands to the CP