You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2012/12/22 00:29:45 UTC
[3/5] git commit: Redundant Router: Restart vpn related services when
redundant router fail-over
Redundant Router: Restart vpn related services when redundant router fail-over
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/5eba4891
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/5eba4891
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/5eba4891
Branch: refs/heads/master
Commit: 5eba48919869720f98c1f4912de9d3686b092f49
Parents: 9f257aa
Author: Sheng Yang <sh...@citrix.com>
Authored: Tue Nov 13 19:03:36 2012 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Dec 21 15:22:03 2012 -0800
----------------------------------------------------------------------
.../debian/config/etc/init.d/cloud-early-config | 1 +
.../config/root/redundant_router/disable_pubip.sh | 2 -
.../root/redundant_router/enable_pubip.sh.templ | 4 +-
.../config/root/redundant_router/master.sh.templ | 6 ++
.../config/root/redundant_router/services.sh | 62 +++++++++++++++
5 files changed, 70 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5eba4891/patches/systemvm/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
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 64459fd..fe536cb 100755
--- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config
+++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
@@ -477,6 +477,7 @@ setup_redundant_router() {
cp /root/redundant_router/check_bumpup.sh $rrouter_bin_path/
cp /root/redundant_router/disable_pubip.sh $rrouter_bin_path/
cp /root/redundant_router/checkrouter.sh.templ /opt/cloud/bin/checkrouter.sh
+ cp /root/redundant_router/services.sh $rrouter_bin_path/
sed -i "s/\[ROUTER_ID\]/$NAME/g" /etc/keepalived/keepalived.conf
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
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5eba4891/patches/systemvm/debian/config/root/redundant_router/disable_pubip.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/redundant_router/disable_pubip.sh b/patches/systemvm/debian/config/root/redundant_router/disable_pubip.sh
index af5edbf..ee4e894 100644
--- a/patches/systemvm/debian/config/root/redundant_router/disable_pubip.sh
+++ b/patches/systemvm/debian/config/root/redundant_router/disable_pubip.sh
@@ -21,5 +21,3 @@ while read i
do
ifconfig $i down
done < /tmp/iflist
-service cloud-passwd-srvr stop
-service dnsmasq stop
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5eba4891/patches/systemvm/debian/config/root/redundant_router/enable_pubip.sh.templ
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/redundant_router/enable_pubip.sh.templ b/patches/systemvm/debian/config/root/redundant_router/enable_pubip.sh.templ
index ccdef0b..0e42ec4 100644
--- a/patches/systemvm/debian/config/root/redundant_router/enable_pubip.sh.templ
+++ b/patches/systemvm/debian/config/root/redundant_router/enable_pubip.sh.templ
@@ -30,6 +30,4 @@ do
ifconfig $i up
fi
done < /tmp/iflist
-ip route add default via [GATEWAY] dev eth2 && \
-service cloud-passwd-srvr restart && \
-service dnsmasq restart
+ip route add default via [GATEWAY] dev eth2
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5eba4891/patches/systemvm/debian/config/root/redundant_router/master.sh.templ
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/redundant_router/master.sh.templ b/patches/systemvm/debian/config/root/redundant_router/master.sh.templ
index 418fd5d..11ca628 100644
--- a/patches/systemvm/debian/config/root/redundant_router/master.sh.templ
+++ b/patches/systemvm/debian/config/root/redundant_router/master.sh.templ
@@ -28,12 +28,18 @@ fi
echo To master called >> [RROUTER_LOG]
[RROUTER_BIN_PATH]/enable_pubip.sh >> [RROUTER_LOG] 2>&1
ret=$?
+if [ $ret -eq 0 ]
+then
+ [RROUTER_BIN_PATH]/services.sh restart >> [RROUTER_LOG] 2>&1
+ ret=$?
+fi
last_msg=`tail -n 1 [RROUTER_LOG]`
echo Enable public ip returned $ret >> [RROUTER_LOG]
if [ $ret -ne 0 ]
then
echo Fail to enable public ip! >> [RROUTER_LOG]
[RROUTER_BIN_PATH]/disable_pubip.sh >> [RROUTER_LOG] 2>&1
+ [RROUTER_BIN_PATH]/services.sh stop >> [RROUTER_LOG] 2>&1
service keepalived stop >> [RROUTER_LOG] 2>&1
service conntrackd stop >> [RROUTER_LOG] 2>&1
echo Status: FAULT \($last_msg\) >> [RROUTER_LOG]
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5eba4891/patches/systemvm/debian/config/root/redundant_router/services.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/redundant_router/services.sh b/patches/systemvm/debian/config/root/redundant_router/services.sh
new file mode 100644
index 0000000..4d8949b
--- /dev/null
+++ b/patches/systemvm/debian/config/root/redundant_router/services.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by the License.
+# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+vpn_service() {
+ ps aux|grep ipsec | grep -v grep > /dev/null
+ no_vpn=$?
+ if [ $no_vpn -eq 1 ]
+ then
+ return 0
+ fi
+ r=0
+ case "$1" in
+ stop)
+ service ipsec stop && \
+ service xl2tpd stop
+ r=$?
+ ;;
+ restart)
+ service ipsec restart && \
+ service xl2tpd restart
+ r=$?
+ ;;
+ esac
+ return $r
+}
+
+ret=0
+case "$1" in
+ start)
+ vpn_service restart && \
+ service cloud-passwd-srvr start && \
+ service dnsmasq start
+ ret=$?
+ ;;
+ stop)
+ vpn_service stop && \
+ service cloud-passwd-srvr stop && \
+ service dnsmasq stop
+ ret=$?
+ ;;
+ restart)
+ vpn_service restart && \
+ service cloud-passwd-srvr restart && \
+ service dnsmasq restart
+ ret=$?
+ ;;
+ *)
+ echo "Usage: services {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
+exit $ret