@@ -344,39 +344,42 @@ function wait_for_service {
344344
345345
346346# ping check
347- # Uses globals ``ENABLED_SERVICES``
348- # ping_check from-net ip boot-timeout expected
347+ # Uses globals ``ENABLED_SERVICES``, ``TOP_DIR``, ``MULTI_HOST``, ``PRIVATE_NETWORK``
348+ # ping_check <ip> [ boot-timeout] [from_net] [ expected]
349349function ping_check {
350- if is_service_enabled neutron; then
351- _ping_check_neutron " $1 " $2 $3 $4
352- return
350+ local ip=$1
351+ local timeout=${2:- 30}
352+ local from_net=${3:- " " }
353+ local expected=${4:- True}
354+ local op=" !"
355+ local failmsg=" [Fail] Couldn't ping server"
356+ local ping_cmd=" ping"
357+
358+ # if we don't specify a from_net we're expecting things to work
359+ # fine from our local box.
360+ if [[ -n " $from_net " ]]; then
361+ if is_service_enabled neutron; then
362+ ping_cmd=" $TOP_DIR /tools/ping_neutron.sh $from_net "
363+ elif [[ " $MULTI_HOST " = " True" && " $from_net " = " $PRIVATE_NETWORK_NAME " ]]; then
364+ # there is no way to address the multihost / private case, bail here for compatibility.
365+ # TODO: remove this cruft and redo code to handle this at the caller level.
366+ return
367+ fi
353368 fi
354- _ping_check_novanet " $1 " $2 $3 $4
355- }
356369
357- # ping check for nova
358- # Uses globals ``MULTI_HOST``, ``PRIVATE_NETWORK``
359- function _ping_check_novanet {
360- local from_net=$1
361- local ip=$2
362- local boot_timeout=$3
363- local expected=${4:- " True" }
364- local check_command=" "
365- MULTI_HOST=$( trueorfalse False MULTI_HOST)
366- if [[ " $MULTI_HOST " = " True" && " $from_net " = " $PRIVATE_NETWORK_NAME " ]]; then
367- return
370+ # inverse the logic if we're testing no connectivity
371+ if [[ " $expected " != " True" ]]; then
372+ op=" "
373+ failmsg=" [Fail] Could ping server"
368374 fi
369- if [[ " $expected " = " True" ]]; then
370- check_command=" while ! ping -c1 -w1 $ip ; do sleep 1; done"
371- else
372- check_command=" while ping -c1 -w1 $ip ; do sleep 1; done"
373- fi
374- if ! timeout $boot_timeout sh -c " $check_command " ; then
375- if [[ " $expected " = " True" ]]; then
376- die $LINENO " [Fail] Couldn't ping server"
377- else
378- die $LINENO " [Fail] Could ping server"
379- fi
375+
376+ # Because we've transformed this command so many times, print it
377+ # out at the end.
378+ local check_command=" while $op $ping_cmd -c1 -w1 $ip ; do sleep 1; done"
379+ echo " Checking connectivity with $check_command "
380+
381+ if ! timeout $timeout sh -c " $check_command " ; then
382+ die $LINENO $failmsg
380383 fi
381384}
382385
0 commit comments