diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2008-04-01 11:10:36 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2008-04-01 11:10:36 -0700 |
commit | cc21d2229111afa079cd138f5d40db85ee9d5742 (patch) | |
tree | 91dd423a55d766ef11c161adb99c75eb400523bc | |
parent | a18b1924a72a7d1f30844b0bc71b60467d61e7b3 (diff) | |
download | vyatta-cluster-cc21d2229111afa079cd138f5d40db85ee9d5742.tar.gz vyatta-cluster-cc21d2229111afa079cd138f5d40db85ee9d5742.zip |
make cluster add/remove watchlink exclude entries
-rw-r--r-- | scripts/VyattaClusterConfig.pm | 33 | ||||
-rwxr-xr-x | scripts/vyatta-update-cluster.pl | 9 |
2 files changed, 39 insertions, 3 deletions
diff --git a/scripts/VyattaClusterConfig.pm b/scripts/VyattaClusterConfig.pm index c6e7991..08c31de 100644 --- a/scripts/VyattaClusterConfig.pm +++ b/scripts/VyattaClusterConfig.pm @@ -15,6 +15,8 @@ my $DEFAULT_MCAST_GROUP = '239.251.252.253'; my $DEFAULT_UDP_PORT = '694'; my $DEFAULT_TTL = '1'; +my $HA_WATCHLINK_ID = 'ha'; + my %fields = ( _interface => undef, _mcast_grp => undef, @@ -336,6 +338,37 @@ EOS return ($str, undef, @init_services); } +sub del_watchlink_exclude { + my $self = shift; + my $cmd = '/opt/vyatta/sbin/vyatta-watchlink-exclude.pl ' + . "--id=$HA_WATCHLINK_ID --action=remove >&/dev/null"; + system($cmd); +} + +sub add_watchlink_exclude { + my $self = shift; + my $bcmd = '/opt/vyatta/sbin/vyatta-watchlink-exclude.pl ' + . "--id=$HA_WATCHLINK_ID --action=add --intf='*'"; + my @groups = keys %{$self->{_groups}}; + my $hashref = $self->{_groups}->{$groups[0]}; + my @ip_addresses = (); + foreach (@{$hashref->{_service}}) { + if (isValidIPSpec($_)) { + my $ip = (/^([^\/]+)\//) ? $1 : $_; + push @ip_addresses, $ip; + } + } + return if (scalar(@ip_addresses) <= 0); + + my $last_ip = pop @ip_addresses; + foreach (@ip_addresses) { + my $cmd = "$bcmd --ipadd=$_"; + system($cmd); + } + my $cmd = "$bcmd --ipadd=$last_ip --signal"; + system($cmd); +} + sub print_str { my ($self) = @_; my $str = "cluster"; diff --git a/scripts/vyatta-update-cluster.pl b/scripts/vyatta-update-cluster.pl index c90dcf8..56545e5 100755 --- a/scripts/vyatta-update-cluster.pl +++ b/scripts/vyatta-update-cluster.pl @@ -14,11 +14,12 @@ if ($config->isEmpty()) { # config is empty => deleted. # shutdown clustering. system("$HA_INIT stop"); + + $config->del_watchlink_exclude(); + exit 0; } -open(OUT, ">>/tmp/cl.log") or exit 1; - my ($authkeys, $haresources, $ha_cf, $err, @init_services); while (1) { ($authkeys, $err) = $config->authkeys(); @@ -62,6 +63,9 @@ if (!chmod(0600, "$HA_DIR/authkeys")) { exit 1; } +$config->del_watchlink_exclude(); +$config->add_watchlink_exclude(); + # stop each service in case it is already started foreach (@init_services) { system("$SERVICE_DIR/$_ stop"); @@ -73,6 +77,5 @@ foreach (@init_services) { system("$HA_INIT stop"); system("$HA_INIT start"); -close OUT; exit 0; |