From 4bbfa2513e9becb28fe737dc40d6c49fa8059331 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 14 Sep 2011 02:58:43 -0700 Subject: [PATCH] bug 11307: Add PRIORITY bump up script for redundant virtual routers --- .../config/etc/init.d/cloud-early-config | 1 + .../debian/config/root/bumpup_priority.sh | 3 + .../debian/config/root/checkrouter.sh | 12 +++- .../root/redundant_router/check_bumpup.sh | 3 + .../redundant_router/keepalived.conf.templ | 64 ++++++++++--------- 5 files changed, 51 insertions(+), 32 deletions(-) create mode 100755 patches/systemvm/debian/config/root/bumpup_priority.sh create mode 100644 patches/systemvm/debian/config/root/redundant_router/check_bumpup.sh diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index f604ba517cd..b473f5ffafc 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -341,6 +341,7 @@ setup_redundant_router() { sed -i "s/\[ROUTER_IP\]/$GUEST_GW\/$GUEST_CIDR_SIZE/g" /etc/keepalived/keepalived.conf sed -i "s/\[BOARDCAST\]/$GUEST_BRD/g" /etc/keepalived/keepalived.conf sed -i "s/\[PRIORITY\]/$ROUTER_PR/g" /etc/keepalived/keepalived.conf + sed -i "s/\[DELTA\]/2/g" /etc/keepalived/keepalived.conf sed -i "s/\[LINK_IF\]/eth0/g" /etc/conntrackd/conntrackd.conf sed -i "s/\[LINK_IP\]/$ETH0_IP/g" /etc/conntrackd/conntrackd.conf sed -i "s/\[IGNORE_IP1\]/$GUEST_GW/g" /etc/conntrackd/conntrackd.conf diff --git a/patches/systemvm/debian/config/root/bumpup_priority.sh b/patches/systemvm/debian/config/root/bumpup_priority.sh new file mode 100755 index 00000000000..9a24a6a60bf --- /dev/null +++ b/patches/systemvm/debian/config/root/bumpup_priority.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +touch /tmp/rrouter_bumped diff --git a/patches/systemvm/debian/config/root/checkrouter.sh b/patches/systemvm/debian/config/root/checkrouter.sh index 6e28a9a278c..c6e7fb94273 100755 --- a/patches/systemvm/debian/config/root/checkrouter.sh +++ b/patches/systemvm/debian/config/root/checkrouter.sh @@ -9,6 +9,16 @@ then exit 1 fi -tail -n 1 /root/keepalived.log | grep "Status" +bumped="Bumped: NO" +if [ -e /tmp/rrouter_bumped ] +then + bumped="Bumped: YES" +fi + +stat=`tail -n 1 /root/keepalived.log | grep "Status"` +if [ $? -eq 0 ] +then + echo "$stat&$bumped" +fi unlock_exit $? $lock $locked diff --git a/patches/systemvm/debian/config/root/redundant_router/check_bumpup.sh b/patches/systemvm/debian/config/root/redundant_router/check_bumpup.sh new file mode 100644 index 00000000000..7f400c74f42 --- /dev/null +++ b/patches/systemvm/debian/config/root/redundant_router/check_bumpup.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cat /tmp/rrouter_bumped diff --git a/patches/systemvm/debian/config/root/redundant_router/keepalived.conf.templ b/patches/systemvm/debian/config/root/redundant_router/keepalived.conf.templ index ed59ba18c71..b7e11c18f04 100644 --- a/patches/systemvm/debian/config/root/redundant_router/keepalived.conf.templ +++ b/patches/systemvm/debian/config/root/redundant_router/keepalived.conf.templ @@ -4,38 +4,12 @@ global_defs { router_id [ROUTER_ID] } -vrrp_sync_group VG_1 { - group { - inside_network # name of vrrp_instance (below) - outside_network # One for each moveable IP. - } - - # notify scripts and alerts are optional - # - # filenames of scripts to run on transitions - # can be unquoted (if just filename) - # or quoted (if has parameters) - # to MASTER transition - notify_master "/root/redundant_router/master.sh" - # to BACKUP transition - notify_backup "/root/redundant_router/backup.sh" - # FAULT transition - notify_fault "/root/redundant_router/fault.sh" - - # for ANY state transition. - # "notify" script is called AFTER the - # notify_* script(s) and is executed - # with 3 arguments provided by keepalived - # (ie don't include parameters in the notify line). - # arguments - # $1 = "GROUP"|"INSTANCE" - # $2 = name of group or instance - # $3 = target state of transition - # ("MASTER"|"BACKUP"|"FAULT") - #notify /root/redundant_router/notify.sh +vrrp_script check_bumpup { + script "/root/redundant_router/check_bumpup.sh" + interval 5 + weight [DELTA] } - vrrp_instance inside_network { state BACKUP interface eth0 @@ -52,5 +26,33 @@ vrrp_instance inside_network { [ROUTER_IP] brd [BOARDCAST] dev eth0 } - nopreempt + track_script { + check_bumpup + } + + #nopreempt + + # notify scripts and alerts are optional + # + # filenames of scripts to run on transitions + # can be unquoted (if just filename) + # or quoted (if has parameters) + # to MASTER transition + notify_master "/root/redundant_router/master.sh" + # to BACKUP transition + notify_backup "/root/redundant_router/backup.sh" + # FAULT transition + notify_fault "/root/redundant_router/fault.sh" + + # for ANY state transition. + # "notify" script is called AFTER the + # notify_* script(s) and is executed + # with 3 arguments provided by keepalived + # (ie don't include parameters in the notify line). + # arguments + # $1 = "GROUP"|"INSTANCE" + # $2 = name of group or instance + # $3 = target state of transition + # ("MASTER"|"BACKUP"|"FAULT") + #notify /root/redundant_router/notify.sh }