diff options
-rw-r--r-- | debian/vyatta-wanloadbalance/DEBIAN/control | 12 | ||||
-rw-r--r-- | debian/vyatta-wanloadbalance/DEBIAN/md5sums | 25 | ||||
-rwxr-xr-x | debian/vyatta-wanloadbalance/DEBIAN/postinst | 6 | ||||
-rwxr-xr-x | debian/vyatta-wanloadbalance/DEBIAN/postrm | 6 | ||||
-rw-r--r-- | scripts/vyatta-wanloadbalance.pl | 180 | ||||
-rw-r--r-- | templates/load-balancing/wan/node.def | 4 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/protocol/node.def | 3 |
7 files changed, 187 insertions, 49 deletions
diff --git a/debian/vyatta-wanloadbalance/DEBIAN/control b/debian/vyatta-wanloadbalance/DEBIAN/control deleted file mode 100644 index 5bc4bff..0000000 --- a/debian/vyatta-wanloadbalance/DEBIAN/control +++ /dev/null @@ -1,12 +0,0 @@ -Package: vyatta-wanloadbalance -Version: 0.1 -Architecture: i386 -Maintainer: Michael Larson <mike@vyatta.com> -Installed-Size: 356 -Depends: bash (>= 3.1), sed (>= 4.1.5), perl (>= 5.8.8), procps (>= 1:3.2.7-3), vyatta-quagga, coreutils (>= 5.97-5.3), vyatta-config-migrate -Suggests: util-linux (>= 2.13-5), net-tools, ethtool, ncurses-bin (>= 5.5-5), ntpdate -Section: contrib/net -Priority: extra -Description: Vyatta configuration system - This package has the Vyatta wan load balance project. It includes support for - the vyatta cli for configuration. diff --git a/debian/vyatta-wanloadbalance/DEBIAN/md5sums b/debian/vyatta-wanloadbalance/DEBIAN/md5sums deleted file mode 100644 index 1d193f4..0000000 --- a/debian/vyatta-wanloadbalance/DEBIAN/md5sums +++ /dev/null @@ -1,25 +0,0 @@ -5e309010d92880d15672129133e5354d usr/share/doc/vyatta-wanloadbalance/README -3c92803d5c1d5b506fbf10fea5ef154d usr/share/doc/vyatta-wanloadbalance/NEWS.gz -9dc8bbe58ac1899b2d26b6a6afbc6b9b usr/share/doc/vyatta-wanloadbalance/changelog.Debian.gz -d5b6fc9862693420e136901e26649011 usr/share/doc/vyatta-wanloadbalance/changelog.gz -cb1ea7b0e74c21a5e12a4f9ed38c7994 usr/share/doc/vyatta-wanloadbalance/copyright -e9e04ef2861fcfc07f03f018ec5d3305 usr/share/lintian/overrides/vyatta-wanloadbalance -f3923aa07256f6ed0eef752b0ce213ea usr/share/linda/overrides/vyatta-wanloadbalance -30c7f2d4054fbd369083fbcd99d4182e opt/vyatta/sbin/wlb.init -091d6831595890cadf16081dfb63672a opt/vyatta/sbin/wan_lb -2450cefdc74a64d549865fafc8dd6eb1 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/interface-health/node.tag/ping/node.def -6c57c9dc462b72e3fdb6ea6b9af4e3a4 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/interface-health/node.tag/resp-time/node.def -c9192540790172935abf0ebefc1c1b62 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/interface-health/node.tag/success-count/node.def -dd070159fb4c42f7dfbce15b7cd1547d opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/interface-health/node.tag/failure-count/node.def -199f9c630830d40322645529ae98da1a opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/interface-health/node.def -f5d50e46c5ab188d91d535532954f638 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/interface/node.tag/weight/node.def -199f9c630830d40322645529ae98da1a opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/interface/node.def -80208663477f6686dfd30031540cac60 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/destination/port-name/node.def -e7736c8eb9de7a1a8b47202bf98b2670 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/destination/address/node.def -5ff5fb1692d5253273bc9f1a42f0603e opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/destination/network/node.def -2b8a4d139de92e9e8535cde4dc44d237 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/destination/port-number/node.def -e76fd6faa7ac120f9e359597aa6d6ede opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/source/port-name/node.def -e7736c8eb9de7a1a8b47202bf98b2670 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/source/address/node.def -4d6f1065b1751e4a0a5dfd205122ea09 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/source/network/node.def -16c5d3b87bd093a0e599ba3376520e5a opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.tag/source/port-number/node.def -05a1b30754b3bbdceb84b6dfeae61146 opt/vyatta/share/vyatta-cfg/templates/load-balancing/wan/rule/node.def diff --git a/debian/vyatta-wanloadbalance/DEBIAN/postinst b/debian/vyatta-wanloadbalance/DEBIAN/postinst deleted file mode 100755 index c1f08d6..0000000 --- a/debian/vyatta-wanloadbalance/DEBIAN/postinst +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -prefix=/opt/vyatta -sysconfdir=${prefix}/etc - -#nothing diff --git a/debian/vyatta-wanloadbalance/DEBIAN/postrm b/debian/vyatta-wanloadbalance/DEBIAN/postrm deleted file mode 100755 index 262b9fe..0000000 --- a/debian/vyatta-wanloadbalance/DEBIAN/postrm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -if [ "$1" = "purge" ]; then - update-rc.d vyatta-ofr remove >/dev/null || exit $? -fi - diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl new file mode 100644 index 0000000..c65c1f0 --- /dev/null +++ b/scripts/vyatta-wanloadbalance.pl @@ -0,0 +1,180 @@ +#!/usr/bin/perl -w +# +# Module: vyatta-wanloadbalance.pl +# +# **** License **** +# Version: VPL 1.0 +# +# The contents of this file are subject to the Vyatta Public License +# Version 1.0 ("License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.vyatta.com/vpl +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# This code was originally developed by Vyatta, Inc. +# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. +# All Rights Reserved. +# +# Author: Michael Larson +# Date: January 2008 +# Description: Writes exclusion list for linkstatus +# +# **** End License **** +# +use lib "/opt/vyatta/share/perl5/"; +use VyattaConfig; +use VyattaMisc; + +use warnings; +use strict; +use POSIX; +use File::Copy; + +sub write_health { +#open conf + my $config = new VyattaConfig; + + $config->setLevel("load-balancing wan interface-health"); + my @eths = $config->listNodes(); + + print FILE_LCK "health {\n"; + + foreach my $ethNode (@eths) { + + print FILE_LCK "\tinterface " . $ethNode . " {\n"; + + my $option = $config->returnValue("$ethNode failure-count"); + if (defined $option) { + print FILE_LCK "\t\tfailure-ct " . $option . "\n"; + } + + $option = $config->returnValue("$ethNode ping"); + if (defined $option) { + print FILE_LCK "\t\ttarget " . $option . "\n"; + } + + $option = $config->returnValue("$ethNode resp-time"); + if (defined $option) { + print FILE_LCK "\t\tping-resp " . $option . "\n"; + } + + $option = $config->returnValue("$ethNode success-count"); + if (defined $option) { + print FILE_LCK "\t\tsuccess-ct " . $option . "\n"; + } + print FILE_LCK "\t}\n"; + } + print FILE_LCK "}\n\n"; +} + +sub write_rules { + my $config = new VyattaConfig; + + $config->setLevel("load-balancing wan rule"); + my @rules = $config->listNodes(); + + #destination + foreach my $rule (@rules) { + print FILE_LCK "rule " . $rule . " {\n"; + + my $option = $config->returnValue("$rule protocol"); + if (defined $option) { + print FILE_LCK "\tprotocol " . $option . "\n" + } + + #destination + print FILE_LCK "\tdestination {\n"; + $option = $config->returnValue("$rule destination address"); + if (defined $option) { + print FILE_LCK "\t\taddress " . $option . "\n"; + } + + $option = $config->returnValue("$rule destination network"); + if (defined $option) { + print FILE_LCK "\t\tnetwork " . $option . "\n"; + } + + $config->setLevel("load-balancing wan rule $rule destination port-number"); + my @dport_nums = $config->listNodes(); + foreach my $dport_num (@dport_nums) { + print FILE_LCK "\t\tport-number " . $dport_num . "\n"; + } + + $config->setLevel("load-balancing wan rule $rule destination port-name"); + my @dport_names = $config->listNodes(); + foreach my $dport_name (@dport_names) { + print FILE_LCK "\t\tport-number " . $dport_name . "\n"; + } + print FILE_LCK "\t}\n"; + + #source + print FILE_LCK "\tsource {\n"; + $option = $config->returnValue("$rule source address"); + if (defined $option) { + print FILE_LCK "\t\taddress " . $option . "\n"; + } + + $option = $config->returnValue("$rule source network"); + if (defined $option) { + print FILE_LCK "\t\tnetwork " . $option . "\n"; + } + + $config->setLevel("load-balancing wan rule $rule source port-number"); + my @sport_nums = $config->listNodes(); + foreach my $sport_num (@sport_nums) { + print FILE_LCK "\t\tport-number " . $sport_num . "\n"; + } + + $config->setLevel("load-balancing wan rule $rule source port-name"); + my @sport_names = $config->listNodes(); + foreach my $sport_name (@sport_names) { + print FILE_LCK "\t\tport-number " . $sport_name . "\n"; + } + print FILE_LCK "\t}\n"; + + #interface + $config->setLevel("load-balancing wan rule $rule interface"); + my @eths = $config->listNodes(); + + foreach my $ethNode (@eths) { + print FILE_LCK "\tinterface " . $ethNode . " {\n"; + + $option = $config->returnValue("$ethNode weight"); + if (defined $option) { + print FILE_LCK "\t\tweight " . $option . "\n"; + } + print FILE_LCK "\t}\n"; + } + print FILE_LCK "}\n"; + } +} + + + +####main +my $conf_file = '/var/load-balance/wlb.conf'; +my $conf_lck_file = '/var/load-balance/wlb.conf.lck'; + +#open file +open FILE, "<$conf_file"; +open FILE_LCK, "+>$conf_lck_file"; + +write_health(); + +write_rules(); + +close FILE; +close FILE_LCK; + +copy ($conf_lck_file,$conf_file); +unlink($conf_lck_file); + + +#finally kick the process +#system "/etc/init.d/vyatta-wanloadbalance restart"; + +exit 0; diff --git a/templates/load-balancing/wan/node.def b/templates/load-balancing/wan/node.def new file mode 100644 index 0000000..f52fa29 --- /dev/null +++ b/templates/load-balancing/wan/node.def @@ -0,0 +1,4 @@ +help: "wan load-balance configuration" +commit: exec "\\${vyatta_sbindir}/vyatta-wanloadbalance.pl" + + diff --git a/templates/load-balancing/wan/rule/node.tag/protocol/node.def b/templates/load-balancing/wan/rule/node.tag/protocol/node.def new file mode 100644 index 0000000..4275317 --- /dev/null +++ b/templates/load-balancing/wan/rule/node.tag/protocol/node.def @@ -0,0 +1,3 @@ +type: txt +help: "protocol" + |