Fault preset_loop when executing preset

Hi, im getting preset_loop fault when executing the following provision:

// Device ID as user name
const username = declare("DeviceID.ID", {value: 1}).value[0]
//log("username=",username)
// Password will be fixed for a given device because Math.random() is seeded with device ID by default.
const password = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
//log("password=", password)

const informInterval = 300;

// Refresh values daily
const daily = Date.now();


// Unique inform offset per device for better load distribution
const informTime = daily % 86400000;

declare("InternetGatewayDevice.ManagementServer.ConnectionRequestUsername", {value: daily}, {value: username});
declare("InternetGatewayDevice.ManagementServer.ConnectionRequestPassword", {value: daily}, {value: password});
declare("InternetGatewayDevice.ManagementServer.PeriodicInformEnable", {value: daily}, {value: true});
declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", {value: daily}, {value: informInterval});
//declare("InternetGatewayDevice.ManagementServer.PeriodicInformTime", {value: daily}, {value: informTime});

declare("Device.ManagementServer.ConnectionRequestUsername", {value: daily}, {value: username});
declare("Device.ManagementServer.ConnectionRequestPassword", {value: daily}, {value: password});
declare("Device.ManagementServer.PeriodicInformEnable", {value: daily}, {value: true});
declare("Device.ManagementServer.PeriodicInformInterval", {value: daily}, {value: informInterval});
declare("Device.ManagementServer.PeriodicInformTime", {value: daily}, {value: informTime});

//Obtener datos del device para enviar
const serialNumber = declare("DeviceID.SerialNumber", { value: 1 }).value[0];
const deviceId = declare("DeviceID.ID", {value: 1}).value[0]
const eventType = "inform"; // En el argumento viene el tipo de evento
log('Event type is ',eventType)
log('Executing ext')
const result = ext("ext-event-notifier","notifyEventToFibermanager", deviceId, serialNumber, eventType)

//log('Executing ext returnCommandToAcs')
//const result = ext("ext-event-notifier","returnCommandToAcs")
log('Complete response is: ',result)


//Applying actions returned
if (result.action_list){
	for (let action of result.action_list){
      log("Executing action with object: " + action.object + " and value: " + action.value)
      if (action.type == "addObject"){
      	declare(action.object, null, {path: action.value})      
      }else if(action.type == "setParameterValues"){
      	declare(action.object, null, {value: action.value})      
      }
	}
}
log('ext executed, result: ',result.response)

Bassicaly in my external function i return a series of actions to execute with the object and the value it must have + the type.
But im getting the following logs:

2024-10-01T16:56:24.298Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Event type is ; 0="i" 1="n" 2="f" 3="o" 4="r" 5="m"
2024-10-01T16:56:24.298Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing ext
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Complete response is: ; response="success" action_list=[{"type":"addObject","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice","value":"2"},{"type":"addObject","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection","value":"1"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WanName","value":"2_Traffic_vlan61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.AddressingType","value":"DHCP"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.ConnectionType","value":"IP_Routed"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.PossibleConnectionTypes","value":"IP_Routed"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Name","value":"2_Traffic_vlan61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Enable","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Mode","value":"2"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.VLANIDMark","value":"61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Enable","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Reset","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID","value":"f2h_6264"},{"type":"setParameterValues","object":"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase","value":"00000000AD1B"}]
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice and value: 2
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection and value: 1
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WanName and value: 2_Traffic_vlan61
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.AddressingType and value: DHCP
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.ConnectionType and value: IP_Routed
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.PossibleConnectionTypes and value: IP_Routed
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Name and value: 2_Traffic_vlan61
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Enable and value: true
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Mode and value: 2
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.VLANIDMark and value: 61
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Enable and value: true
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Reset and value: true
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID and value: f2h_6264
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase and value: 00000000AD1B
2024-10-01T16:56:24.430Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: ext executed, result: ; 0="s" 1="u" 2="c" 3="c" 4="e" 5="s" 6="s"
2024-10-01T16:56:24.431Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: ACS request; acsRequestId="1924902f5f90400" acsRequestName="SetParameterValues"
2024-10-01T16:56:24.435Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Event type is ; 0="i" 1="n" 2="f" 3="o" 4="r" 5="m"
2024-10-01T16:56:24.435Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing ext
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Complete response is: ; response="success" action_list=[{"type":"addObject","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice","value":"2"},{"type":"addObject","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection","value":"1"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WanName","value":"2_Traffic_vlan61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.AddressingType","value":"DHCP"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.ConnectionType","value":"IP_Routed"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.PossibleConnectionTypes","value":"IP_Routed"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Name","value":"2_Traffic_vlan61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Enable","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Mode","value":"2"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.VLANIDMark","value":"61"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Enable","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Reset","value":"true"},{"type":"setParameterValues","object":"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID","value":"f2h_4773"},{"type":"setParameterValues","object":"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase","value":"00000000AD1B"}]
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice and value: 2
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection and value: 1
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WanName and value: 2_Traffic_vlan61
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.AddressingType and value: DHCP
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.ConnectionType and value: IP_Routed
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.PossibleConnectionTypes and value: IP_Routed
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Name and value: 2_Traffic_vlan61
2024-10-01T16:56:24.560Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Enable and value: true
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.Mode and value: 2
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.X_CT-COM_WANGponLinkConfig.VLANIDMark and value: 61
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Enable and value: true
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.Reset and value: true
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID and value: f2h_4773
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: Executing action with object: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.KeyPassphrase and value: 00000000AD1B
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: Script: ext executed, result: ; 0="s" 1="u" 2="c" 3="c" 4="e" 5="s" 6="s"
2024-10-01T16:56:24.561Z [INFO] ::ffff:10.42.0.1 202BC1-BM632w-000000: ACS request; acsRequestId="1924902f5f90500" acsRequestName="SetParameterValues"
2024-10-01T16:56:24.563Z [WARN] ::ffff:10.42.0.1 202BC1-BM632w-000000: Channel has faulted; channel="default" retries=1 faultCode="preset_loop" faultMessage="The presets are stuck in an endless configuration loop"
2024-10-01T16:56:24.563Z [WARN] ::ffff:10.42.0.1 202BC1-BM632w-000000: Channel has faulted; channel="inform" retries=1 faultCode="preset_loop" faultMessage="The presets are stuck in an endless configuration loop"

I never got this error i cant find where the problem is, i have tried adding { value: daily } to the declarations but i get the same error. Somebody knows whats happening and can help me?

You have competing preset values for InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID

: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID and value: f2h_6264
: InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID and value: f2h_4773

Provision scripts may get executed multiple times in a given session. Although all data model-mutating operations are idempotent, a script as a whole may not be. It is, therefore, necessary to repeatedly run the script until there are no more side effects and a stable state is reached.

So GenieACS is going to keep running your script until there are no more changes. In this case, GenieACS tried 4 times to get to a state of no changes and could not. So it throws a fault.

As a matter of structure and form, I would move your custom code outside of the inform script and into its own script. This will allow you to compose the various provision scripts as necessary for different operations.

1 Like

Oh, the second executing generates another random number for ssid.
I change it to generate the same random number for intervals and it works marvels.
Thank you a lot.