Applying provision depending on timestamp

Hello,

I have a configuration database for my devices that I use as a means of building a config file for that device on the fly. I want the device to reapply the config whenever the timestamp of the record in the config database changes. I am pulling the timestamp of that record into GenieACS as a virtual parameter for that device. I already have a provision that applies the database-generated config file for that device. The problem that I can’t figure out how to solve is how to tell if there has been a change to the timestamp from before. I was going to try comparing the timestamp virtual parameter with the last inform time for the device but the last inform does not appear in the parameter list and I’m not even sure if that strategy would work because it depends on timing - ex if last inform is updated before it runs my comparison, the comparison may never be true and the config would then never apply.

Any ideas or feedback would be appreciated.

I found an alternative way of doing what I wanted - comparing the database record update timestamp to the config file downloaded timestamp.

let uuid = declare(“VirtualParameters.UUID”, {value: 1}).value[0];
let secret = declare(“VirtualParameters.SECRET”, {value: 1}).value[0];
let lastdownload = declare(“Downloads.[FileType:3 Vendor Configuration File].Download”, {value: 1}).value[0];
let updatedat = declare(“VirtualParameters.UPDATED-AT”, {value: 1}).value[0];
let datelastdownload = new Date(lastdownload);
let dateupdatedat = new Date(updatedat);

if (datelastdownload < dateupdatedat) {
log(“Last config download date (” + datelastdownload + “) is older than last update date (” + dateupdatedat + “, triggering config update.”);
log("About to download: " + “files/” + uuid + “/” + secret + “/alter-rsc.alter”);
declare(“Downloads.[FileType:3 Vendor Configuration File]”,
{path: 1}, {path: 1});
declare(“Downloads.[FileType:3 Vendor Configuration File].FileName”,
{value: 1}, {value: “files/” + uuid + “/” + secret + “/alter-rsc.alter”});
declare(“Downloads.[FileType:3 Vendor Configuration File].Download”,
{value: 1}, {value: Date.now()});
} else {
log(“Last config download date (” + datelastdownload + “) is newer than last update date (” + dateupdatedat + “, no config update necessary.”);
}

1 Like