X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fauthz.git;a=blobdiff_plain;f=auth%2Fauth-cass%2Fcass_init%2Fcmd.sh;h=afb66774ccc83bc8161b8035dfa5e7231385a1de;hp=09379730e49ee5142347ee2d983e2c968853c195;hb=1e3be601c78fa851333e51c6498713d1c412bd62;hpb=7e97d0c2c5a10e92d1233117bb60bfd9e42d35a0 diff --git a/auth/auth-cass/cass_init/cmd.sh b/auth/auth-cass/cass_init/cmd.sh index 09379730..afb66774 100644 --- a/auth/auth-cass/cass_init/cmd.sh +++ b/auth/auth-cass/cass_init/cmd.sh @@ -16,20 +16,36 @@ function status { fi } -function install_cql { - status install +function wait_start { sleep 10 status wait for cassandra to start + for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do + if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then + echo "Waiting for Cassandra to start... Sleep 10" + sleep 10 + else + break + fi + done +} + +function wait_cql { + status wait for keyspace to be initialized + for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do + if [ "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then + break + else + echo "Waiting for Keyspaces to be loaded... Sleep 10" + sleep 10 + fi + done +} + +function install_cql { + wait_start started # Now, make sure data exists if [ "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" = "" ]; then - for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do - if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then - echo "Waiting for Cassandra to start... Sleep 10" - sleep 10 - else - break - fi - done + status install echo "Initializing Cassandra DB" if [ "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following " @@ -108,6 +124,14 @@ case "$1" in echo "Cassandra Startup" /usr/local/bin/docker-entrypoint.sh ;; + wait) + # Wait for initialization. This can be called from Docker only as a check to make sure it is ready + wait_start started + + # Make sure Keyspace is loaded + wait_cql + status ready + ;; onap) # start install_onap (which calls install_cql first) in background, waiting for process to start install_onap &