Commit 951a4ceb authored by Franco Fichtner's avatar Franco Fichtner

interfaces: call stack on get_carp_interface_status() is also tricky

parent 382a3d3b
......@@ -5397,3 +5397,26 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false,
return false;
}
/*
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface)
{
$carp_query = '';
/* XXX: Need to fidn a better way for this! */
list ($interface, $vhid) = explode("_vip", $carpinterface);
$interface = get_real_interface($interface);
exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/grep 'vhid {$vhid}'", $carp_query);
foreach($carp_query as $int) {
if (stristr($int, "MASTER")) {
return gettext("MASTER");
} elseif (stristr($int, "BACKUP")) {
return gettext("BACKUP");
} elseif(stristr($int, "INIT")) {
return gettext("INIT");
}
}
return;
}
......@@ -51,28 +51,6 @@ function is_private_ip($iptocheck)
return $isprivate;
}
/*
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
$carp_query = "";
/* XXX: Need to fidn a better way for this! */
list ($interface, $vhid) = explode("_vip", $carpinterface);
$interface = get_real_interface($interface);
exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/grep 'vhid {$vhid}'", $carp_query);
foreach($carp_query as $int) {
if (stristr($int, "MASTER")) {
return gettext("MASTER");
} elseif (stristr($int, "BACKUP")) {
return gettext("BACKUP");
} elseif(stristr($int, "INIT")) {
return gettext("INIT");
}
}
return;
}
/*
* restore_config_section($section_name, new_contents): restore a configuration section,
* and write the configuration out
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment