diff options
-rwxr-xr-x | docker/instance_config.sh | 4 | ||||
-rwxr-xr-x | docker/instance_init.sh | 64 | ||||
-rw-r--r-- | resources/bin/initDB.sh | 39 | ||||
-rw-r--r-- | resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql | 31 | ||||
-rw-r--r-- | resources/dbscripts/mysql/vfc-nfvo-lcm-createobj.sql | 320 |
5 files changed, 456 insertions, 2 deletions
diff --git a/docker/instance_config.sh b/docker/instance_config.sh index dc811d3f..073d0e6f 100755 --- a/docker/instance_config.sh +++ b/docker/instance_config.sh @@ -29,10 +29,14 @@ fi # Configure MYSQL 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 echo "MYSQL_ADDR=$MYSQL_ADDR" sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/nfvo/lcm/lcm/pub/config/config.py sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py +sed -i "s|DB_USER.*|DB_USER = '$MYSQL_USER'|" vfc/nfvo/lcm/lcm/pub/config/config.py +sed -i "s|DB_PASSWD.*|DB_PASSWD = '$MYSQL_ROOT_PASSWORD'|" vfc/nfvo/lcm/lcm/pub/config/config.py cat vfc/nfvo/lcm/lcm/pub/config/config.py diff --git a/docker/instance_init.sh b/docker/instance_init.sh index cfc9b0d5..7226e16c 100755 --- a/docker/instance_init.sh +++ b/docker/instance_init.sh @@ -1,2 +1,62 @@ -#!/bin/bash -echo "No service needs init." +#/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/ + +if [ ! -f /service/vfc/nfvo/lcm/resources/bin/logs/django.log ]; then + touch /service/vfc/nfvo/lcm/resources/bin/logs/django.log +else + echo >/service/vfc/nfvo/lcm/resources/bin/logs/django.log +fi +if [ ! -f /var/log/onap/vfc/nslcm/runtime_nslcm.log ]; then + touch /var/log/onap/vfc/nslcm/runtime_nslcm.log +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 && python $man_path/manage.py migrate & + 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}'` + if [ $tab3 -gt 0 ] ; then + echo "TABLE CREATE uUCCESSFUL" + fi +else + echo "table already existed" + exit 1 +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" +fi diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh new file mode 100644 index 00000000..13c0f2ca --- /dev/null +++ b/resources/bin/initDB.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright 2018 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +###### +#test for vfc-db +###### + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +MYSQL_USER=$1 +MYSQL_PASSWORD=$2 +MYSQL_PORT=$3 +MYSQL_IP=$4 +echo "start create vfcnfvolcm db" +sql_path=$HOME/../ +mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql +sql_result=$? +if [ $sql_result -ne 0 ] ; then + echo "failed to create vfcnfvolcm database" + exit 1 +elif [ $sql_result -eq 0 ]; then + echo "create vfcnfvolcm database successfully" + exit 0 +fi + diff --git a/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql new file mode 100644 index 00000000..94e630b5 --- /dev/null +++ b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql @@ -0,0 +1,31 @@ +-- +-- Copyright 2018 ZTE Corporation. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +/******************drop old database and user***************************/ +use mysql; +drop database IF EXISTS vfcnfvolcm; +delete from user where User='vfcnfvolcm'; +FLUSH PRIVILEGES; + +/******************create new database and user***************************/ +create database vfcnfvolcm CHARACTER SET utf8; + +GRANT ALL PRIVILEGES ON vfcnfvolcm.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; + +GRANT ALL PRIVILEGES ON vfcnfvolcm.* TO 'vfcnfvolcm'@'localhost' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'vfcnfvolcm'@'localhost' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; +FLUSH PRIVILEGES;
\ No newline at end of file diff --git a/resources/dbscripts/mysql/vfc-nfvo-lcm-createobj.sql b/resources/dbscripts/mysql/vfc-nfvo-lcm-createobj.sql new file mode 100644 index 00000000..c2447766 --- /dev/null +++ b/resources/dbscripts/mysql/vfc-nfvo-lcm-createobj.sql @@ -0,0 +1,320 @@ +-- +-- Copyright 2018 ZTE Corporation. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +use vfcnfvolcm; + +DROP TABLE IF EXISTS NFVO_CPINST; +CREATE TABLE NFVO_CPINST ( + `CPINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `CPDID` varchar(255) NOT NULL, + `CPINSTANCENAME` varchar(255) NOT NULL, + `OWNERTYPE` integer NOT NULL, + `OWNERID` varchar(255) NOT NULL, + `RELATEDTYPE` integer NOT NULL, + `RELATEDVL` varchar(255) NULL, + `RELATEDCP` varchar(255) NULL, + `RELATEDPORT` varchar(255) NULL, + `STATUS` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_FPINST; +CREATE TABLE NFVO_FPINST ( + `FPID` varchar(255) NOT NULL, + `FPINSTID` varchar(255) NOT NULL PRIMARY KEY, + `FPNAME` varchar(255) NOT NULL, + `NSINSTID` varchar(255) NOT NULL, + `VNFFGINSTID` varchar(255) NOT NULL, + `SYMMETRIC` integer NULL, + `POLICYINFO` longtext NOT NULL, + `FORWORDERPATHS` varchar(255) NULL, + `STATUS` varchar(255) NOT NULL, + `SDNCONTROLLERID` varchar(255) NOT NULL, + `SFCID` varchar(255) NOT NULL, + `FLOWCLASSIFIERS` varchar(255) NOT NULL, + `PORTPAIRGROUPS` longtext NOT NULL +); + +DROP TABLE IF EXISTS NFVO_JOB; +CREATE TABLE NFVO_JOB ( + `JOBID` varchar(255) NOT NULL PRIMARY KEY, + `JOBTYPE` varchar (255) NOT NULL, + `JOBACTION` varchar(255) NOT NULL, + `RESID` varchar(255) NOT NULL, + `STATUS` integer NULL, + `STARTTIME` varchar(255) NULL, + `ENDTIME` varchar(255) NULL, + `PROGRESS` integer NULL, + `USER` varchar(255) NULL, + `PARENTJOBID` varchar(255) NULL, + `RESNAME` varchar(255) NULL +); + +DROP TABLE IF EXISTS NFVO_JOB_STATUS; +CREATE TABLE NFVO_JOB_STATUS ( + `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + `INDEXID` integer NOT NULL, + `JOBID` varchar(255) NOT NULL, + `STATUS` varchar(255) NOT NULL, + `PROGRESS` integer NULL, + `DESCP` longtext NOT NULL, + `ERRCODE` varchar(255) NULL, + `ADDTIME` varchar(255) NULL +); + +DROP TABLE IF EXISTS NFVO_NFINST; +CREATE TABLE NFVO_NFINST ( + `NFINSTID` varchar(200) NOT NULL PRIMARY KEY, + `M_NFINSTID` varchar(200) NULL, + `NFNAME` varchar(100) NULL, + `TEMPLATEID` varchar(200) NULL, + `VNFID` varchar(200) NULL, + `PACKAGEID` varchar(200) NULL, + `VNFMINSTID` varchar(200) NULL, + `NSINSTID` varchar(200) NULL, + `STATUS` varchar(20) NULL, + `FLAVOURID` varchar(200) NULL, + `VNFLEVEL` varchar(200) NULL, + `LOCATION` varchar(200) NULL, + `MAXVM` integer NULL, + `MAXCPU` integer NULL, + `MAXRAM` integer NULL, + `MAXHD` integer NULL, + `MAXSHD` integer NULL, + `MAXNET` integer NULL, + `VERSION` varchar(255) NULL, + `VENDOR` varchar(255) NULL, + `VNFDMODEL` longtext NULL, + `INPUTPARAMS` longtext NULL, + `SCALEPARAMS` longtext NULL, + `CREATETIME` varchar(200) NULL, + `LASTUPTIME` varchar(200) NULL, + `EXTENSION` longtext NULL +); + +DROP TABLE IF EXISTS NFVO_NFPACKAGE; +CREATE TABLE NFVO_NFPACKAGE ( + `UUID` varchar(255) NOT NULL PRIMARY KEY, + `NFPACKAGEID` varchar(200) NOT NULL, + `VNFDID` varchar(255) NOT NULL, + `VENDOR` varchar(255) NOT NULL, + `VNFDVERSION` varchar(255) NOT NULL, + `VNFVERSION` varchar(255) NOT NULL, + `VNFDMODEL` longtext NULL, + `VNFDPATH` varchar(300) NULL +); + +DROP TABLE IF EXISTS NFVO_NSPACKAGE; +CREATE TABLE NFVO_NSPACKAGE ( + `ID` varchar(200) NOT NULL PRIMARY KEY, + `NSDID` varchar(200) NOT NULL, + `NAME` varchar(200) NOT NULL, + `VENDOR` varchar(200) NULL, + `DESCRIPTION` varchar(200) NULL, + `VERSION` varchar(200) NULL, + `NSDMODEL` longtext NULL, + `NSDPATH` varchar(300) NULL +); + +DROP TABLE IF EXISTS NFVO_NSINST; +CREATE TABLE NFVO_NSINST ( + `ID` varchar(200) NOT NULL PRIMARY KEY, + `NAME` varchar(200) NOT NULL, + `NSPACKAGEID` varchar(200) NULL, + `NSDID` varchar(200) NOT NULL, + `NSDINVARIANTID` varchar(200) NOT NULL, + `DESCRIPTION` varchar(255) NULL, + `SDNCONTROLLERID` varchar(200) NULL, + `FLAVOURID` varchar(200) NULL, + `NSLEVEL` varchar(200) NULL, + `STATUS` varchar(200) NULL, + `NSDMODEL` longtext NULL, + `INPUTPARAMS` longtext NULL, + `SCALEPARAMS` longtext NULL, + `CREATETIME` varchar(200) NULL, + `LASTUPTIME` varchar(200) NULL, + `GLOBALCUSTOMERID` varchar(50) NULL, + `SERVICETYPE` varchar(50) NULL +); + +DROP TABLE IF EXISTS NFVO_PORTINST; +CREATE TABLE NFVO_PORTINST ( + `PORTID` varchar(255) NOT NULL PRIMARY KEY, + `NETWORKID` varchar(255) NOT NULL, + `SUBNETWORKID` varchar(255) NOT NULL, + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `NAME` varchar(255) NOT NULL, + `INSTID` varchar(255) NOT NULL, + `CPINSTANCEID` varchar(255) NOT NULL, + `BANDWIDTH` varchar(255) NOT NULL, + `OPERATIONALSTATE` varchar(255) NOT NULL, + `IPADDRESS` varchar(255) NOT NULL, + `MACADDRESS` varchar(255) NOT NULL, + `FLOATIPADDRESS` varchar(255) NOT NULL, + `SERVICEIPADDRESS` varchar(255) NOT NULL, + `TYPEVIRTUALNIC` varchar(255) NOT NULL, + `SFCENCAPSULATION` varchar(255) NOT NULL, + `DIRECTION` varchar (255) NOT NULL, + `TENANT` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_VLINST; +CREATE TABLE NFVO_VLINST ( + `VLINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `VLDID` varchar(255) NOT NULL, + `VLINSTANCENAME` varchar(255) NULL, + `OWNERTYPE` integer NOT NULL, + `OWNERID` varchar(255) NOT NULL, + `RELATEDNETWORKID` varchar(255) NULL, + `RELATEDSUBNETWORKID` varchar(255) NULL, + `VLTYPE` integer NOT NULL, + `VIMID` varchar(255) NOT NULL, + `TENANT` varchar(255) NOT NULL, + `STATUS` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_VMINST; +CREATE TABLE NFVO_VMINST ( + `VMID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar (255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `INSTTYPE` integer NULL, + `INSTID` varchar(255) NULL, + `VMNAME` varchar(255) NOT NULL, + `OPERATIONALSTATE` integer NOT NULL, + `ZONEID` varchar(255) NULL, + `TENANT` varchar(255) NULL, + `HOSTID` varchar(255) NOT NULL, + `DETAILINFO` varchar(255) NULL +); + +DROP TABLE IF EXISTS NFVO_VNFCINST; +CREATE TABLE NFVO_VNFCINST ( + `VNFCINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `VDUID` varchar(255) NOT NULL, + `NFINSTID` varchar(255) NOT NULL, + `VMID` varchar(255) NOT NULL, + `STATUS` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_VNFFGINST; +CREATE TABLE NFVO_VNFFGINST ( + `VNFFGDID` varchar(255) NOT NULL, + `VNFFGINSTID` varchar(255) NOT NULL PRIMARY KEY, + `NSINSTID` varchar(255) NOT NULL, + `DESC` varchar(255) NULL, + `VENDOR` varchar(255) NULL, + `VERSION` varchar(255) NULL, + `ENDPOINTNUMBER` integer NOT NULL, + `VLLIST` varchar(1024) NOT NULL, + `CPLIST` varchar(1024) NOT NULL, + `VNFLIST` varchar(1024) NOT NULL, + `FPLIST` varchar(1024) NOT NULL, + `STATUS` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_NFPACKAGEFILE; +CREATE TABLE NFVO_NFPACKAGEFILE ( + `ID` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + `NFPACKAGEID` varchar(50) NOT NULL, + `FILENAME` varchar(100) NOT NULL, + `FILETYPE` varchar(2) NOT NULL, + `IMAGEID` varchar(50) NOT NULL, + `VIMID` varchar(50) NOT NULL, + `VIMUSER` varchar(50) NOT NULL, + `TENANT` varchar(50) NOT NULL, + `PURPOSE` varchar(1000) NOT NULL, + `STATUS` varchar(10) NOT NULL +); + +SET FOREIGN_KEY_CHECKS = 0; +DROP TABLE IF EXISTS t_lcm_servicebaseinfo; +SET FOREIGN_KEY_CHECKS = 1; +CREATE TABLE t_lcm_servicebaseinfo ( + serviceId VARCHAR(255) NOT NULL, + serviceName VARCHAR(255) NOT NULL, + serviceType VARCHAR(20) NOT NULL, + description VARCHAR(255) NULL, + activeStatus VARCHAR(20) NOT NULL, + status VARCHAR(20) NOT NULL, + creator VARCHAR(50) NOT NULL, + createTime BIGINT NOT NULL, + CONSTRAINT t_lcm_servicebaseinfo PRIMARY KEY(serviceId) +); +DROP TABLE IF EXISTS t_lcm_defPackage_mapping; +CREATE TABLE t_lcm_defPackage_mapping ( + serviceId VARCHAR(255) NOT NULL, + serviceDefId VARCHAR(255) NOT NULL, + templateId VARCHAR(255) NOT NULL, + templateName VARCHAR(255) NOT NULL, + CONSTRAINT t_lcm_defPackage_mapping PRIMARY KEY(serviceId), + CONSTRAINT t_lcm_defPackage_mapping FOREIGN KEY (serviceId) REFERENCES t_lcm_servicebaseinfo (serviceId) +); +DROP TABLE IF EXISTS t_lcm_inputParam_mapping; +CREATE TABLE t_lcm_inputParam_mapping ( + serviceId VARCHAR(255) NOT NULL, + inputKey VARCHAR(255) NOT NULL, + inputValue mediumtext NULL, + CONSTRAINT t_lcm_inputParam_mapping PRIMARY KEY(serviceId,inputKey), + CONSTRAINT t_lcm_inputParam_mapping FOREIGN KEY (serviceId) REFERENCES t_lcm_servicebaseinfo (serviceId) +); + +DROP TABLE IF EXISTS NFVO_WF_PLAN; +CREATE TABLE NFVO_WF_PLAN ( + `DEPLOYEDID` varchar(255) NOT NULL PRIMARY KEY, + `PROCESSID` varchar(255) NOT NULL, + `STATUS` varchar(255) NOT NULL, + `MESSAGE` varchar(1024) NULL, + `PLANNAME` varchar(255) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_OOF_DATA; +CREATE TABLE NFVO_OOF_DATA ( + `REQUESTID` varchar(255) NOT NULL, + `TRANSACTIONID` varchar(255) NOT NULL, + `REQUESTSTATUS` varchar(50) NOT NULL, + `RESOURCEMODULENAME` varchar(100) NOT NULL, + `SERVICERESOURCEID` varchar(255) NOT NULL, + `VIMID` varchar(255) NULL, + `CLOUDOWNER` varchar(100) NULL, + `CLOUDREGIONID` varchar(255) NULL, + `VDUINFO` longtext NULL, + CONSTRAINT ID PRIMARY KEY(REQUESTID,TRANSACTIONID) +); + +DROP TABLE IF EXISTS NFVO_PNFINST; +CREATE TABLE NFVO_PNFINST ( + `PNFID` varchar(255) NOT NULL PRIMARY KEY, + `PNFNAME` varchar(255) NOT NULL, + `PNFDID` varchar(50) NOT NULL, + `PNFDINFOID` varchar(100) NOT NULL, + `PNFPROFILEID` varchar(255) NOT NULL, + `CPINFO` longtext NOT NULL, + `EMSID` varchar(255) NOT NULL, + `NSINSTANCES` varchar(1000) NOT NULL +); + +DROP TABLE IF EXISTS NFVO_SUBSCRIPTION; +CREATE TABLE `NFVO_SUBSCRIPTION` ( + `SUBSCRIPTIONID` varchar(200) NOT NULL PRIMARY KEY, + `CALLBACKURI` longtext NOT NULL, + `AUTHINFO` longtext, + `NOTIFICATIONTYPES` varchar(255), + `OPERATIONTYPES` longtext, + `OPERATIONSTATES` longtext, + `VNFINSTANCEFILTER` longtext, + `LINKS` longtext NOT NULL +); |