From b5ab6468c9784d5f5f21e808034f462d5c9d91b2 Mon Sep 17 00:00:00 2001 From: sridhargaddam Date: Tue, 24 Feb 2015 07:23:24 +0000 Subject: [PATCH] Fix curl issue when SERVICE_HOST is defined to IPv6 address When SERVICE_HOST is defined to literal IPv6 address (i.e., [fdf8:f53b:82e4::179]) we will have to include --globoff option for curl to be able to reach the various openstack services. Using globoff works for both IPv6 and IPv4 urls, so its safe to include this option for all curl statements in devstack. Closes-Bug: #1424943 Change-Id: I2afc16f2f94d7d7069b0ba61bc8348c03413e4e7 --- exercises/horizon.sh | 2 +- exercises/sahara.sh | 2 +- exercises/zaqar.sh | 2 +- functions | 4 +++- lib/ceilometer | 2 +- lib/keystone | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/exercises/horizon.sh b/exercises/horizon.sh index ad08221690..4020580157 100755 --- a/exercises/horizon.sh +++ b/exercises/horizon.sh @@ -36,7 +36,7 @@ source $TOP_DIR/exerciserc is_service_enabled horizon || exit 55 # can we get the front page -curl http://$SERVICE_HOST 2>/dev/null | grep -q 'Log In' || die $LINENO "Horizon front page not functioning!" +$CURL_GET http://$SERVICE_HOST 2>/dev/null | grep -q 'Log In' || die $LINENO "Horizon front page not functioning!" set +o xtrace echo "*********************************************************************" diff --git a/exercises/sahara.sh b/exercises/sahara.sh index 867920ed31..2589e28c0c 100755 --- a/exercises/sahara.sh +++ b/exercises/sahara.sh @@ -35,7 +35,7 @@ source $TOP_DIR/exerciserc is_service_enabled sahara || exit 55 -curl http://$SERVICE_HOST:8386/ 2>/dev/null | grep -q 'Auth' || die $LINENO "Sahara API isn't functioning!" +$CURL_GET http://$SERVICE_HOST:8386/ 2>/dev/null | grep -q 'Auth' || die $LINENO "Sahara API isn't functioning!" set +o xtrace echo "*********************************************************************" diff --git a/exercises/zaqar.sh b/exercises/zaqar.sh index 6996f346b5..c370b12c85 100755 --- a/exercises/zaqar.sh +++ b/exercises/zaqar.sh @@ -35,7 +35,7 @@ source $TOP_DIR/exerciserc is_service_enabled zaqar-server || exit 55 -curl http://$SERVICE_HOST:8888/v1/ 2>/dev/null | grep -q 'queue_name' || die $LINENO "Zaqar API not functioning!" +$CURL_GET http://$SERVICE_HOST:8888/v1/ 2>/dev/null | grep -q 'queue_name' || die $LINENO "Zaqar API not functioning!" set +o xtrace echo "*********************************************************************" diff --git a/functions b/functions index 2f976cfab1..79b2b37b4e 100644 --- a/functions +++ b/functions @@ -325,13 +325,15 @@ function use_database { fi } +#Macro for curl statements. curl requires -g option for literal IPv6 addresses. +CURL_GET="${CURL_GET:-curl -g}" # Wait for an HTTP server to start answering requests # wait_for_service timeout url function wait_for_service { local timeout=$1 local url=$2 - timeout $timeout sh -c "while ! curl -k --noproxy '*' -s $url >/dev/null; do sleep 1; done" + timeout $timeout sh -c "while ! $CURL_GET -k --noproxy '*' -s $url >/dev/null; do sleep 1; done" } diff --git a/lib/ceilometer b/lib/ceilometer index f509788ab7..82e9417ba4 100644 --- a/lib/ceilometer +++ b/lib/ceilometer @@ -340,7 +340,7 @@ function start_ceilometer { # only die on API if it was actually intended to be turned on if is_service_enabled ceilometer-api; then echo "Waiting for ceilometer-api to start..." - if ! timeout $SERVICE_TIMEOUT sh -c "while ! curl --noproxy '*' -s http://localhost:8777/v2/ >/dev/null; do sleep 1; done"; then + if ! wait_for_service $SERVICE_TIMEOUT $CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/v2/; then die $LINENO "ceilometer-api did not start" fi fi diff --git a/lib/keystone b/lib/keystone index 102d188611..0968445dc0 100644 --- a/lib/keystone +++ b/lib/keystone @@ -564,7 +564,7 @@ function start_keystone { # Check that the keystone service is running. Even if the tls tunnel # should be enabled, make sure the internal port is checked using # unencryted traffic at this point. - if ! timeout $SERVICE_TIMEOUT sh -c "while ! curl --noproxy '*' -k -s $auth_protocol://$KEYSTONE_SERVICE_HOST:$service_port/v$IDENTITY_API_VERSION/ >/dev/null; do sleep 1; done"; then + if ! wait_for_service $SERVICE_TIMEOUT $auth_protocol://$KEYSTONE_SERVICE_HOST:$service_port/v$IDENTITY_API_VERSION/; then die $LINENO "keystone did not start" fi