What are the common use cases of the “commit()” function inside a provision script? And what is the behavior of an script (and the other concurrent scripts) on a commit() in the middle of other script?
As I know, the preset scripts run as many times as necessary to reach the “stable state” (no more set/get/add operations). And there is a implicit commit() at the end of the script.
But I’m not minding where could I use the commit() function in the middle of the preset script.
A commit is used when you need to force an explicit flush of the data to the CPE. A fantastic example is the CPE I’m working with a client on will not allow you to set all the DHCP params in one operation. If you try and set the DHCP pool min/max address before the CPE has applied the subnet changes, it throws a fault. So I have an explicit commit in the middle of the script after setting the subnet mask before the Min/Max address params are sent to the CPE.
declare('Device.DHCPv4.Server.Pool.1.DNSServers', { value: 1 }, { value: '192.168.2.1' });
declare('Device.DHCPv4.Server.Pool.1.X_SomeVendorSpecificParam', { value: 1 }, { value: '192.168.2.1' });
declare('Device.IP.Interface.1.IPv4Address.1.SubnetMask', { value: 1 }, { value: '255.255.255.0' });
// This CPE is lame and will not let you change the Min/Max addr until you've committed these changes...
commit();
declare('Device.DHCPv4.Server.Pool.1.MinAddress', { value: 1 }, { value:'192.168.2.100' });
declare('Device.DHCPv4.Server.Pool.1.MaxAddress', { value: 1 }, { value: '192.168.2.249' });