Commit f13453d6 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) cleanups vslb.inc

parent 2d48ceec
......@@ -111,38 +111,6 @@ class SendMonitor extends Monitor {
}
}
function echo_lbaction($action) {
global $config;
// Index actions by name
$actions_a = array();
for ($i=0; isset($config['load_balancer']['lbaction'][$i]); $i++)
$actions_a[$config['load_balancer']['lbaction'][$i]['name']] = $config['load_balancer']['lbaction'][$i];
$ret = "";
$ret .= "{$actions_a[$action]['direction']} {$actions_a[$action]['type']} {$actions_a[$action]['action']}";
switch($actions_a[$action]['action']) {
case 'append':
$ret .= " \"{$actions_a[$action]['options']['value']}\" to \"{$actions_a[$action]['options']['akey']}\"";
break;
case 'change':
$ret .= " \"{$actions_a[$action]['options']['akey']}\" to \"{$actions_a[$action]['options']['value']}\"";
break;
case 'expect':
$ret .= " \"{$actions_a[$action]['options']['value']}\" from \"{$actions_a[$action]['options']['akey']}\"";
break;
case 'filter':
$ret .= " \"{$actions_a[$action]['options']['value']}\" from \"{$actions_a[$action]['options']['akey']}\"";
break;
case 'hash':
$ret .= " \"{$actions_a[$action]['options']['akey']}\"";
break;
case 'log':
$ret .= " \"{$actions_a[$action]['options']['akey']}\"";
break;
}
return $ret;
}
function relayd_configure($kill_first=false) {
global $config, $g;
......@@ -153,10 +121,26 @@ function relayd_configure($kill_first=false) {
require_once("filter.inc");
}
$vs_a = $config['load_balancer']['virtual_server'];
$pool_a = $config['load_balancer']['lbpool'];
$protocol_a = $config['load_balancer']['lbprotocol'];
$setting = $config['load_balancer']['setting'];
if (isset($config['load_balancer']['virtual_server'])) {
$vs_a = $config['load_balancer']['virtual_server'];
} else {
$vs_a = null;
}
if (isset($config['load_balancer']['lbpool'])) {
$pool_a = $config['load_balancer']['lbpool'];
} else {
$pool_a = null;
}
if (isset($config['load_balancer']['lbprotocol'])) {
$protocol_a = $config['load_balancer']['lbprotocol'];
} else {
$protocol_a = null;
}
if (isset($config['load_balancer']['setting'])) {
$setting = $config['load_balancer']['setting'];
} else {
$setting = null;
}
$check_a = array();
......@@ -184,7 +168,7 @@ function relayd_configure($kill_first=false) {
}
$fd = fopen('/var/etc/relayd.conf', 'w');
$conf .= "log updates \n";
$conf = "log updates \n";
/* Global timeout, interval and prefork settings
if not specified by the user:
......@@ -233,21 +217,6 @@ function relayd_configure($kill_first=false) {
}
}
}
// if(is_array($protocol_a)) {
// for ($i = 0; isset($protocol_a[$i]); $i++) {
// $proto = "{$protocol_a[$i]['type']} protocol \"{$protocol_a[$i]['name']}\" {\n";
// if(is_array($protocol_a[$i]['lbaction'])) {
// if($protocol_a[$i]['lbaction'][0] == "") {
// continue;
// }
// for ($a = 0; isset($protocol_a[$i]['lbaction'][$a]); $a++) {
// $proto .= " " . echo_lbaction($protocol_a[$i]['lbaction'][$a]) . "\n";
// }
// }
// $proto .= "}\n";
// $conf .= $proto;
// }
// }
$conf .= "dns protocol \"dnsproto\" {\n";
$conf .= "\t" . "tcp { nodelay, sack, socket buffer 1024, backlog 1000 }\n";
......@@ -529,40 +498,3 @@ function cleanup_lb_mark_anchor($name)
file_put_contents($filename, implode("\n", $cleanup_anchors));
}
/* Cleanup relayd anchors that have been marked for cleanup. */
function cleanup_lb_marked()
{
global $config;
$filename = '/tmp/relayd_anchors_remove';
$cleanup_anchors = array();
/* Nothing to do! */
if (!file_exists($filename)) {
return;
} else {
$cleanup_anchors = explode("\n", file_get_contents($filename));
/* Nothing to do! */
if (empty($cleanup_anchors)) {
return;
}
}
/* Load current names so we can make sure we don't remove an anchor that is still in use. */
$vs_a = $config['load_balancer']['virtual_server'];
$active_vsnames = array();
if (isset($vs_a)) {
foreach ($vs_a as $vs) {
$active_vsnames[] = $vs['name'];
}
}
foreach ($cleanup_anchors as $anchor) {
/* Only cleanup an anchor if it is not still active. */
if (!in_array($anchor, $active_vsnames)) {
cleanup_lb_anchor($anchor);
}
}
@unlink($filename);
}
......@@ -33,6 +33,45 @@ require_once("filter.inc");
require_once("vslb.inc");
require_once("maintable.inc");
/* Cleanup relayd anchors that have been marked for cleanup. */
function cleanup_lb_marked()
{
global $config;
$filename = '/tmp/relayd_anchors_remove';
$cleanup_anchors = array();
/* Nothing to do! */
if (!file_exists($filename)) {
return;
} else {
$cleanup_anchors = explode("\n", file_get_contents($filename));
/* Nothing to do! */
if (empty($cleanup_anchors)) {
return;
}
}
/* Load current names so we can make sure we don't remove an anchor that is still in use. */
$vs_a = $config['load_balancer']['virtual_server'];
$active_vsnames = array();
if (isset($vs_a)) {
foreach ($vs_a as $vs) {
$active_vsnames[] = $vs['name'];
}
}
foreach ($cleanup_anchors as $anchor) {
/* Only cleanup an anchor if it is not still active. */
if (!in_array($anchor, $active_vsnames)) {
cleanup_lb_anchor($anchor);
}
}
@unlink($filename);
}
if (!is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array();
}
......
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