Figure 3: Conditions that must be met before an alias IP is added
&PingHost: the subroutine for checking the availability
of an IP (see Figure 1).
$ALIAS_IP: the IP Address of the alias.
$ROUTER: the IP Address of the system&'s default router.
$PARTNER: the IP Address of our partner running Alias Defender.
$PRIMARY: a true/false value for which true means the system
is the default system for running the alias IP. Used
to reduce collisions during the adding of the alias IP.
sub CheckAlias{
# Subroutine for checking to see if the alias is alive.
# A return value of "true" means that we should add the alias.
#
# For a return value of true, the following must be meet:
# if we are the primary
# the alias must be down and router must be up.
#
# if we are not the primary
# the alias and partner must be down while the router
# must be up.
#
if (&PingHost("$ALIAS_IP") eq "true"){
return false;
}else{
if (&PingHost("$ROUTER") eq "true"){
if ($PRIMARY eq "true"){
# Alias is down, router is up and we are the primary.
# Do not care if partner is alive. Bring up alias.
return true;
}else{
if (&PingHost("$PARTNER") eq "true"){
&DisplayLogMessage("WARNING!! Could not \
failover. $ALIAS_IP is NOT alive but the primary \
$PARTNER is alive.");
return false;
}else{
# Alias is down, router is up, partner is down
# and we are are the secondary. Bring up alias.
return true;
}
}
}else{
# Router is down. In this situation, a failover is not
# done because of the possibility the switch or network
# is down.
&DisplayLogMessage("ERROR!! Could not bring up $ALIAS_IP \
due to router unavailability. Switch/Network down?");
return false;
}
}
}
|