From f72bec9dff2b62e9d3704676ec3a12cf1c85a09d Mon Sep 17 00:00:00 2001 From: Mohit Mehta Date: Fri, 11 Jun 2010 15:18:31 -0700 Subject: add function to get all configured sync-groups --- lib/Vyatta/Keepalived.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Vyatta/Keepalived.pm b/lib/Vyatta/Keepalived.pm index 6689f4a..dc7e71b 100755 --- a/lib/Vyatta/Keepalived.pm +++ b/lib/Vyatta/Keepalived.pm @@ -29,7 +29,7 @@ our @EXPORT = qw(get_conf_file get_state_script get_state_file vrrp_log vrrp_get_init_state get_changes_file start_daemon restart_daemon stop_daemon vrrp_get_config list_vrrp_intf list_vrrp_group - list_vrrp_sync_group); + list_vrrp_sync_group list_all_vrrp_sync_grps); use base qw(Exporter); use Vyatta::Config; @@ -371,5 +371,23 @@ sub list_vrrp_sync_group { return $sync_group; } +sub list_all_vrrp_sync_grps { + my @sync_grps = (); + my @vrrp_intfs = list_vrrp_intf(); + foreach my $vrrp_intf (@vrrp_intfs) { + my @vrrp_groups = list_vrrp_group($vrrp_intf); + foreach my $vrrp_group (@vrrp_groups) { + my $sync_grp = list_vrrp_sync_group($vrrp_intf, $vrrp_group); + if (defined $sync_grp) { + # add to sync_grps if not already there + if (scalar( grep( /^$sync_grp$/, @sync_grps ) ) == 0) { + push (@sync_grps, $sync_grp); + } + } + } + } + return @sync_grps; +} + 1; #end of file -- cgit v1.2.3