diff options
Diffstat (limited to 'lcm')
-rwxr-xr-x | lcm/docker/instance_init.sh | 6 | ||||
-rwxr-xr-x | lcm/resources/bin/initDB.sh | 7 | ||||
-rw-r--r-- | lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql | 9 |
3 files changed, 9 insertions, 13 deletions
diff --git a/lcm/docker/instance_init.sh b/lcm/docker/instance_init.sh index e7951192..b2c82cbb 100755 --- a/lcm/docker/instance_init.sh +++ b/lcm/docker/instance_init.sh @@ -22,9 +22,9 @@ function migrate_database { python manage.py migrate } -cd /service -if [ ! -f dbexist.txt ]; then - echo 1 > dbexist.txt +GET_VNFM_DB="show databases like 'gvnfm';" +VNFM_DB=`mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP -e "$GET_VNFM_DB"` +if [[ "$VNFM_DB" != "" ]]; then create_database migrate_database fi diff --git a/lcm/resources/bin/initDB.sh b/lcm/resources/bin/initDB.sh index 764ac1ac..5386170b 100755 --- a/lcm/resources/bin/initDB.sh +++ b/lcm/resources/bin/initDB.sh @@ -26,10 +26,9 @@ sql_path=$HOME/../ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql sql_result=$? if [ $sql_result -ne 0 ] ; then - echo "failed to create gvnfm database" + echo "Failed to create gvnfm database" exit 1 -elif [ $sql_result -eq 0 ]; then - echo "create gvnfm database successfully" +else + echo "Create gvnfm database successfully" exit 0 fi - diff --git a/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql b/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql index 79133432..aebcd6b7 100644 --- a/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql +++ b/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql @@ -12,18 +12,15 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -/******************drop old database and user***************************/ +/******************create database and user***************************/ use mysql; -drop database IF EXISTS gvnfm; -delete from user where User='gvnfm'; -FLUSH PRIVILEGES; -/******************create new database and user***************************/ -create database gvnfm CHARACTER SET utf8; +create database if not exists gvnfm CHARACTER SET utf8; GRANT ALL PRIVILEGES ON gvnfm.* TO 'gvnfm'@'%' IDENTIFIED BY 'gvnfm' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON mysql.* TO 'gvnfm'@'%' IDENTIFIED BY 'gvnfm' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON gvnfm.* TO 'gvnfm'@'localhost' IDENTIFIED BY 'gvnfm' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON mysql.* TO 'gvnfm'@'localhost' IDENTIFIED BY 'gvnfm' WITH GRANT OPTION; + FLUSH PRIVILEGES; |