diff options
author | jim-p <jimp@pfsense.org> | 2010-08-10 16:17:48 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2010-08-10 16:21:32 -0400 |
commit | e0c27075f36858e62a5d5445216a3bac3f6ebfde (patch) | |
tree | 26dfc1fa7f88305eb56aca9cc0fb4295796a6c35 /usr | |
parent | a9d5bf0cab6016341655999001d3c672a6a4970c (diff) | |
download | pfsense-e0c27075f36858e62a5d5445216a3bac3f6ebfde.zip pfsense-e0c27075f36858e62a5d5445216a3bac3f6ebfde.tar.gz |
Add the ability to select a mode for LB pool members, load balance (default) or manual failover. If manual failover is selected, only allow one server to be chosen as active.
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/javascript/load_balancer_pool_edit/pool.js | 38 | ||||
-rwxr-xr-x | usr/local/www/load_balancer_pool.php | 5 | ||||
-rwxr-xr-x | usr/local/www/load_balancer_pool_edit.php | 19 |
3 files changed, 56 insertions, 6 deletions
diff --git a/usr/local/www/javascript/load_balancer_pool_edit/pool.js b/usr/local/www/javascript/load_balancer_pool_edit/pool.js index ab6303d..fd626e5 100755 --- a/usr/local/www/javascript/load_balancer_pool_edit/pool.js +++ b/usr/local/www/javascript/load_balancer_pool_edit/pool.js @@ -110,6 +110,44 @@ function moveOptions(theSelFrom, theSelTo) } } +function checkPoolControls() { + var active = document.iform.serversSelect; + var inactive = document.iform.serversDisabledSelect; + if ($("mode").value == "failover") { + if ($("serversSelect").length > 0) { + $("moveToEnabled").disabled=1; + } else { + $("moveToEnabled").disabled=0; + } + } else { + $("moveToEnabled").disabled=0; + } +} + +function enforceFailover() { + if ($("mode").value != "failover") { + return; + } + var active = document.iform.serversSelect; + var inactive = document.iform.serversDisabledSelect; + var count = 0; + var moveText = new Array(); + var moveVals = new Array(); + var i; + if (active.length > 1) { + // Move all but one entry to the disabled list + for (i=active.length-1; i>0; i--) { + moveText[count] = active.options[i].text; + moveVals[count] = active.options[i].value; + deleteOption(active, i); + count++; + } + for (i=count-1; i>=0; i--) { + addOption(inactive, moveText[i], moveVals[i]); + } + } +} + // functions up() and down() modified from http://www.babailiica.com/js/sorter/ function up(obj) { diff --git a/usr/local/www/load_balancer_pool.php b/usr/local/www/load_balancer_pool.php index 48dccd6..cd6e2a6 100755 --- a/usr/local/www/load_balancer_pool.php +++ b/usr/local/www/load_balancer_pool.php @@ -129,10 +129,11 @@ include("head.inc"); $t->edit_uri('load_balancer_pool_edit.php'); $t->my_uri('load_balancer_pool.php'); $t->add_column(gettext('Name'),'name',10); + $t->add_column(gettext('Mode'),'mode',10); $t->add_column(gettext('Servers'),'servers',15); $t->add_column(gettext('Port'),'port',10); - $t->add_column(gettext('Monitor'),'monitor',15); - $t->add_column(gettext('Description'),'desc',30); + $t->add_column(gettext('Monitor'),'monitor',10); + $t->add_column(gettext('Description'),'desc',25); $t->add_button('edit'); $t->add_button('dup'); $t->add_button('del'); diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php index 748580f..e8529ac 100755 --- a/usr/local/www/load_balancer_pool_edit.php +++ b/usr/local/www/load_balancer_pool_edit.php @@ -53,6 +53,7 @@ else if (isset($id) && $a_pool[$id]) { $pconfig['name'] = $a_pool[$id]['name']; + $pconfig['mode'] = $a_pool[$id]['mode']; $pconfig['desc'] = $a_pool[$id]['desc']; $pconfig['port'] = $a_pool[$id]['port']; $pconfig['servers'] = &$a_pool[$id]['servers']; @@ -70,8 +71,8 @@ if ($_POST) { $pconfig = $_POST; /* input validation */ - $reqdfields = explode(" ", "name port monitor servers"); - $reqdfieldsn = array(gettext("Name"),gettext("Port"),gettext("Monitor"),gettext("Server List")); + $reqdfields = explode(" ", "name mode port monitor servers"); + $reqdfieldsn = array(gettext("Name"),gettext("Mode"),gettext("Port"),gettext("Monitor"),gettext("Server List")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); @@ -110,6 +111,7 @@ if ($_POST) { $changedesc .= sprintf(gettext(" modified '%s' pool:"), $poolent['name']); update_if_changed("name", $poolent['name'], $_POST['name']); + update_if_changed("mode", $poolent['mode'], $_POST['mode']); update_if_changed("description", $poolent['desc'], $_POST['desc']); update_if_changed("port", $poolent['port'], $_POST['port']); update_if_changed("servers", $poolent['servers'], $_POST['servers']); @@ -171,6 +173,15 @@ function clearcombo(){ </td> </tr> <tr align="left"> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Mode"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <select id="mode" name="mode" onChange="enforceFailover(); checkPoolControls();"> + <option value="loadbalance" <?if(!isset($pconfig['mode']) || ($pconfig['mode'] == "loadbalance")) echo "value=\"{$pconfig['name']}\"";?>>Load Balance</option> + <option value="failover" <?if($pconfig['mode'] == "failover") echo "value=\"{$pconfig['name']}\"";?>>Manual Failover</option> + </select> + </td> + </tr> + <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> <input name="desc" type="text" <?if(isset($pconfig['desc'])) echo "value=\"{$pconfig['desc']}\"";?>size="64"> @@ -249,8 +260,8 @@ function clearcombo(){ </td> <td valign="middle"> - <input class="formbtn" type="button" name="moveToEnabled" value=">" onclick="moveOptions(document.iform.serversDisabledSelect, document.iform.serversSelect);" /><br/> - <input class="formbtn" type="button" name="moveToDisabled" value="<" onclick="moveOptions(document.iform.serversSelect, document.iform.serversDisabledSelect);" /> + <input class="formbtn" type="button" id="moveToEnabled" name="moveToEnabled" value=">" onclick="moveOptions(document.iform.serversDisabledSelect, document.iform.serversSelect); checkPoolControls();" /><br/> + <input class="formbtn" type="button" id="moveToDisabled" name="moveToDisabled" value="<" onclick="moveOptions(document.iform.serversSelect, document.iform.serversDisabledSelect); checkPoolControls();" /> </td> <td> |