CLOUDSTACK-2118 added delay for interface to come up in cloud-early-config In cloud-early-config ifup is taking some time to setup the interface ip So in setup_interface waiting for some time for interface to come up

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
Jayapal 2013-04-19 17:31:19 +05:30 committed by Abhinandan Prateek
parent b01f63123f
commit 59bee8d1b4

View File

@ -27,6 +27,8 @@
# under the License.
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
#set -x
#exec 3>&0 4>&1 > /var/log/test.log 2>&1
# Fix haproxy directory issue
mkdir -p /var/lib/haproxy
@ -227,7 +229,29 @@ setup_interface() {
ifdown $intf
if [ "$RROUTER" != "1" -o "$1" != "2" ]
then
ifup $intf
ifup $intf
timer=0
log_it "checking that $intf has IP "
while true
do
ip=$(ifconfig $intf | grep "inet addr:" | awk '{print $2}' | awk -F: '{print $2}')
if [ -z $ip ]
then
sleep 1;
#waiting for the interface to setup with ip
log_it "waiting for $intf interface setup with ip timer=$timer"
else
break
fi
if [ $timer -gt 15 ]
then
log_it "interface $intf is not set up with ip... exiting";
break
fi
timer=`expr $timer + 1`
done
fi
fi
}
@ -392,33 +416,8 @@ setup_common() {
gwdev="eth0"
fi
timer=0
#default route add fails if we run before interface configured with ip
log_it "checking that $gwdev has IP before setting default route to $GW"
echo "checking that $gwdev has IP before setting default route to $GW"
while true
do
ip=$(ifconfig $gwdev | grep "inet addr:" | awk '{print $2}' | awk -F: '{print $2}')
if [ -z $ip ]
then
sleep 1;
#waiting for the interface to setup with ip
log_it "waiting for $gwdev interface setup with ip"
echo "waiting for $gwdev interface setup with ip"
else
ip route add default via $GW dev $gwdev
break
fi
ip route add default via $GW dev $gwdev
if [ $timer -gt 15 ]
then
log_it "interface $gwdev is not set up with ip... configuring default route failed";
echo "interface $gwdev is not set up with ip... configuring default route failed"
break
fi
timer=`expr $timer + 1`
done
fi
# a hacking way to activate vSwitch under VMware