From 6045d3c2fd7988b54971f02c14cdc6364f186fc8 Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Fri, 19 Sep 2014 14:25:11 +0200 Subject: [PATCH] labs: wait for namespaces and interfaces When setting up neutron router and DHCP, the time until namespaces and interfaces are ready varies a lot (from less than a second to five seconds and more), even on the same host system. If it takes longer, we proceed too early which leaves the cluster misconfigured. In that case, nova instances fail to get a DHCP address. This patch makes sure the script waits until the interfaces are ready. Change-Id: I346a098062d984956cf496e89f9ada2a38df0569 --- labs/scripts/setup_neutron_network.sh | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/labs/scripts/setup_neutron_network.sh b/labs/scripts/setup_neutron_network.sh index f315c4d8..3b4125dd 100755 --- a/labs/scripts/setup_neutron_network.sh +++ b/labs/scripts/setup_neutron_network.sh @@ -135,7 +135,56 @@ iniset_sudo $conf DEFAULT verbose True echo "Restarting the network service." sudo service neutron-plugin-openvswitch-agent restart sudo service neutron-l3-agent restart + +echo -n "Getting router namespace." +nsrouter=$(ip netns|grep qrouter) +while [ : ]; do + nsrouter=$(ip netns|grep qrouter) + if [ -n "$nsrouter" ]; then + echo + echo "Router namespace: $nsrouter" + break + fi + echo -n "." + sleep 1 +done + sudo service neutron-dhcp-agent restart + +echo -n "Getting DHCP namespace." +while [ : ]; do + nsdhcp=$(ip netns|grep qdhcp) + if [ -n "$nsdhcp" ]; then + echo + echo "DHCP namespace: $nsdhcp" + break + fi + echo -n "." + sleep 1 +done + +echo -n "Waiting for interfaces qr-*, qg-* in router namespace." +while [ : ]; do + ifaces=$(sudo ip netns exec "$nsrouter" ip addr) + if [[ $ifaces == *:\ qr-* && $ifaces == *:\ qg-* ]]; then + echo + break + fi + echo -n "." + sleep 1 +done + +echo -n "Waiting for interface tap* in DHCP namespace." +while [ : ]; do + ifaces=$(sudo ip netns exec "$nsdhcp" ip addr) + if [[ $ifaces == *:\ tap* ]]; then + echo + break + fi + echo -n "." + sleep 1 +done + sudo service neutron-metadata-agent restart echo "Restarting the OVS agent."