How to create new instances?


I really dont end to understand how to create new index, I try to use the example on the doc but is not clear for me: when i add the * , i get a fault of loop. if i let without * , it wont create anything.

Can give me a hand to understand how to create a new entry without generate numbers that are not consecutive? i dont know anymore were to find a example of this or more clear explanation.


// Ensure that all other instances are deleted
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.[]”, null, {path: 0});
// Add the entries we care about
let entries = declare(“Device.Services.X_MM_RemoteAccess.TrustedDomainNumberOfEntries”, {value: now}).value[0];
log(‘ENTRIES’, {are: entries});

declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.*”, {path: 1}, { path: (entries+2) });
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.1.Enable”, {value: now}, {value: true});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.1.IPAddress”, {value: now}, {value: “”});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.1.PrefixLength”, {value: now}, {value: “16”});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.2.Enable”, {value: now}, {value: true});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.2.IPAddress”, {value: now}, {value: “”});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.2.PrefixLength”, {value: now}, {value: “8”});

try this:
// Ensure that all other instances are deleted
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.*”, null, {path: 0});

declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.[Enable: true, IPAddress:,PrefixLength:16]”, null, {path: 1});
declare(“Device.Services.X_MM_RemoteAccess.TrustedDomain.[Enable: true, IPAddress:,PrefixLength:8]”, null, {path: 1});

hello lavira thanks

I do test, and with * i got “faultCode=“preset_loop” faultMessage=“The presets are stuck in an endless configuration loop””

Also, it delete instances but creates a new one not with 1 and 2 but with a pointer increased. Is there a way to point to 1? or may be a issue of CPE?

This is the instances created (from test):

Device.Services.X_MM_RemoteAccess.TrustedDomain.67.Enable true
Device.Services.X_MM_RemoteAccess.TrustedDomain.67.PrefixLength 16
Device.Services.X_MM_RemoteAccess.TrustedDomain.68.Enable true
Device.Services.X_MM_RemoteAccess.TrustedDomain.68.PrefixLength 8
Device.Services.X_MM_RemoteAccess.TrustedDomainNumberOfEntries 2

again, thanks for quick response

