dangogh commented on a change in pull request #2714: Tm script improvements
URL: https://github.com/apache/trafficcontrol/pull/2714#discussion_r211334842
##########
File path: infrastructure/cdn-in-a-box/traffic_monitor/run.sh
##########
@@ -59,64 +59,63 @@ sed -ie "s;MY_GATEWAY;$GATEWAY;g" /server.json
sed -ie "s;MY_NETMASK;$NETMASK;g" /server.json
sed -ie "s;MY_IP;$IP;g" /server.json
-while ! curl -sk $TO_URL/api/1.3/ping </dev/null; do
- echo "waiting for $TO_HOST:$TO_PORT"
+source /to-access.sh
+
+while ! to-ping; do
+ echo "waiting for traffic_ops..."
sleep 3
done
-RESPONSE=$(curl -sk -d '{ "u":"'"$TM_USER"'", "p":"'"$TM_PASSWORD"'" }'
$TO_URL/api/1.3/user/login)
-while [[ "$RESPONSE" == '{"alerts":[{"text":"Invalid username or
password.","level":"error"}]}' ]]; do
- echo "Waiting for availability of $TM_USER login"
- RESPONSE=$(curl -sk -d '{ "u":"'"$TM_USER"'", "p":"'"$TM_PASSWORD"'" }'
$TO_URL/api/1.3/user/login)
+# There's a race condition with setting the TM credentials and TO actually
creating
+# the TM user
+while [[ -z "$(to-get api/1.3/users | grep $TM_USER )" ]]; do
+ echo "waiting for TM_USER creation..."
sleep 3
done
-curl -ksc cookie.jar -d
"{\"u\":\"$TO_ADMIN_USER\",\"p\":\"${TO_ADMIN_PASSWORD}\"}"
$TO_URL/api/1.3/user/login
-echo "Got Cookie: $(tail -n1 cookie.jar | tr '\t' ' ')"
+
+# Need to do this to get the to-access auth to use proper credentials
+export TO_ADMIN_USER="$TM_USER"
+export TO_ADMIN_PASSWORD="$TM_PASSWORD"
+
# Gets our CDN ID
-CDN=$(curl -ksb cookie.jar $TO_URL/api/1.3/cdns)
-CDN=$(echo $CDN | tr '}' '\n' | grep CDN-in-a-Box | tr ',' '\n' | grep '"id"'
| cut -d : -f2)
+CDN=$(to-get api/1.3/cdns | jq
'.response|.[]|select(.name=="CDN-in-a-Box")|.id')
while [[ -z "$CDN" ]]; do
- echo "waiting for trafficops setup to complete..."
+ echo "waiting for traffic_ops setup to complete..."
sleep 3
- CDN=$(curl -ksb cookie.jar $TO_URL/api/1.3/cdns)
- CDN=$(echo $CDN | tr '}' '\n' | grep CDN-in-a-Box | tr ',' '\n' | grep
'"id"' | cut -d : -f2)
+ CDN=$(to-get api/1.3/cdns | jq
'.response|.[]|select(.name=="CDN-in-a-Box")|.id')
Review comment:
same as above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services