How to ensure only specific instances exist?

Dan Morphis dan at milkcarton.com
Thu Jun 15 13:41:34 EDT 2017


We are adding the ability for customers to manage port forwarding
(PortMapping). I'm trying to figure out how to ensure that only specific
instances exist in the PortMapping node. For instance customer adds a port
forward for
ExternalPort:3000,InternalPort:3001,PortMappingProtocol:TCP,InternalClient:192.168.1.50.
Creating that instance will be easy enough.

Now, the customer remove that instance, and adds a mapping for
ExternalPort:8080,InternalPort:80,PortMappingProtocol:TCP,InternalClient:192.168.1.51,
ExternalPort:8081,InternalPort:80,PortMappingProtocol:TCP,InternalClient:192.168.1.50.
How can I using provisioning scripts ensure that the first instance is
deleted, and the second instance is created, if the only data I have
available is what the desired state should be?

My first thought was to delete all existing PortMapping entries and then
add back the desired entries. But that seems really inefficient. I could do
something like this to ensure I have the desired number of entries:

declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.PortMapping.*",
null, {path: 2});

But then how would I go about updating the two entries with the desired
values? Something like this?

declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.PortMapping.[ExternalPort:8080,InternalPort:80,PortMappingProtocol:TCP,InternalClient:192.168.1.51]",
{path: 1}, {path: 1});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.PortMapping.[ExternalPort:8081,InternalPort:80,PortMappingProtocol:TCP,InternalClient:192.168.1.50]",
{path: 1}, {path: 1});


--dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20170615/b5858767/attachment.html>


More information about the Users mailing list