From a64dfc6524f0d59f4c7c0df4d2d6d30679791909 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Sun, 8 Mar 2009 17:47:40 -0700 Subject: Fix 4183: No auto completion for group number when running 'clear vrrp master interface group ' --- scripts/keepalived/vyatta-keepalived.pl | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'scripts/keepalived') diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index fa82b023..7d5e6ed7 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -383,6 +383,45 @@ sub keepalived_write_file { close $fh; } +sub list_vrrp_intf { + my $config = new Vyatta::Config; + my @intfs = (); + + $config->setLevel("interfaces ethernet"); + my @eths = $config->listOrigNodes(); + foreach my $eth (@eths) { + my $path = "interfaces ethernet $eth"; + $config->setLevel($path); + push @intfs, $eth if $config->existsOrig("vrrp"); + if ($config->existsOrig("vif")) { + my $path = "interfaces ethernet $eth vif"; + $config->setLevel($path); + my @vifs = $config->listOrigNodes(); + foreach my $vif (@vifs) { + my $vif_intf = $eth . "." . $vif; + my $vif_path = "$path $vif"; + $config->setLevel($vif_path); + push @intfs, $vif_intf if $config->existsOrig("vrrp"); + } + } + } + return @intfs; +} + +sub list_vrrp_group { + my ($name) = @_; + + my $config = new Vyatta::Config; + my $path = "interfaces ethernet $name"; + if ($name =~ /(eth\d+)\.(\d+)/) { + $path = "interfaces ethernet $1 vif $2"; + } + $path .= " vrrp vrrp-group"; + $config->setLevel($path); + my @groups = $config->listOrigNodes(); + return @groups; +} + # # main @@ -450,6 +489,22 @@ if ($action eq "check-vip") { exit 0; } +if ($action eq "list-vrrp-intf") { + my @intfs = list_vrrp_intf(); + print join(' ', @intfs); + exit 0; +} + +if ($action eq "list-vrrp-group") { + if (! defined $vrrp_intf) { + print "must include interface\n"; + exit 1; + } + my @groups = list_vrrp_group($vrrp_intf); + print join(' ', @groups); + exit 0; +} + exit 0; # end of file -- cgit v1.2.3