1
Development and Code Review / Plugin Writes IP to Config File - IP Change?
« on: Today at 01:23:04 am »
I've made a load of improvements to a plugin but have hit a blocker. The plugin in question has to write the IP address for a service to listen on, into a config file. I can use the templates structure for the plugins, e.g.
However that gets the IP address out of the config file. If an interface is set to DHCP, or SLAAC (for the ipaddrv6 property) there is no IP address in that field. How do we cope with that in a plugin, is there an event handler for an IP address change that can update config files for running services?
Code: [Select]
{% if helpers.exists('interfaces.'+int+'.ipaddr') %}
{% set interface_ip = helpers.getNodeByTag('interfaces.'+int+'.ipaddr') %}
{% if '.' in interface_ip %}
--- do stuff here ---
{% endif %}
{% endif %}
However that gets the IP address out of the config file. If an interface is set to DHCP, or SLAAC (for the ipaddrv6 property) there is no IP address in that field. How do we cope with that in a plugin, is there an event handler for an IP address change that can update config files for running services?