<div dir="ltr">Look at using provisioning scripts. I'm still not understanding why you care about the last index? What you really want is to only have 1 WANPPPConnection instance on each WANConnectionDevice instance. I'm going to presume you would want all the WANPPPConnection instances (on each WANConnection) to have the same credentials?<div><br></div><div><br></div><div><br></div><div>This is the provision script I use. This script checks for a "Provisioned" tag on the CPE, if the CPE has the Provisioned tag, then the script returns. At the end of the script, the Provisioned tag is set. This script is kicked off by a preset which has the following preconditions: Tags != Provisioned, Tags == Routed. Our CPEs can be in one of two states, Routed or Bridged.</div><div><br></div><div>Data is returned to the provisioning script from an external script (line 18). The external script interfaces with our subscriber management system which returns the username and password for the given CPE, as well as Wi-Fi and DHCP settings (we don't allow customers access to the CPE and require them to do all configuration through our portal which stores the Wi-Fi and DHCP settings (with the passphrase stored encrypted).</div><div><div><br></div><div>*********************************************************************** Provisioning script ***************************************************</div><div></div><pre style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">const </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now </span>= Date.<span style="color:rgb(122,122,67)">now</span>();<br><br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">provisioned </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"Tags.Provisioned"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>});<br><span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">provisioned</span>.<span style="color:rgb(102,14,122);font-weight:bold">value </span>!== <span style="color:rgb(102,14,122);font-weight:bold">undefined</span>) {<br>    <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'CPE is (allegedly) provisioned, returning'</span>);<br>    <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">model </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.DeviceInfo.ModelName"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>}).<span style="color:rgb(102,14,122);font-weight:bold">value</span>[<span style="color:rgb(0,0,255)">0</span>];<br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">serialNumber </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"DeviceID.SerialNumber"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>}).<span style="color:rgb(102,14,122);font-weight:bold">value</span>[<span style="color:rgb(0,0,255)">0</span>];<br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">productClass </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"DeviceID.ProductClass"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>}).<span style="color:rgb(102,14,122);font-weight:bold">value</span>[<span style="color:rgb(0,0,255)">0</span>];<br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">oui </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"DeviceID.OUI"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>}).<span style="color:rgb(102,14,122);font-weight:bold">value</span>[<span style="color:rgb(0,0,255)">0</span>];<br><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">args </span>= {<span style="color:rgb(102,14,122);font-weight:bold">serial</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">serialNumber</span>, <span style="color:rgb(102,14,122);font-weight:bold">productClass</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">productClass</span>, <span style="color:rgb(102,14,122);font-weight:bold">oui</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">oui</span>};<br><br><br><span style="color:rgb(128,128,128);font-style:italic">//Get the PPPoE creds<br></span><span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">config </span>= ext(<span style="color:rgb(0,128,0);font-weight:bold">'cpe-config'</span>, <span style="color:rgb(0,128,0);font-weight:bold">'resetPppoe'</span>, <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">JSON</span>.<span style="color:rgb(122,122,67)">stringify</span>(<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">args</span>));<br><span style="color:rgb(0,0,128);font-weight:bold">if </span>(!<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">config</span>) {<br>    <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'No config returned from API'</span>);<br>    <span style="color:rgb(0,0,128);font-weight:bold">return</span>;<br>}<br><br><br><span style="color:rgb(128,128,128);font-style:italic">//Disable the WANIPConnection instance on the ATM interface<br></span><span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Disabling WANIPConnection'</span>);<br>declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*.Enable"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">path</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>, <span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">false</span>});<br><br><br><span style="font-style:italic">refreshWlan</span>();<br><span style="font-style:italic">setupBaseWanPppConnection</span>();<br><br><span style="font-style:italic">setAccountSpecificSettings</span>(<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">config</span>);<br><span style="font-style:italic">setConnectionServicesAndDns</span>();<br><br><span style="color:rgb(128,128,128);font-style:italic">//Refresh the mac and external ip<br></span>declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.MACAddress"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>});<br><br><span style="font-style:italic">updateTags</span>(<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">config</span>);<br><span style="font-style:italic">bouncePppoeConnection</span>();<br><br><span style="color:rgb(0,0,128);font-weight:bold">return</span>; <span style="color:rgb(128,128,128);font-style:italic">//Not explicitly needed, but I want to prevent any extranious code at the bottom from executing...<br></span><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">updateTags</span>(config) {<br>    <span style="color:rgb(0,0,128);font-weight:bold">if </span>(config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>) {<br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>(config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(102,14,122);font-weight:bold">add </span>&& config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(102,14,122);font-weight:bold">add</span>.<span style="color:rgb(102,14,122);font-weight:bold">length</span>) {<br>            <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Adding tags: ' </span>+ config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(102,14,122);font-weight:bold">add</span>.<span style="color:rgb(122,122,67)">join</span>(<span style="color:rgb(0,128,0);font-weight:bold">', '</span>));<br><br>            <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">let </span>[<span style="color:rgb(69,131,131)">index</span>, <span style="color:rgb(69,131,131)">tag</span>] <span style="color:rgb(0,0,128);font-weight:bold">of </span>Object.<span style="color:rgb(122,122,67)">entries</span>(config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(102,14,122);font-weight:bold">add</span>)) {<br>                <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Tag: ' </span>+ <span style="color:rgb(69,131,131)">tag</span>);<br><br>                declare(<span style="color:rgb(0,128,0);font-weight:bold">"Tags." </span>+ <span style="color:rgb(69,131,131)">tag</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>            }<br>        }<br><br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>(config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(122,122,67)">remove </span>&& config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(122,122,67)">remove</span>.<span style="color:rgb(102,14,122);font-weight:bold">length</span>) {<br>            <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Removing tags: ' </span>+ config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(122,122,67)">remove</span>.<span style="color:rgb(122,122,67)">join</span>(<span style="color:rgb(0,128,0);font-weight:bold">', '</span>));<br><br>            <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">let </span>[<span style="color:rgb(69,131,131)">index</span>, <span style="color:rgb(69,131,131)">tag</span>] <span style="color:rgb(0,0,128);font-weight:bold">of </span>Object.<span style="color:rgb(122,122,67)">entries</span>(config.<span style="color:rgb(102,14,122);font-weight:bold">tags</span>.<span style="color:rgb(122,122,67)">remove</span>)) {<br>                <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Tag: ' </span>+ <span style="color:rgb(69,131,131)">tag</span>);<br>                declare(<span style="color:rgb(0,128,0);font-weight:bold">"Tags." </span>+ <span style="color:rgb(69,131,131)">tag</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">false</span>});<br>            }<br>        }<br>    }<br><br>    <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Done configuring. Setting provisioned tag'</span>);<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"Tags.Provisioned"</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">refreshWlan</span>() {<br>    <span style="color:rgb(128,128,128);font-style:italic">//Refresh the WLAN config<br></span><span style="color:rgb(128,128,128);font-style:italic">    </span><span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Refreshing WLAN'</span>);<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.*"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">path</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.SSID"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.LANDevice.1.WLANConfiguration.*.Enable"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.LANDevice.1.WLANConfiguration.*.X_SMARTRG_COM_BaseMacAsDefaultPassPhrase"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">false</span>});<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">setupBaseWanPppConnection</span>() {<br>    <span style="color:rgb(128,128,128);font-style:italic">//Ensure we have a WANPPPConnection instance<br></span><span style="color:rgb(128,128,128);font-style:italic">    </span><span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Creating WANPPPConnection (if necessary)'</span>);<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*"</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>, {<span style="color:rgb(102,14,122);font-weight:bold">path</span>: <span style="color:rgb(0,0,255)">1</span>});<br><br>    <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Setting up WANPPPConnection'</span>);<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">path</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}); <span style="color:rgb(128,128,128);font-style:italic">//Refresh the node...<br></span><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic">    </span>declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Name"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,128,0);font-weight:bold">"Internet"</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.ConnectionType"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,128,0);font-weight:bold">"IP_Routed"</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_IfName"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,128,0);font-weight:bold">"ppp0.1"</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.NATEnabled"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_FirewallEnabled"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Enable"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.PPPoEServiceName"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,128,0);font-weight:bold">"broadband"</span>});<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">setAccountSpecificSettings</span>(config) {<br>    <span style="color:rgb(128,128,128);font-style:italic">//{value: now} forces GenieACS to update the value of the username/password if the value hasn't been updated before now<br></span><span style="color:rgb(128,128,128);font-style:italic">    </span><span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Setting un: ' </span>+ config.<span style="color:rgb(102,14,122);font-weight:bold">username </span>+ <span style="color:rgb(0,128,0);font-weight:bold">', pw: ' </span>+ config.<span style="color:rgb(102,14,122);font-weight:bold">password</span>);<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: config.<span style="color:rgb(102,14,122);font-weight:bold">username</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: config.<span style="color:rgb(102,14,122);font-weight:bold">password</span>});<br><br>    <span style="color:rgb(128,128,128);font-style:italic">//Refresh the vParams<br></span><span style="color:rgb(128,128,128);font-style:italic">    </span>declare(<span style="color:rgb(0,128,0);font-weight:bold">"VirtualParameters.pppoeUsername"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>});<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">if </span>(config.<span style="color:rgb(102,14,122);font-weight:bold">settings</span>) {<br>        <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Setting wifi/dhcp config'</span>);<br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>(<span style="color:rgb(0,0,128);font-weight:bold">let </span>[<span style="color:rgb(69,131,131)">key</span>, <span style="color:rgb(69,131,131)">value</span>] <span style="color:rgb(0,0,128);font-weight:bold">of </span>Object.<span style="color:rgb(122,122,67)">entries</span>(config.<span style="color:rgb(102,14,122);font-weight:bold">settings</span>)) {<br>            <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'KVP'</span>, {<span style="color:rgb(102,14,122);font-weight:bold">key</span>: <span style="color:rgb(69,131,131)">key</span>, <span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(69,131,131)">value </span>});<br>            declare(<span style="color:rgb(69,131,131)">key</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(69,131,131)">value</span>});<br>        }<br>    }<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">setConnectionServicesAndDns</span>() {<br>    <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Setting connection services'</span>);<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">hasWanPort </span>= declare(<span style="color:rgb(0,128,0);font-weight:bold">"Tags.WanPort"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,255)">1</span>}).<span style="color:rgb(102,14,122);font-weight:bold">value </span>!== <span style="color:rgb(102,14,122);font-weight:bold">undefined</span>;<br>    <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">connServices </span>= <span style="color:rgb(0,128,0);font-weight:bold">'ppp0.1'</span>;<br>    <span style="color:rgb(0,0,128);font-weight:bold">if </span>(<span style="color:rgb(69,131,131)">hasWanPort</span>) {<br>        <span style="color:rgb(69,131,131)">connServices </span>= <span style="color:rgb(0,128,0);font-weight:bold">'ppp0.1,ppp1.1'</span>;<br>    }<br><br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.Layer3Forwarding.*"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>});<br><br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.Layer3Forwarding.X_BROADCOM_COM_DefaultConnectionServices"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(69,131,131)">connServices</span>});<br>    declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.X_BROADCOM_COM_NetworkConfig.DNSIfName"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(69,131,131)">connServices</span>});<br>}<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">bouncePppoeConnection</span>() {<br>    <span style="color:rgb(128,128,128);font-style:italic">//Bounce the PPPoE connection<br></span><span style="color:rgb(128,128,128);font-style:italic">    </span><span style="color:rgb(0,0,128);font-weight:bold">switch </span>(<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">model</span>) {<br>        <span style="color:rgb(0,0,128);font-weight:bold">case </span><span style="color:rgb(0,128,0);font-weight:bold">'SR515ac'</span>:<br>            <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Rebooting, because the CPE is dumb'</span>, {<span style="color:rgb(102,14,122);font-weight:bold">model</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">model</span>});<br>            declare(<span style="color:rgb(0,128,0);font-weight:bold">"Reboot"</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: Date.<span style="color:rgb(122,122,67)">now</span>()});<br>            <span style="color:rgb(0,0,128);font-weight:bold">break</span>;<br>        <span style="color:rgb(0,0,128);font-weight:bold">case </span><span style="color:rgb(0,128,0);font-weight:bold">'SR510N'</span>:<br>        <span style="color:rgb(0,0,128);font-weight:bold">default</span>:<br>            <span style="font-style:italic">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Bouncing the WANPPPConnection instances'</span>);<br>            declare(<span style="color:rgb(0,128,0);font-weight:bold">"InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.Reset"</span>, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">now</span>}, {<span style="color:rgb(102,14,122);font-weight:bold">value</span>: <span style="color:rgb(0,0,128);font-weight:bold">true</span>});<br>    }<br>}</pre><div><br></div><div><br></div></div><div><br></div><div><br></div><div>*********************************************************************** External script. Lives in genieacs/config/ext/cpe-config.js ***************************************************</div><div><pre style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">const </span><span style="color:rgb(69,131,131)">API_URL </span>= <span style="color:rgb(122,122,67)">process</span>.<span style="color:rgb(102,14,122);font-weight:bold">env</span>.API_URL || <span style="color:rgb(0,128,0);font-weight:bold">'<a href="https://your-host.com/api">https://your-host.com/api</a>'</span>;<br><span style="color:rgb(0,0,128);font-weight:bold">const </span><span style="color:rgb(69,131,131)">url </span>= <span style="color:rgb(102,14,122);font-weight:bold">require</span>(<span style="color:rgb(0,128,0);font-weight:bold">"url"</span>);<br><span style="color:rgb(0,0,128);font-weight:bold">const </span><span style="color:rgb(69,131,131)">http </span>= <span style="color:rgb(102,14,122);font-weight:bold">require</span>(<span style="color:rgb(69,131,131)">API_URL</span>.<span style="color:rgb(122,122,67)">split</span>(<span style="color:rgb(0,128,0);font-weight:bold">":"</span>, <span style="color:rgb(0,0,255)">1</span>)[<span style="color:rgb(0,0,255)">0</span>]);<br><br><span style="color:rgb(0,0,128);font-weight:bold">function </span><span style="font-style:italic">resetPppoe</span>(args, callback) {<br>    <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">params </span>= <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">JSON</span>.<span style="color:rgb(122,122,67)">parse</span>(args[<span style="color:rgb(0,0,255)">0</span>]);<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">const </span><span style="color:rgb(69,131,131)">uri </span>= <span style="color:rgb(69,131,131)">API_URL </span>+ <span style="color:rgb(0,128,0);font-weight:bold">"/ResetPPPoECreds?serial=" </span>+ <span style="color:rgb(69,131,131)">params</span>.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">serial </span>+ <span style="color:rgb(0,128,0);font-weight:bold">'&productClass=' </span>+ <span style="color:rgb(69,131,131)">params</span>.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">productClass </span>+ <span style="color:rgb(0,128,0);font-weight:bold">'&oui=' </span>+ <span style="color:rgb(69,131,131)">params</span>.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">oui</span>;<br><br>    <span style="color:rgb(102,14,122);font-weight:bold">console</span>.<span style="color:rgb(122,122,67)">log</span>({ <span style="color:rgb(102,14,122);font-weight:bold">uri</span>: <span style="color:rgb(69,131,131)">uri</span>, <span style="color:rgb(102,14,122);font-weight:bold">serial</span>: <span style="color:rgb(69,131,131)">params</span>.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">serial </span>});<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">options </span>= <span style="color:rgb(69,131,131)">url</span>.<span style="color:rgb(122,122,67)">parse</span>(<span style="color:rgb(69,131,131)">uri</span>);<br>    <span style="color:rgb(69,131,131)">options</span>.<span style="color:rgb(102,14,122);font-weight:bold">headers </span>= {<br>        <span style="color:rgb(102,14,122);font-weight:bold">accept</span>: <span style="color:rgb(0,128,0);font-weight:bold">'application/json'</span>,<br>        <span style="color:rgb(0,128,0);font-weight:bold">"content-type"</span>: <span style="color:rgb(0,128,0);font-weight:bold">'application/json'<br></span><span style="color:rgb(0,128,0);font-weight:bold">    </span>};<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">request </span>= <span style="color:rgb(69,131,131)">http</span>.<span style="color:rgb(122,122,67)">get</span>(<span style="color:rgb(69,131,131)">options</span>, <span style="color:rgb(0,0,128);font-weight:bold">function </span>(response) {<br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>(response.<span style="color:rgb(102,14,122);font-weight:bold">statusCode </span>== <span style="color:rgb(0,0,255)">404</span>) {<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>callback(<span style="color:rgb(0,0,128);font-weight:bold">null</span>, <span style="color:rgb(0,0,128);font-weight:bold">null</span>);<br>        }<br><br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>(response.<span style="color:rgb(102,14,122);font-weight:bold">statusCode </span>>= <span style="color:rgb(0,0,255)">400</span>) {<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>callback(<span style="color:rgb(0,0,128);font-weight:bold">new </span>Error(<span style="color:rgb(0,128,0);font-weight:bold">"Unexpected error resetting PPPoE credentials. Response Code: " </span>+ response.<span style="color:rgb(102,14,122);font-weight:bold">statusCode </span>+ <span style="color:rgb(0,128,0);font-weight:bold">'. Status Message: ' </span>+ response.<span style="color:rgb(102,14,122);font-weight:bold">statusMessage </span>+ <span style="color:rgb(0,128,0);font-weight:bold">'. t: ' </span>+ <span style="color:rgb(0,0,128);font-weight:bold">typeof </span>response.<span style="color:rgb(102,14,122);font-weight:bold">statusCode</span>));<br>        }<br><br>        <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">data </span>= <span style="color:rgb(0,128,0);font-weight:bold">""</span>;<br>        response.<span style="color:rgb(122,122,67)">on</span>(<span style="color:rgb(0,128,0);font-weight:bold">"data"</span>, <span style="color:rgb(0,0,128);font-weight:bold">function </span>(d) {<br>            <span style="color:rgb(69,131,131)">data </span>= <span style="color:rgb(69,131,131)">data </span>+ d.<span style="color:rgb(122,122,67)">toString</span>();<br>        });<br><br>        response.<span style="color:rgb(122,122,67)">on</span>(<span style="color:rgb(0,128,0);font-weight:bold">"end"</span>, <span style="color:rgb(0,0,128);font-weight:bold">function </span>() {<br>            <span style="color:rgb(0,0,128);font-weight:bold">let </span><span style="color:rgb(69,131,131)">result </span>= <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">JSON</span>.<span style="color:rgb(122,122,67)">parse</span>(<span style="color:rgb(69,131,131)">data</span>);<br><br>            <span style="color:rgb(102,14,122);font-weight:bold">console</span>.<span style="color:rgb(122,122,67)">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'Returning credentials to client'</span>, <span style="color:rgb(69,131,131)">result</span>);<br>            <span style="color:rgb(0,0,128);font-weight:bold">return </span>callback(<span style="color:rgb(0,0,128);font-weight:bold">null</span>, <span style="color:rgb(69,131,131)">result</span>);<br>        });<br>    });<br><br>    <span style="color:rgb(69,131,131)">request</span>.<span style="color:rgb(122,122,67)">on</span>(<span style="color:rgb(0,128,0);font-weight:bold">"error"</span>, <span style="color:rgb(0,0,128);font-weight:bold">function </span>(err) {<br>        <span style="color:rgb(102,14,122);font-weight:bold">console</span>.<span style="color:rgb(122,122,67)">log</span>(<span style="color:rgb(0,128,0);font-weight:bold">'args'</span>);<br>        <span style="color:rgb(102,14,122);font-weight:bold">console</span>.<span style="color:rgb(122,122,67)">log</span>(<span style="color:rgb(69,131,131)">arguments</span>);<br>        callback(err);<br>    });<br>}<br><br><span style="color:rgb(102,14,122);font-weight:bold">exports</span>.<span style="font-style:italic">resetPppoe </span>= <span style="font-style:italic">resetPppoe</span>;<br></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 5, 2017 at 11:21 PM, Marco Marino <span dir="ltr"><<a href="mailto:marino.mrc@gmail.com" target="_blank">marino.mrc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>More precisely, I can also access a WANDevice using a "condition" if possible. For example, I need to reset <br><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">InternetGatewayDevice.<wbr>WANDevice.X.<wbr>WANConnectionDevice.1.<wbr>WANPPPConnection.1.Username<br></span></div><div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">if and only if<br></span></div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path"></span><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">InternetGatewayDevice.<wbr>WANDevice.X.<wbr>WANConnectionDevice.1.<wbr>WANPPPConnection.1.Username = "test"<br><br></span></div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">Is there some way to do this? This kind of operation is better than using last index on WANDevice in my case.<br></span></div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">Thank you,<br></span></div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path">Marco<br></span><div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path"><br></span><div><span class="m_7952795853452651659gmail-long-text m_7952795853452651659gmail-param-path"><br></span></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-09-06 8:51 GMT+02:00 Marco Marino <span dir="ltr"><<a href="mailto:marino.mrc@gmail.com" target="_blank">marino.mrc@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Dan, Thank you for your answer. But the problem is the index = 3 (InternetGatewayDevice.WANDevi<wbr>ce.3   !!!) how can I select only last WANDevice ?? Obviously I don't know a priori how many WANDevices are configured on the device.<br></div>Thank you<br><div><br></div></div><div class="m_7952795853452651659HOEnZb"><div class="m_7952795853452651659h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-09-05 19:05 GMT+02:00 Dan Morphis <span dir="ltr"><<a href="mailto:dan@milkcarton.com" target="_blank">dan@milkcarton.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Why only the last PPP connection? Why would you want to have more than one PPP connection?</div><div><br></div><div>Here is how I do it:</div><div><br></div>First tell Genie you only want one item:<div>declare("InternetGatewayDevice<wbr>.WANDevice.3.WANConnectionDevi<wbr>ce.1.<span style="font-size:12.8px">WANPPPConnection</span>.*", {value: Date.now()}, {path: 1}); // path: 1 says only one value<br></div><div><br></div><div>Then you set the values:</div><div><div>declare("InternetGatewayDevice<wbr>.WANDevice.3.WANConnectionDevi<wbr>ce.1.WANPPPConnection.*.Userna<wbr>me", {value: Date.now()}, {value: "someUsername"});</div><div>declare("InternetGatewayDevice<wbr>.WANDevice.3.WANConnectionDevi<wbr>ce.1.WANPPPConnection.*.Passwo<wbr>rd", {value: Date.now()}, {value: "somePassword"});</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_7952795853452651659m_9073304773867829316h5">On Tue, Sep 5, 2017 at 6:12 AM, Marco Marino <span dir="ltr"><<a href="mailto:marino.mrc@gmail.com" target="_blank">marino.mrc@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_7952795853452651659m_9073304773867829316h5"><div dir="ltr"><div><div><div><div><span class="m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-long-text m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-param-path">Hi, I need to set the following parameter:<br>InternetGatewayDevice.WANDevic<wbr>e.3.WANConnectionDevice.1.WANP<wbr>PPConnection.1.Username<br></span></div><span class="m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-long-text m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-param-path">The problem is that I don't know a priori the index of InternetGatewayDevice.WANDevic<wbr>e.X<br></span></div><span class="m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-long-text m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-param-path">Is there a way using a provision script to set *last* index of WANDevice ??<br><br></span></div><span class="m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-long-text m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-param-path">Thank you,<br></span></div><span class="m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-long-text m_7952795853452651659m_9073304773867829316m_2009764845098077046m_8645007323070785789gmail-param-path">Marco<br></span></div>
<br></div></div>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.genieacs.com" target="_blank">Users@lists.genieacs.com</a><br>
<a href="http://lists.genieacs.com/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.genieacs.com/mail<wbr>man/listinfo/users</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.genieacs.com" target="_blank">Users@lists.genieacs.com</a><br>
<a href="http://lists.genieacs.com/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.genieacs.com/mail<wbr>man/listinfo/users</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.genieacs.com">Users@lists.genieacs.com</a><br>
<a href="http://lists.genieacs.com/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.genieacs.com/<wbr>mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>