Accueil › Forums › HAast (High Availability for Asterisk) › Configuration & Optimization › Changing routes & opening ports on node promotion/demotion
Tagged: event handler, haast, ifcfg, network, route
-
AuthorPosts
-
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?
HAAst performs all NIC control using the Linux system API; it does not use network configuration scripts (such as ifcfg-ethX, ifup, ifdown, etc). These 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:
#!/bin/bash
# Delete old default route
ip route del default via 172.31.254.1 2>&1
# Add new default route
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):
#!/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.
-
AuthorPosts
- You must be logged in to reply to this topic.