From ff33ff463b4ddeeb1aea2d4c8147722f8fb3ebcb Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Mon, 6 Nov 2017 15:47:00 +0100 Subject: [PATCH] net/keepalived: add notify hotplug-call script handling During keepalived config generation for the vrrp_instance and vrrp_sync_group the notify_* sections are automatic added to the runtime keepalived.conf. This could be used for service which want to react on keepalived notifications. Signed-off-by: Florian Eckert --- net/keepalived/files/keepalived.init | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/net/keepalived/files/keepalived.init b/net/keepalived/files/keepalived.init index 41e311d545..778777b671 100644 --- a/net/keepalived/files/keepalived.init +++ b/net/keepalived/files/keepalived.init @@ -79,6 +79,18 @@ print_list_indent() { printf "$indent}\n" >> $KEEPALIVED_CONF } +print_notify() { + local type=$1 + shift + local name=$1 + shift + for notify in $*; do + printf "$INDENT_1$notify" >> $KEEPALIVED_CONF + notify=$(echo $notify | tr 'a-z' 'A-Z') + printf " \"/bin/busybox env -i ACTION=$notify TYPE=$type NAME=$name /sbin/hotplug-call keepalived\"\n" >> $KEEPALIVED_CONF + done +} + global_defs() { local linkbeat_use_polling notification_email @@ -242,8 +254,11 @@ vrrp_sync_group() { group="$valid_group" print_list_indent group - print_elems_indent $1 $INDENT_1 notify_backup notify_master notify_fault \ - notify no_val_smtp_alert no_val_global_tracking + print_elems_indent $1 $INDENT_1 no_val_smtp_alert no_val_global_tracking + + print_notify "GROUP" "$name" notify_backup notify_master \ + notify_fault notify + config_section_close } @@ -266,13 +281,15 @@ vrrp_instance() { print_elems_indent $1 $INDENT_1 use_vmac state interface \ mcast_src_ip unicast_src_ip virtual_router_id version priority \ - advert_int preempt_delay debug notify_backup \ - notify_master notify_fault notify_stop notify \ + advert_int preempt_delay debug \ lvs_sync_daemon_interface garp_master_delay garp_master_refresh \ garp_master_repeat garp_master_refresh_repeat \ no_val_vmac_xmit_base no_val_native_ipv6 no_val_accept \ no_val_dont_track_primary no_val_smtp_alert no_val_nopreempt + print_notify "INSTANCE" "$name" notify_backup notify_master \ + notify_fault notify_stop notify + # Handle virtual_ipaddress & virtual_ipaddress_excluded lists for opt in virtual_ipaddress virtual_ipaddress_excluded; do config_get $opt $1 $opt -- 2.30.2