Mikrotik. Create PPPoE interface

Hi

Could anyone help to add PPPoE interface on the Mikrotik device.
Here are parts of my provision script:

//get count of ppp interfaces
let num = declare(“Device.PPP.InterfaceNumberOfEntries”, {value: 1}).value[0];
log("num: " + num);

//create one more PPP interface
declare(“Device.PPP.Interface.*”, null, {path: num+1 });

Then I should set “Device.PPP.Interface.I.X_MIKROTIK_Type” = “PPPoE”
Where I - number of just created (declared) PPP interface.
Code:

declare(“Device.PPP.Interface.”+ “3” +“.X_MIKROTIK_Type”, null, {value: “PPPoE”});

This code works when I enter I=3 manually. But last number can change. I want to get the number of last created interface from device parameters. The question is how to do this.


Then I tried this:

var interfaces = declare(“Device.PPP.Interface.”);
log(interfaces.size); // count of PPP.Interfaces
log(interfaces.path); // path of first PPP.Interface

But I don’t know how to get number or path of last element in interfaces


I’d suggest doing this slightly differently. Find a sub param that should be unique and use that as your key. For example, if you only ever going to have a single instance where ‘X_MIKROTIK_Type’ is ‘PPPoE’, then you can do something like this:

declare(“Device.PPP.Interface.[X_MIKROTIK_Type:PPPoE]”, {path: Date.now()}, {path: 1});

This will create a new instance if necessary and set ‘X_MIKROTIK_Type’. If there are other params you need to set:

declare(“Device.PPP.Interface.[X_MIKROTIK_Type:PPPoE].Param”, {value: Date.now()}, {value: "abc"});