summaryrefslogtreecommitdiff
path: root/scripts/keepalived/vyatta-keepalived.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-21 08:21:53 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-21 08:21:53 -0800
commit5021e2073b50f3f2022d19c07870b11604548689 (patch)
tree9860b66c0b508d3f7f0a80954dbd18a378f99418 /scripts/keepalived/vyatta-keepalived.pl
parent081b37958049ed703dce5f4c7a9c39bcbf3f4a4a (diff)
downloadvyatta-cfg-system-5021e2073b50f3f2022d19c07870b11604548689.tar.gz
vyatta-cfg-system-5021e2073b50f3f2022d19c07870b11604548689.zip
Rename VyattaKeepalived to Vyatta::Keepalived
Use directory hierarchy in perl.
Diffstat (limited to 'scripts/keepalived/vyatta-keepalived.pl')
-rwxr-xr-xscripts/keepalived/vyatta-keepalived.pl42
1 files changed, 21 insertions, 21 deletions
diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl
index c41fa7e2..a59f6832 100755
--- a/scripts/keepalived/vyatta-keepalived.pl
+++ b/scripts/keepalived/vyatta-keepalived.pl
@@ -25,14 +25,14 @@
use lib "/opt/vyatta/share/perl5/";
use VyattaConfig;
-use VyattaKeepalived;
+use Vyatta::Keepalived;
use Getopt::Long;
use strict;
use warnings;
my $changes_file = '/var/log/vrrpd/changes';
-my $conf_file = VyattaKeepalived::get_conf_file();
+my $conf_file = get_conf_file();
my %HoA_sync_groups;
@@ -43,7 +43,7 @@ sub keepalived_get_values {
my $output = '';
my $config = new VyattaConfig;
- my $state_transition_script = VyattaKeepalived::get_state_script();
+ my $state_transition_script = get_state_script();
$config->setLevel("$path vrrp vrrp-group");
my @groups = $config->listNodes();
@@ -51,8 +51,8 @@ sub keepalived_get_values {
my $vrrp_instance = "vyatta-$intf-$group";
$config->setLevel("$path vrrp vrrp-group $group");
if ($config->exists("disable")) {
- VyattaKeepalived::vrrp_log("$vrrp_instance disabled - skipping");
- my $state_file = VyattaKeepalived::get_state_file($intf, $group);
+ vrrp_log("$vrrp_instance disabled - skipping");
+ my $state_file = get_state_file($intf, $group);
system("rm -f $state_file");
next;
}
@@ -116,7 +116,7 @@ sub keepalived_get_values {
$output .= "vrrp_instance $vrrp_instance \{\n";
my $init_state;
- $init_state = VyattaKeepalived::vrrp_get_init_state($intf, $group,
+ $init_state = vrrp_get_init_state($intf, $group,
$vips[0], $preempt);
$output .= "\tstate $init_state\n";
$output .= "\tinterface $intf\n";
@@ -179,7 +179,7 @@ sub vrrp_save_changes {
my @list = @_;
my $num_changes = scalar(@list);
- VyattaKeepalived::vrrp_log("saving changes file $num_changes");
+ vrrp_log("saving changes file $num_changes");
open(my $FILE, ">", $changes_file) or die "Error: write $!";
print $FILE join("\n", @list), "\n";
close($FILE);
@@ -201,7 +201,7 @@ sub vrrp_find_changes {
my ($vrrp, $vrrp_status) = each(%vrrp_status_hash);
if ($vrrp_status ne "static") {
push @list, $eth;
- VyattaKeepalived::vrrp_log("$vrrp_status found $eth");
+ vrrp_log("$vrrp_status found $eth");
}
}
if ($config->exists("vif")) {
@@ -217,7 +217,7 @@ sub vrrp_find_changes {
my ($vrrp, $vrrp_status) = each(%vrrp_status_hash);
if ($vrrp_status ne "static") {
push @list, "$eth.$vif";
- VyattaKeepalived::vrrp_log("$vrrp_status found $eth.$vif");
+ vrrp_log("$vrrp_status found $eth.$vif");
}
}
}
@@ -234,7 +234,7 @@ sub vrrp_find_changes {
$config->setLevel($path);
if ($config->isDeleted("vrrp")) {
push @list, $eth;
- VyattaKeepalived::vrrp_log("Delete found $eth");
+ vrrp_log("Delete found $eth");
}
$config->setLevel("$path vif");
my @vifs = $config->listOrigNodes();
@@ -244,13 +244,13 @@ sub vrrp_find_changes {
$config->setLevel($vif_path);
if ($config->isDeleted("vrrp")) {
push @list, "$eth.$vif";
- VyattaKeepalived::vrrp_log("Delete found $eth.$vif");
+ vrrp_log("Delete found $eth.$vif");
}
}
}
my $num = scalar(@list);
- VyattaKeepalived::vrrp_log("Start transation: $num changes");
+ vrrp_log("Start transation: $num changes");
if ($num) {
vrrp_save_changes(@list);
}
@@ -271,7 +271,7 @@ sub remove_from_changes {
my @new_lines = ();
foreach my $line (@lines) {
if ($line =~ /$intf$/) {
- VyattaKeepalived::vrrp_log("remove_from_changes [$line]");
+ vrrp_log("remove_from_changes [$line]");
} else {
push @new_lines, $line;
}
@@ -316,7 +316,7 @@ sub vrrp_update_config {
#
my $vif_intf = $eth . "." . $vif;
if (!(-d "/sys/class/net/$vif_intf")) {
- VyattaKeepalived::vrrp_log("skipping $vif_intf");
+ vrrp_log("skipping $vif_intf");
next;
}
my $vif_path = "$path $vif";
@@ -363,24 +363,24 @@ if (! defined $action) {
}
if ($action eq "update") {
- VyattaKeepalived::vrrp_log("vrrp update $vrrp_intf");
+ vrrp_log("vrrp update $vrrp_intf");
if ( ! -e $changes_file) {
my $num_changes = vrrp_find_changes();
if ($num_changes == 0) {
#
# Shouldn't happen, but ...
#
- VyattaKeepalived::vrrp_log("unexpected 0 changes");
+ vrrp_log("unexpected 0 changes");
}
}
my $vrrp_instances = vrrp_update_config($vrrp_intf);
my $more_changes = remove_from_changes($vrrp_intf);
- VyattaKeepalived::vrrp_log(" instances $vrrp_instances, $more_changes");
+ vrrp_log(" instances $vrrp_instances, $more_changes");
if ($vrrp_instances > 0 and $more_changes == 0) {
- VyattaKeepalived::restart_daemon($conf_file);
+ restart_daemon($conf_file);
}
if ($vrrp_instances == 0) {
- VyattaKeepalived::stop_daemon();
+ stop_daemon();
system("rm -f $conf_file");
}
}
@@ -390,8 +390,8 @@ if ($action eq "delete") {
print "must include interface & group";
exit 1;
}
- VyattaKeepalived::vrrp_log("vrrp delete $vrrp_intf $vrrp_group");
- my $state_file = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group);
+ vrrp_log("vrrp delete $vrrp_intf $vrrp_group");
+ my $state_file = get_state_file($vrrp_intf, $vrrp_group);
system("rm -f $state_file");
exit 0;
}