diff options
Diffstat (limited to 'lcm')
-rwxr-xr-x | lcm/docker/instance_config.sh | 4 | ||||
-rwxr-xr-x | lcm/docker/instance_init.sh | 66 | ||||
-rw-r--r-- | lcm/resources/bin/initDB.sh | 39 | ||||
-rw-r--r-- | lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql | 29 | ||||
-rw-r--r-- | lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql | 281 |
5 files changed, 418 insertions, 1 deletions
diff --git a/lcm/docker/instance_config.sh b/lcm/docker/instance_config.sh index 48a157c4..93c6aa8b 100755 --- a/lcm/docker/instance_config.sh +++ b/lcm/docker/instance_config.sh @@ -21,9 +21,13 @@ sed -i "s/127.0.0.1:80/$MSB_IP:$MSB_PORT/" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/c MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` echo "MYSQL_ADDR=$MYSQL_ADDR" +MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1` +MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2` sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py +sed -i "s|DB_USER.*|DB_USER = '$MYSQL_USER'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py +sed -i "s|DB_PASSWD.*|DB_PASSWD = '$MYSQL_ROOT_PASSWORD'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py cat vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py diff --git a/lcm/docker/instance_init.sh b/lcm/docker/instance_init.sh index cfc9b0d5..46a3db07 100755 --- a/lcm/docker/instance_init.sh +++ b/lcm/docker/instance_init.sh @@ -1,2 +1,66 @@ #!/bin/bash -echo "No service needs init." +###### +# by vfc-db test +##### +# echo "No service needs init." +#MYSQL_USER=$1 +###### +#by duan +pip install PyMySQL==0.9.3 +if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log ]; then + mkdir -p /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/ + touch /service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log +else + echo >/service/vfc/gvnfm/vnflcm/lcm/resources/bin/logs/django.log +fi + +if [ ! -f /var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.log ]; then + mkdir -p /var/log/onap/vfc/gvnfm-vnflcm/ + touch /var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.log +else + echo >/var/log/onap/vfc/gvnfm-vnflcm/runtime_lcm.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/gvnfm/vnflcm/lcm/resources/bin + bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP + #DIRNAME=`dirname $0` + #HOME=`cd $DIRNAME/; pwd` + #man_path=$HOME/../ + man_path=/service/vfc/gvnfm/vnflcm/lcm + #tab=`mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "use vfcnfvolcm; select count(*) from vfcnfvolcm;"` + 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='gvnfm';"` + 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='gvnfm';"` + tab3=`echo $tab2|awk '{print $2}'` + if [ $tab3 -gt 0 ] ; then + echo "TABLE CREATE SUCCESSFUL" + fi +else + echo "table already existed" + exit 1 +fi + } + +if [ ! -f /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt ]; then + echo 1 > /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt + echo `pwd` >> /service/vfc/gvnfm/vnflcm/lcm/docker/db.txt + create_database +else + echo "database already existed" +fi diff --git a/lcm/resources/bin/initDB.sh b/lcm/resources/bin/initDB.sh new file mode 100644 index 00000000..8c97edcb --- /dev/null +++ b/lcm/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 gvnfm db" +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" + exit 1 +elif [ $sql_result -eq 0 ]; then + 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 new file mode 100644 index 00000000..79133432 --- /dev/null +++ b/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql @@ -0,0 +1,29 @@ +-- 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 gvnfm; +delete from user where User='gvnfm'; +FLUSH PRIVILEGES; + +/******************create new database and user***************************/ +create database 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; diff --git a/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql b/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql new file mode 100644 index 00000000..5946dd76 --- /dev/null +++ b/lcm/resources/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql @@ -0,0 +1,281 @@ +-- 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 gvnfm; + +CREATE TABLE `NFINST` ( + `NFINSTID` varchar(200) NOT NULL PRIMARY KEY, + `NFNAME` varchar(100), + `VNFMINSTID` varchar(255), + `PACKAGEID` varchar(200), + `STATUS` varchar(20), + `FLAVOURID` varchar(200), + `LOCATION` varchar(200), + `VERSION` varchar(255), + `VENDOR` varchar(255), + `NETYPE` varchar(255), + `VNFDMODEL` longtext, + `INPUTPARAMS` longtext, + `CREATETIME` varchar(200), + `LASTUPTIME` varchar(200), + `VNFINSTANCEDESC` varchar(200), + `VNFDID` varchar(200), + `VNFSOFTWAREVER` varchar(200), + `VNFCONFIGURABLEPROPERTIES` longtext, + `LOCALIZATIONLANGUAGE` varchar(255), + `OPERATIONSTATE` varchar(255), + `RESINFO` longtext, + `VIMINFO` longtext +) +; +CREATE TABLE `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, + `STARTTIME` varchar(255), + `ENDTIME` varchar(255), + `PROGRESS` integer, + `USER` varchar(255), + `PARENTJOBID` varchar(255), + `RESNAME` varchar(255) +) +; +CREATE TABLE `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, + `DESCP` longtext NOT NULL, + `ERRCODE` varchar(255), + `ADDTIME` varchar(255) +) +; +CREATE TABLE `NFVOREGINFO` ( + `NFVOID` varchar(255) NOT NULL PRIMARY KEY, + `VNFMINSTID` varchar(255) NOT NULL, + `URL` varchar(255) NOT NULL, + `USERNAME` varchar(255), + `PASSWD` varchar(255), + `AUTHTYPE` integer NOT NULL, + `CLIENTCERT` varchar(255), + `SERVERCERT` varchar(255), + `REGTIME` varchar(255) NOT NULL +) +; +CREATE TABLE `STORAGEINST` ( + `STORAGEID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `INSTTYPE` integer NOT NULL, + `INSTID` varchar(255) NOT NULL, + `NAME` varchar(255), + `STORAGETYPE` varchar(255) NOT NULL, + `SIZE` varchar(255) NOT NULL, + `TENANT` varchar(50), + `ISPREDEFINED` integer, + `CREATETIME` varchar(200), + `NODEID` varchar(255) +) +; +CREATE TABLE `VMINST` ( + `VMID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar(255) NOT NULL, + `TENANT` varchar(255), + `RESOURCEID` varchar(255) NOT NULL, + `VMNAME` varchar(255) NOT NULL, + `NICARRAY` varchar(255) NOT NULL, + `METADATA` varchar(255) NOT NULL, + `VOLUMEARRAY` varchar(255) NOT NULL, + `SERVERGROUP` varchar(255) NOT NULL, + `AVAILABILITYZONE` varchar(255) NOT NULL, + `FLAVORID` varchar(255) NOT NULL, + `SECURITYGROUPS` varchar(255) NOT NULL, + `OPERATIONALSTATE` varchar(255), + `INSTTYPE` integer NOT NULL, + `ISPREDEFINED` integer, + `CREATETIME` varchar(200), + `INSTID` varchar(255) NOT NULL, + `NODEID` varchar(255) +) +; +CREATE TABLE `VNFCINST` ( + `VNFCINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `VDUID` varchar(255) NOT NULL, + `VDUTYPE` varchar(255) NOT NULL, + `NFINSTID` varchar(255) NOT NULL, + `VMID` varchar(255) NOT NULL, + `ISPREDEFINED` integer +) +; +CREATE TABLE `FLAVOURINST` ( + `FLAVOURID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `NAME` varchar(255) NOT NULL, + `TENANT` varchar(255), + `VCPU` integer, + `MEMORY` integer, + `DISK` integer, + `EPHEMERAL` integer, + `SWAP` integer, + `ISPUBLIC` integer, + `EXTRASPECS` varchar(255) NOT NULL, + `INSTID` varchar(255) NOT NULL, + `CREATETIME` varchar(200), + `ISPREDEFINED` integer +) +; +CREATE TABLE `NETWORKINST` ( + `NETWORKID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `INSTTYPE` integer NOT NULL, + `INSTID` varchar(255) NOT NULL, + `NAME` varchar(255) NOT NULL, + `TENANT` varchar(255), + `ISPREDEFINED` integer, + `DESC` varchar(255), + `VENDOR` varchar(255), + `BANDWIDTH` integer, + `MTU` integer, + `NETWORKTYPE` varchar(255), + `SEGMENTID` varchar(255), + `NETWORKQOS` varchar(255), + `CREATETIME` varchar(200), + `PHYNETWORK` varchar(255), + `ISSHARED` integer, + `VLANTRANS` integer, + `ROUTEREXTERNAL` integer, + `NODEID` varchar(255) +) +; +CREATE TABLE `SUBNETWORKINST` ( + `SUBNETWORKID` varchar(255) NOT NULL PRIMARY KEY, + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `NETWORKID` varchar(255) NOT NULL, + `INSTTYPE` integer NOT NULL, + `INSTID` varchar(255) NOT NULL, + `NAME` varchar(255) NOT NULL, + `IPVERSION` integer, + `GATEWAYIP` varchar(255), + `ISDHCPENABLED` integer, + `CIDR` varchar(255) NOT NULL, + `VDSNAME` varchar(255), + `OPERATIONALSTATE` varchar(255), + `TENANT` varchar(255), + `ISPREDEFINED` integer, + `CREATETIME` varchar(200), + `DNSNAMESERVERS` longtext NOT NULL, + `HOSTROUTES` longtext NOT NULL, + `ALLOCATIONPOOLS` longtext NOT NULL +) +; +CREATE TABLE `VLINST` ( + `VLINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `VLDID` varchar(255) NOT NULL, + `VLINSTANCENAME` varchar(255), + `OWNERTYPE` integer NOT NULL, + `OWNERID` varchar(255) NOT NULL, + `RELATEDNETWORKID` varchar(255), + `RELATEDSUBNETWORKID` varchar(255), + `VLTYPE` integer NOT NULL, + `VIMID` varchar(255) NOT NULL, + `TENANT` varchar(50) NOT NULL +) +; +CREATE TABLE `PORTINST` ( + `PORTID` varchar(255) NOT NULL PRIMARY KEY, + `NETWORKID` varchar(255) NOT NULL, + `SUBNETWORKID` varchar(255), + `VIMID` varchar(255) NOT NULL, + `RESOURCEID` varchar(255) NOT NULL, + `NAME` varchar(255), + `INSTTYPE` integer NOT NULL, + `INSTID` varchar(255) NOT NULL, + `CPINSTANCEID` varchar(255), + `BANDWIDTH` varchar(255), + `OPERATIONALSTATE` varchar(255), + `IPADDRESS` varchar(255) NOT NULL, + `MACADDRESS` varchar(255) NOT NULL, + `NICORDER` varchar(255) NOT NULL, + `FLOATIPADDRESS` varchar(255), + `SERVICEIPADDRESS` varchar(255), + `TYPEVIRTUALNIC` varchar(255), + `SFCENCAPSULATION` varchar(255), + `DIRECTION` varchar(255), + `TENANT` varchar(255), + `INTERFACENAME` varchar(255), + `VMID` varchar(255), + `CREATETIME` varchar(200), + `SECURITYGROUPS` varchar(255) NOT NULL, + `ISPREDEFINED` integer, + `NODEID` varchar(255) +) +; +CREATE TABLE `CPINST` ( + `CPINSTANCEID` varchar(255) NOT NULL PRIMARY KEY, + `CPDID` varchar(255) NOT NULL, + `CPINSTANCENAME` varchar(255) NOT NULL, + `VLINSTANCEID` varchar(255) NOT NULL, + `OWNERTYPE` integer NOT NULL, + `OWNERID` varchar(255) NOT NULL, + `RELATEDTYPE` integer NOT NULL, + `RELATEDVL` varchar(255), + `RELATEDCP` varchar(255), + `RELATEDPORT` varchar(255) +) +; +CREATE TABLE `VNF_REG` ( + `ID` varchar(200) NOT NULL PRIMARY KEY, + `IP` varchar(200) NOT NULL, + `PORT` varchar(200) NOT NULL, + `USERNAME` varchar(255) NOT NULL, + `PASSWORD` varchar(255) NOT NULL +) +; +CREATE TABLE `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 +) +; +CREATE TABLE `VNFLCMOPOCCS` ( + `ID` varchar(255) NOT NULL PRIMARY KEY, + `OPERATIONSTATE` varchar(30) NOT NULL, + `STATEENTEREDTIME` varchar(30) NOT NULL, + `STARTTIME` varchar(30) NOT NULL, + `VNFINSTANCEID` varchar(255) NOT NULL, + `GRANTID` varchar(255), + `OPERATION` varchar(30) NOT NULL, + `ISAUTOMATICINVOCATION` varchar(5) NOT NULL, + `OPERATIONPARAMS` longtext NOT NULL, + `ISCANCELPENDING` varchar(5) NOT NULL, + `CANCELMODE` varchar(255), + `ERROR` longtext, + `RESOURCECHANGES` longtext, + `CHANGEDINFO` longtext, + `CHANGEDEXTCONNECTIVITY` longtext, + `LINKS` longtext NOT NULL +) +; +COMMIT; |