summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2008-01-21 19:00:21 -0800
committerStig Thormodsrud <stig@vyatta.com>2008-01-21 19:00:21 -0800
commitc3f28ce3332dfa5ccc3ac658df876d7cd444eea5 (patch)
tree119ca2b780798772ab7980f7e01ceae3be93c7f1 /scripts
parentb45bba4286e83f8babcd70eef908f2ea2f8fff3c (diff)
downloadvyatta-cfg-system-c3f28ce3332dfa5ccc3ac658df876d7cd444eea5.tar.gz
vyatta-cfg-system-c3f28ce3332dfa5ccc3ac658df876d7cd444eea5.zip
All vrrp to be configured on vif
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/keepalived/VyattaKeepalived.pm38
-rwxr-xr-xscripts/keepalived/vyatta-keepalived.pl30
-rwxr-xr-xscripts/keepalived/vyatta-show-vrrp.pl2
3 files changed, 41 insertions, 29 deletions
diff --git a/scripts/keepalived/VyattaKeepalived.pm b/scripts/keepalived/VyattaKeepalived.pm
index ae7a831e..70665638 100755
--- a/scripts/keepalived/VyattaKeepalived.pm
+++ b/scripts/keepalived/VyattaKeepalived.pm
@@ -64,7 +64,8 @@ sub is_running {
sub start_daemon {
my ($conf) = @_;
- my $cmd = "$daemon --vrrp --log-facility 7 --log-detail --dump-conf --use-file $conf";
+ my $cmd = "$daemon --vrrp --log-facility 7 --log-detail --dump-conf";
+ $cmd .= " --use-file $conf";
system($cmd);
vrrp_log("start_daemon");
}
@@ -123,34 +124,32 @@ sub get_state_files {
if ($group eq "all") {
open($LS,"ls $state_dir |grep '^vrrpd_$intf.*\.state\$' | sort |");
} else {
- open($LS,"ls $state_dir |grep '^vrrpd_$intf.\_$group\.state\$' | sort |");
+ my $intf_group = $intf . "_" . $group . ".state";
+ open($LS,
+ "ls $state_dir |grep '^vrrpd_$intf_group\$' | sort |");
}
@state_files = <$LS>;
close($LS);
foreach my $i (0 .. $#state_files) {
$state_files[$i] = "$state_dir/$state_files[$i]";
}
- chomp @state_files;
+ chomp @state_files;
return @state_files;
}
-sub get_vips_per_intf {
- my ($intf) = @_;
-
- my $config = new VyattaConfig;
- my @groups = ();
-
- $config->setLevel("interfaces ethernet $intf vrrp vrrp-group");
- @groups = $config->listOrigNodes();
- return scalar(@groups);
-}
-
sub vrrp_get_config {
my ($intf, $group) = @_;
+ my $path;
my $config = new VyattaConfig;
+
+ if ($intf =~ m/(eth\d+)\.(\d+)/) {
+ $path = "interfaces ethernet $1 vif $2";
+ } else {
+ $path = "interfaces ethernet $intf";
+ }
- $config->setLevel("interfaces ethernet $intf");
+ $config->setLevel($path);
my $primary_addr = $config->returnOrigValue("address");
if (!defined $primary_addr) {
$primary_addr = "0.0.0.0";
@@ -160,7 +159,7 @@ sub vrrp_get_config {
$primary_addr = $1;
}
- $config->setLevel("interfaces ethernet $intf vrrp vrrp-group $group");
+ $config->setLevel("$path vrrp vrrp-group $group");
my @vips = $config->returnOrigValues("virtual-address");
my $priority = $config->returnOrigValue("priority");
if (!defined $priority) {
@@ -174,13 +173,12 @@ sub vrrp_get_config {
if (!defined $advert_int) {
$advert_int = 1;
}
- $config->setLevel("interfaces ethernet $intf vrrp vrrp-group $group authentication");
+ $config->setLevel("$path vrrp vrrp-group $group authentication");
my $auth_type = $config->returnOrigValue("type");
if (!defined $auth_type) {
$auth_type = "none";
- } else {
- $auth_type = uc($auth_type);
- }
+ }
+
return ($primary_addr, $priority, $preempt, $advert_int, $auth_type, @vips);
}
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;
}
diff --git a/scripts/keepalived/vyatta-show-vrrp.pl b/scripts/keepalived/vyatta-show-vrrp.pl
index 9228eeeb..93c1ecd2 100755
--- a/scripts/keepalived/vyatta-show-vrrp.pl
+++ b/scripts/keepalived/vyatta-show-vrrp.pl
@@ -149,7 +149,7 @@ sub vrrp_show {
#
my $intf = "eth";
my $group = "all";
-if ($#ARGV == 0) {
+if ($#ARGV >= 0) {
$intf = $ARGV[0];
}
if ($#ARGV == 1) {