diff options
Diffstat (limited to 'scripts/keepalived/vyatta-keepalived.pl')
-rwxr-xr-x | scripts/keepalived/vyatta-keepalived.pl | 55 |
1 files changed, 55 insertions, 0 deletions
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 |