Changing routes & opening ports on node promotion/demotion

Configuring synchronization, sensors, and optimizations
Post Reply
voipsecured
Posts: 1
Joined: Fri Apr 20, 2018 11:41 am

Changing routes & opening ports on node promotion/demotion

Post by voipsecured » Fri Apr 20, 2018 11:53 am

I am running a HAast test cluster (which from what I can see functions correctly on fail over), bringing up and taking down the voipnic on a shared IP address configuration. My issue is that system network configuration scripts don't run (ifup-local , ifdown-local which I have tested manually with ifup and ifdown commands), which leads me to believe that the eth ports are controlled by some other means. I need to run these scripts to care of routing both inside a VE and externally on the Host server when the ports are stopped and started. How can I do so?
User avatar
Telium Support
Posts: 173
Joined: Sun Nov 27, 2016 3:27 pm

re: Changing routes & opening ports on node promotion/demotion

Post by Telium Support » Fri Apr 20, 2018 1:02 pm

HAAst performs all NIC control using the Linux system API; it does not use network configuration scripts (such as ifcfg-ethX, ifup, ifdown, etc). The scripts you are referring to are Linux distribution specific, and are ignored by HAAst. All configuration of a shared VoIP NIC is accomplished in the [voipnic] stanza of the haast.conf file.

In order to perform other actions on the PBX at the time of promotion/demotion (i.e. becoming the active or becoming the standby node), you need to use the HAAst event handler system. For example, if you wanted to change the default route of the PBX when it is promoted, you could create a file called /usr/local/haast/events/asterisk.start.pre which contains:

Code: Select all

#!/bin/bash
ip route del default via 172.31.254.1 2>&1
ip route add default via 172.31.253.1 2>&1
And if you wanted to switch the default route back when the PBX is demoted, you could create a file called /usr/local/haast/events/asterisk.stop.post which reverses these statements. You can place any code you like in the event handler, but it should complete quickly (ideally < 5 seconds), so if you need to start long-running executables from the event handler be sure to fork them in the event handler code. For example, if you wanted to deleted all temporary files (which can run for several minutes) when the node becomes standby, your event handler file would contain (notice the ampersand which forks the command):

Code: Select all

#!/bin/bash
rm -rf /tmp &
If you want to open/close ports in a firewall, control virtual machine functions, etc. then the event handler system is the right way to accomplish this. Just be sure to fork each command, or fork a single bash script which serializes those commands if any of these commands can run for an extended period of time.

Please note that event handlers are only available in the Commercial Unlimited edition of HAAst. See the EDITIONS tab of the HAAst web page to see what functionality is available in each HAAst edition.
Post Reply