ahhh, sorry … I usually run provision scripts based on the presence of certain tags and remove the tags when the provision finishes in order to prevent this kind of loops.
Note from the documentation ( : 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 in order to make it idempotent, please remove from the provisioning script the line:
declare(‘Device.Services.X_MM_RemoteAccess.TrustedDomain.*’, null, {path: 0});

If you want to make sure that all devices have just the items you provided you could try something like:

let remoteAccess = [{ipAddress:'', prefixLength: '16'},
                    {ipAddress:'', prefixLength: '8'}];

declare('Device.Services.X_MM_RemoteAccess.TrustedDomain.*', null, {path: remoteAccess.length});

for (let i of remoteAccess) { 
    declare('Device.Services.X_MM_RemoteAccess.TrustedDomain.[Enabled:true,IPAddress:' +i.ipAddress+ ',PrefixLength:'+i.prefixLength+']', null, {path: 1}); 

not 100% sure it will work in all cases, but please give it a try :slightly_smiling_face:

Seem to enter in a infinite loop , dont know why since i should be up to two…

Let’s hope the third time will be alright:

let remoteAccess = [{ipAddress:'', prefixLength: '16'},
                    {ipAddress:'', prefixLength: '8'}];

let d = declare('Device.Services.X_MM_RemoteAccess.TrustedDomain.*', null, {path: remoteAccess.length});

for (let instance of d) {
    let i = remoteAccess.shift();
    declare(instance.path + '.Enabled', null, {value: true});
    declare(instance.path + '.IPAddress', null, {value: i.ipAddress});
    declare(instance.path + '.PrefixLength', null, {value: i.prefixLength});

    commit(); // optional

You are never guaranteed as to which instance ids are returned by the CPE. Just because you delete all instances does not mean the CPE will start renumbering at 1. This is identified out in the docs.

To fix your script, these are the changes you need to make:

let now =;
//Ensure that *all* other instances are deleted
declare("Device.Services.X_MM_RemoteAccess.TrustedDomain.[]", null, {path: 0});

//Add the two entries we care about
declare("Device.Services.X_MM_RemoteAccess.TrustedDomain.[Enable:true,IPAddress:,PrefixLength:16]", {path: now}, {path: 1});
declare("Device.Services.X_MM_RemoteAccess.TrustedDomain.[Enable:true,IPAddress:,PrefixLength:8]", {path: now}, {path: 1});

There is no need for an explicit commit() call either.

The way this works is GenieACS will delete the in-memory version of these instances, build up the new instances, diff between the CPE and make any necessary changes. So for example if the CPE already has two instances of TrustedDomain with the correct values, no changes will be sent to the CPE.

Thanks lavira and akcoder.

But from the debug log, i see that its delete the “4253” (since i do to many test and dont do any factory reset yet).


But my question is, should CPE need to decrement the pointer automatically if the last is erased, per example? i don know if this is a bad implementation on CPE. Since i see that only two objects are 4253,4254 or later 4255,4256, and cpe always increments but not decrement when erased.

Thanks a lot!

akcoder’s answer is almost identical to my first one and I think it won’t work also, because the provisioning script will run every time and delete + add the same rules, thus is not idempotent.
Tr069 protocol states that the instance number will be incremented and won’t be reused so if you want to start from 1 again, you must do a reset to factory default.

Please try the code from my third answer … that should work.

Hello guys .

Yes i used the akcoder simple sintax for this case, since i don need any other entries on Trusted domain. (thanks Akcoder!! for clarifications)

But i also try you code, Lavira, for another case, that i need to make entries for routing table and i need to keep the existence of 4 or 5 that are embedded on CPE. But i dont know why is not working. May be my low or very little knowledge of programming wont let me visualize the solution over your help:

// Configure routing management interfaces
log(‘Setting setting management routes and’);
let Default_ip_mgmt = declare(“Device.DHCPv4.Client.4.IPRouters”, {value: 1}).value[0];
let routing_entries = declare(“Device.Routing.Router.1.IPv4ForwardingNumberOfEntries”, {value: 1}).value[0];

let subnets =[{Enable:true, DestIPAddress:‘’, DestSubnetMask: ‘’, Interface:‘Device.IP.Interface.5’, StaticRoute:true},
{Enable:true, DestIPAddress:‘’, DestSubnetMask: ‘’, Interface:‘Device.IP.Interface.5’, StaticRoute:true}];

let d = declare(‘Device.Routing.Router.1.IPv4Forwarding.*’, null, {path: subnets.length + routing_entries });

for (let instance of d ) {
let i = subnets.shift();
declare(instance.path + ‘.Enable’, null, {value: i.Enable});
declare(instance.path + ‘.DestIPAddress’, null, {value: i.DestIPAddress});
declare(instance.path + ‘.DestSubnetMask’, null, {value: i.DestSubnetMask});
declare(instance.path + ‘.GatewayIPAddress’, null, {value: Default_ip_mgmt});
declare(instance.path + ‘.Interface’, null, {value: i.Interface});
declare(instance.path + ‘.StaticRoute’, null, {value: i.StaticRoute});

this casue a error:

name: TypeError
message: Cannot read property ‘Enable’ of undefined
stack: |-
TypeError: Cannot read property ‘Enable’ of undefined
at test:13:56

Dont know why Enable is undefined since is a valid value. Also dont know how will instance will work with a value greater than two that i declare. (i know that this is a lack for programming from my side i need to cachup soon as possible…)

For all cases, the issue of iterance, i do manage with Tags (since this points i will use on BOOTSTRAP).

This solution actually comes from @zaidka. Because of the way provision scripts work, this doesn’t rely on instance ids, only the values between the brackets.