summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohit Mehta <mohit@vyatta.com>2008-03-20 16:30:08 -0700
committerMohit Mehta <mohit@vyatta.com>2008-03-20 16:30:08 -0700
commit814b58b62fcb20c45f0a8e31f6f09e308aabc39f (patch)
tree4fff8ec80e2c106f5268400f528d2e7a9ac695f5
parentf8620172d349b7892fdb56ee9a98a549e849b9ed (diff)
downloadvyatta-cfg-system-814b58b62fcb20c45f0a8e31f6f09e308aabc39f.tar.gz
vyatta-cfg-system-814b58b62fcb20c45f0a8e31f6f09e308aabc39f.zip
Fix Bug 2778 VRRP: add ability to run scripts on state transition
- enhancement added: configuring of scripts to run on vrrp state-transitions
-rwxr-xr-xscripts/keepalived/vyatta-keepalived.pl21
-rwxr-xr-xscripts/keepalived/vyatta-vrrp-state.pl9
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def4
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def2
10 files changed, 54 insertions, 4 deletions
diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl
index 1deeafe8..0f1301db 100755
--- a/scripts/keepalived/vyatta-keepalived.pl
+++ b/scripts/keepalived/vyatta-keepalived.pl
@@ -81,6 +81,21 @@ sub keepalived_get_values {
}
}
+ $config->setLevel("$path vrrp vrrp-group $group run-transition-scripts");
+ my $run_backup_script = $config->returnValue("backup");
+ if(!defined $run_backup_script){
+ $run_backup_script = "null";
+ }
+ my $run_fault_script = $config->returnValue("fault");
+ if(!defined $run_fault_script){
+ $run_fault_script = "null";
+ }
+ my $run_master_script = $config->returnValue("master");
+ if(!defined $run_master_script){
+ $run_master_script = "null";
+ }
+
+
$output .= "vrrp_instance $vrrp_instance \{\n";
if ($preempt eq "false") {
$output .= "\tstate BACKUP\n";
@@ -105,11 +120,11 @@ sub keepalived_get_values {
}
$output .= "\t\}\n";
$output .= "\tnotify_master ";
- $output .= "\"$state_transition_script master $intf $group @vips\" \n";
+ $output .= "\"$state_transition_script master $intf $group $run_master_script @vips\" \n";
$output .= "\tnotify_backup ";
- $output .= "\"$state_transition_script backup $intf $group @vips\" \n";
+ $output .= "\"$state_transition_script backup $intf $group $run_backup_script @vips\" \n";
$output .= "\tnotify_fault ";
- $output .= "\"$state_transition_script fault $intf $group @vips\" \n";
+ $output .= "\"$state_transition_script fault $intf $group $run_fault_script @vips\" \n";
$output .= "\}\n";
}
diff --git a/scripts/keepalived/vyatta-vrrp-state.pl b/scripts/keepalived/vyatta-vrrp-state.pl
index 8b813529..9e11b649 100755
--- a/scripts/keepalived/vyatta-vrrp-state.pl
+++ b/scripts/keepalived/vyatta-vrrp-state.pl
@@ -55,7 +55,8 @@ sub vrrp_state_log {
my $vrrp_state = $ARGV[0];
my $vrrp_intf = $ARGV[1];
my $vrrp_group = $ARGV[2];
-my $vrrp_vip = $ARGV[3];
+my $vrrp_transitionscript = $ARGV[3];
+my $vrrp_vip = $ARGV[4];
my $sfile = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group);
my ($old_time, $old_intf, $old_group, $old_state, $old_ltime) =
@@ -77,6 +78,12 @@ if ($vrrp_state eq "backup") {
system("rm -f $mfile");
}
+
+if (!($vrrp_transitionscript eq "null")){
+ exec("$vrrp_transitionscript");
+}
+
+
exit 0;
# end of file
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def
new file mode 100644
index 00000000..8c323f0a
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to backup
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Backup Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def
new file mode 100644
index 00000000..57f53ae9
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to fault
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Fault Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def
new file mode 100644
index 00000000..14e484d9
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to master
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Master Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def
new file mode 100644
index 00000000..e47f7444
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def
@@ -0,0 +1,2 @@
+help: Specify scripts for vrrp state-transitions
+
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def
new file mode 100644
index 00000000..8c323f0a
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/backup/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to backup
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Backup Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def
new file mode 100644
index 00000000..57f53ae9
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/fault/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to fault
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Fault Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def
new file mode 100644
index 00000000..14e484d9
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/master/node.def
@@ -0,0 +1,4 @@
+help: specify an executable script to run on vrrp state-transition to master
+type: txt
+syntax:expression: exec "[ -x $VAR(@) ] || exit 1"; "Master Script should be an existing executable"
+
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def
new file mode 100644
index 00000000..e47f7444
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/run-transition-scripts/node.def
@@ -0,0 +1,2 @@
+help: Specify scripts for vrrp state-transitions
+