diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2008-01-21 19:00:21 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2008-01-21 19:00:21 -0800 |
commit | c3f28ce3332dfa5ccc3ac658df876d7cd444eea5 (patch) | |
tree | 119ca2b780798772ab7980f7e01ceae3be93c7f1 /scripts/keepalived/vyatta-keepalived.pl | |
parent | b45bba4286e83f8babcd70eef908f2ea2f8fff3c (diff) | |
download | vyatta-cfg-quagga-c3f28ce3332dfa5ccc3ac658df876d7cd444eea5.tar.gz vyatta-cfg-quagga-c3f28ce3332dfa5ccc3ac658df876d7cd444eea5.zip |
All vrrp to be configured on vif
Diffstat (limited to 'scripts/keepalived/vyatta-keepalived.pl')
-rwxr-xr-x | scripts/keepalived/vyatta-keepalived.pl | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index 7555d183..f024f88a 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -37,18 +37,18 @@ use warnings; my %HoA_sync_groups; sub keepalived_get_values { - my ($intf) = @_; + my ($intf, $path) = @_; my $output = ''; my $config = new VyattaConfig; my $state_transition_script = VyattaKeepalived::get_state_script(); - $config->setLevel("interfaces ethernet $intf vrrp vrrp-group"); + $config->setLevel("$path vrrp vrrp-group"); my @groups = $config->listNodes(); foreach my $group (@groups) { my $vrrp_instance = "vyatta-$intf-$group"; - $config->setLevel("interfaces ethernet $intf vrrp vrrp-group $group"); + $config->setLevel("$path vrrp vrrp-group $group"); my @vips = $config->returnValues("virtual-address"); if (scalar(@vips) == 0) { print "must define a virtual-address for vrrp-group $group\n"; @@ -71,10 +71,11 @@ sub keepalived_get_values { push @{ $HoA_sync_groups{$sync_group} }, $vrrp_instance; } - $config->setLevel("interfaces ethernet $intf vrrp vrrp-group $group authentication"); + $config->setLevel("$path vrrp vrrp-group $group authentication"); my $auth_type = $config->returnValue("type"); my $auth_pass; if (defined $auth_type) { + $auth_type = "PASS" if $auth_type eq "simple"; $auth_type = uc($auth_type); $auth_pass = $config->returnValue("password"); if (! defined $auth_pass) { @@ -138,16 +139,29 @@ sub vrrp_update_config { my $config = new VyattaConfig; - # todo: support vifs $config->setLevel("interfaces ethernet"); my @eths = $config->listNodes(); my $vrrp_instances = 0; foreach my $eth (@eths) { - $config->setLevel("interfaces ethernet $eth"); + my $path = "interfaces ethernet $eth"; + $config->setLevel($path); if ($config->exists("vrrp")) { - $output .= keepalived_get_values($eth); + $output .= keepalived_get_values($eth, $path); $vrrp_instances++; } + if ($config->exists("vif")) { + my $path = "interfaces ethernet $eth vif"; + $config->setLevel($path); + my @vifs = $config->listNodes(); + foreach my $vif (@vifs) { + my $vif_path = "$path $vif"; + $config->setLevel($vif_path); + if ($config->exists("vrrp")) { + $output .= keepalived_get_values("$eth.$vif", $vif_path); + $vrrp_instances++; + } + } + } } if ($vrrp_instances > 0) { @@ -199,7 +213,7 @@ if ($action eq "delete") { exit 1; } my $state_file = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group); - system("rm $state_file"); + system("rm -f $state_file"); VyattaKeepalived::vrrp_log("vrrp delete $vrrp_intf $vrrp_group"); exit 0; } |