diff options
author | yangyan <yangyanyj@chinamobile.com> | 2019-03-28 16:13:43 +0800 |
---|---|---|
committer | yangyan <yangyanyj@chinamobile.com> | 2019-03-28 16:13:49 +0800 |
commit | 5c08fc723d2d08b3411f1c1f270d7e58d92d5956 (patch) | |
tree | ab3ea54ecf9dd9b5171576d791bb9364433a283b /docker | |
parent | 0200706ec19be16c1d57785b5356d2485220d176 (diff) |
fix the bug of nslcm
Change-Id: I8a80f7fda536401e8d2bcfb4b61fcda7e2f3563a
Issue-ID: VFC-1319
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'docker')
-rwxr-xr-x | docker/instance_init.sh | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/docker/instance_init.sh b/docker/instance_init.sh index de4175b3..90778a4b 100755 --- a/docker/instance_init.sh +++ b/docker/instance_init.sh @@ -1,10 +1,5 @@ #/bin/bash -###### -# by vfc-db test -##### -# echo "No service needs init." -#MYSQL_USER=$1 -###### + pip install PyMySQL==0.9.3 mkdir -p /service/vfc/nfvo/lcm/resources/bin/logs mkdir -p /var/log/onap/vfc/nslcm/ @@ -19,31 +14,27 @@ if [ ! -f /var/log/onap/vfc/nslcm/runtime_nslcm.log ]; then else echo >/var/log/onap/vfc/nslcm/runtime_nslcm.log fi -###### + MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1` MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2` function create_database { - #cd /service/vfc/nfvo/db/resources/nslcm/bin + cd /service/vfc/nfvo/lcm/resources/bin bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP man_path=/service/vfc/nfvo/lcm tab=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"` tab1=`echo $tab |awk '{print $2}'` - echo "==========" - echo $tab1 - echo "==========" + if [ $tab1 -eq 0 ] ; then - echo "============" - echo $tab1 - echo "============" + echo "TABLE NOT EXISTS, START MIGRATE" - python $man_path/manage.py makemigrations database && python $man_path/manage.py migrate & + python $man_path/manage.py makemigrations database && python $man_path/manage.py migrate database & wait tab2=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"` - tab3=`echo $tab2|awk '{print $2}'` + tab3=`echo $tab2|awk '{print $2}'` if [ $tab3 -gt 0 ] ; then echo "TABLE CREATE uUCCESSFUL" fi @@ -55,7 +46,7 @@ fi if [ ! -f /service/vfc/nfvo/lcm/docker/db.txt ]; then echo 1 > /service/vfc/nfvo/lcm/docker/db.txt - echo `pwd` >> db.txt + create_database else echo "database already existed" |