summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-12-18 01:21:30 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-18 01:21:30 +0000
commitad2a34d5bb7da6b61b7a6595b2e3ab50e309ce9c (patch)
tree710c71f231ca65b3f65288101d9b1b0e635a1d0a
parent326c6564f17b56e838d086566c0d9f1fa0eca8f7 (diff)
parent582f11f6dc7b7237f18798ee646d762b29eb0f35 (diff)
Merge "Restart docker if mariadb fails to start"
-rwxr-xr-xscripts/policy/script1.sh64
1 files changed, 49 insertions, 15 deletions
diff --git a/scripts/policy/script1.sh b/scripts/policy/script1.sh
index 70706921..c47c4bf8 100755
--- a/scripts/policy/script1.sh
+++ b/scripts/policy/script1.sh
@@ -46,23 +46,15 @@ cd ..
ifconfig
-if ! ifconfig eth0; then
- if ! ifconfig ens3; then
- echo "Could not determine IP address"
- exit 1
- fi
- export IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
-else
- export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
+export IP=`ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}'`
+if [ -z "$IP" ]; then
+ echo "Could not determine IP address"
+ exit 1
fi
echo $IP
if ! ifconfig docker0; then
- if ! ifconfig ens3; then
- echo "Could not determine IP address"
- exit 1
- fi
- export DOCKER_IP_IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
+ export DOCKER_IP="$IP"
else
export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
fi
@@ -121,7 +113,49 @@ echo ${NEXUS_IP}
MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
echo ${MARIADB_IP}
-sleep 5m
+sleep 3m
+
+docker logs mariadb 2>&1 | grep -q "mysqld: ready for connections"
+if [ $? -eq 0 ]; then
+ # mariadb is ok - sleep a little longer for others
+ sleep 2m
+
+else
+ echo mariadb is not ready
+ echo Restarting...
+
+ docker kill drools pdp pap brmsgw nexus mariadb
+ docker rm -f drools pdp pap brmsgw nexus mariadb
+
+ docker-compose -f docker-compose-integration.yml up -d
+
+ if [ ! $? -eq 0 ]; then
+ echo "Docker compose failed"
+ exit 1
+ fi
+
+ docker ps
+
+ POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
+ echo ${POLICY_IP}
+
+ PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
+ echo ${PDP_IP}
+
+ PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
+ echo ${PAP_IP}
+
+ BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
+ echo ${BRMS_IP}
+
+ NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
+ echo ${NEXUS_IP}
+
+ MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
+ echo ${MARIADB_IP}
+
+ sleep 5m
+fi
netstat -tnl
@@ -160,7 +194,7 @@ INTERVAL=20
TIME=0
while [ "$TIME" -lt "$TIME_OUT" ]; do
- curl -k -i -v -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": ".*"}' https://${PDP_IP}:8081/pdp/api/getConfig && break
+ curl -k -i -v -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -d '{"policyName": ".*"}' https://${PDP_IP}:8081/pdp/api/getConfig && break
echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
sleep $INTERVAL