Confused about adding objects via declare in provision scripts.
SC SCx
kredaxx at gmail.com
Thu May 9 06:06:02 EDT 2019
Hi,
I am a bit confused how to "declare" objects to be added or removed in
GenieACS provisioning scripts.
Suppose I have a sample settings tree like this that contains 1
WANPPPConnection and 3 WANIPConnections, and I would like to add another
WANIPConnection with WANNAME="test",WANENABLED=true
InternetGatewayDevice.WANDevice.1.WANConnectionDevice
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.WANNAME=wanppp1
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.2.WANENABLED=true
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANIPConnection.1.WANNAME=wanip1
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.2.WANENABLED=true
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANIPConnection.1.WANNAME=wanip2
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANPPPConnection.2.WANENABLED=true
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.4.WANIPConnection.1.WANNAME=wanip3
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.4.WANPPPConnection.2.WANENABLED=true
I can successfully "manually" add a new WANIPConnection like so with an
explicit number (e.g. 5), but since the indexing can be arbitrary in the
settings tree (and can clash) this is not a good idea.
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.5.WANIPConnection.[WANNAME:test,WANENABLED:true]",
{path:1}, {path:1});
So my other attempt was with a wildcard instead to not to rely on an index,
like so:
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANIPConnection.[WANNAME:test,WANENABLED:true]",
{path:1}, {path:1});
However this calls 4 times "AddObject" RPCs, creates 4 WANIPConnections,
but only the last one contains the specified
WANNNAMAE="test",WANENABLED=true.
So after reading around the mailing list and the Wiki I found samples where
one specifies the desired instance count, so I tried something along the
lines of this:
var wanIpCount =
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*",
{value: Date.now()}).size; //get the current count of existing
wanipconnections
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.[]",
null, { path: wanIpCount + 1}); //specify we want one additional instance
to be present
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.5.WANIPConnection.[WANNAME:test,WANENABLED:true]",
{path:1}, {path:1});
Unfortunately this is no good as well, it managed to call 2 times AddObject
and then throws an error of faultCode="cwmp.9002" faultMessage="Internal
error".
What would be the proper way to add a new WANIPconnection instance in this
case?
PS:
Since this is not mentioned anywhere, is a wildcard: "*" equivalent to
empty brackets: "[]" in a path string?
Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20190509/a1db9cbb/attachment.html>
More information about the Users
mailing list