summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-08-08 16:00:50 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-08-08 16:00:50 +0800
commit3b75ae19a25647785c81c02129bf12e0ed54e043 (patch)
treec9787d8d0437d35a20b1a5c12aba81c0c80530b9
parent278369e5fa6a7585df69af444c518503aa603740 (diff)
Remove DB and redis service from vnfres
Change-Id: If3b274d442bdde62a225c5fe02116af4f38a0509 Issue-ID: VFC-980 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--res/assembly.xml14
-rwxr-xr-xres/assembly/bin/initDB.sh48
-rw-r--r--res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql29
-rw-r--r--res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql249
-rw-r--r--res/docker/Dockerfile11
-rwxr-xr-xres/docker/docker-entrypoint.sh18
-rwxr-xr-xres/docker/instance_config.sh20
-rwxr-xr-xres/docker/instance_init.sh23
8 files changed, 18 insertions, 394 deletions
diff --git a/res/assembly.xml b/res/assembly.xml
index 7c1b050..f6fe751 100644
--- a/res/assembly.xml
+++ b/res/assembly.xml
@@ -48,20 +48,6 @@
</includes>
</fileSet>
<fileSet>
- <directory>assembly/dbscripts/mysql</directory>
- <outputDirectory>/assembly/dbscripts/mysql</outputDirectory>
- <includes>
- <include>*.sql</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>assembly/bin</directory>
- <outputDirectory>/assembly/bin</outputDirectory>
- <includes>
- <include>*.sh</include>
- </includes>
- </fileSet>
- <fileSet>
<directory>.</directory>
<outputDirectory>/</outputDirectory>
<includes>
diff --git a/res/assembly/bin/initDB.sh b/res/assembly/bin/initDB.sh
deleted file mode 100755
index ec213fd..0000000
--- a/res/assembly/bin/initDB.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2017 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.
-
-DIRNAME=`dirname $0`
-HOME=`cd $DIRNAME/; pwd`
-user=$1
-password=$2
-port=$3
-host=$4
-echo "start create resource management db"
-sql_path=$HOME/../
-mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql
-sql_result=$?
-if [ $sql_result != 0 ] ; then
- echo "failed to create resource management database"
- exit 1
-fi
-fileFlag=*createobj.sql
-location=$sql_path/dbscripts/mysql
-fileName=""
-for i in `ls $location`
-do
- if [[ $i == ${fileFlag} ]];then
- fileName=${i};
- echo "start create table:${fileName}"
- mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/$fileName
- sql_result=$?
- if [ $sql_result != 0 ] ; then
- echo "failed to init resource management table:${fileName}"
- exit 1
- fi
- fi
-done
-echo "init resource management database success!"
-exit 0
diff --git a/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql b/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql
deleted file mode 100644
index d15e63e..0000000
--- a/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createdb.sql
+++ /dev/null
@@ -1,29 +0,0 @@
--- Copyright 2017 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/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql b/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql
deleted file mode 100644
index 66e5a75..0000000
--- a/res/assembly/dbscripts/mysql/onap-gvnfm-vnfres-createobj.sql
+++ /dev/null
@@ -1,249 +0,0 @@
--- Copyright 2017 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),
- `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)
-)
-;
-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
-)
-;
-
-COMMIT;
- \ No newline at end of file
diff --git a/res/docker/Dockerfile b/res/docker/Dockerfile
index b3c3a25..d81d196 100644
--- a/res/docker/Dockerfile
+++ b/res/docker/Dockerfile
@@ -9,9 +9,6 @@ ENV https_proxy $HTTPS_PROXY
RUN sed -i "s|set compatible|set nocompatible|" /etc/vim/vimrc.tiny
RUN echo "set backspace=2" >> /etc/vim/vimrc.tiny
-RUN echo "mysql-server mysql-server/root_password password root" | debconf-set-selections
-RUN echo "mysql-server mysql-server/root_password_again password root" | debconf-set-selections
-
RUN apt-get update && \
apt-get install -y python-virtualenv && \
apt-get install -y python-setuptools && \
@@ -19,8 +16,6 @@ RUN apt-get update && \
apt-get install -y python-pip && \
apt-get install -y gcc && \
apt-get install -y libmysqlclient-dev && \
- apt-get install -y redis-server && \
- apt-get install -y mysql-server && \
apt-get install -y mysql-client && \
apt-get install -y wget && \
apt-get install -y unzip && \
@@ -37,16 +32,10 @@ RUN wget -q -O vfc-gvnfm-vnfres.zip 'https://nexus.onap.org/service/local/artifa
unzip vfc-gvnfm-vnfres.zip && \
rm -rf vfc-gvnfm-vnfres.zip
-RUN sed -i "s|bind-address.*|# bind-address = 127.0.0.1|" /etc/mysql/my.cnf
-
-VOLUME /var/lib/mysql
-
WORKDIR /service/vfc/gvnfm/vnfres/res
RUN pip install -r requirements.txt
EXPOSE 8802
-EXPOSE 3306
-EXPOSE 6379
WORKDIR /service
ENTRYPOINT vfc/gvnfm/vnfres/res/docker/docker-entrypoint.sh
diff --git a/res/docker/docker-entrypoint.sh b/res/docker/docker-entrypoint.sh
index 214ae15..a4caa72 100755
--- a/res/docker/docker-entrypoint.sh
+++ b/res/docker/docker-entrypoint.sh
@@ -5,17 +5,18 @@ if [ -z "$SERVICE_IP" ]; then
fi
echo "SERVICE_IP=$SERVICE_IP"
-if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
- export MYSQL_ROOT_PASSWORD="root"
-fi
-echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD"
-
if [ -z "$MSB_ADDR" ]; then
echo "Missing required variable MSB_ADDR: Microservices Service Bus address <ip>:<port>"
exit 1
fi
echo "MSB_ADDR=$MSB_ADDR"
+if [ -z "$MYSQL_ADDR" ]; then
+ echo "Missing required variable MYSQL_ADDR: <ip>:<port>"
+ exit 1
+fi
+echo "MYSQL_ADDR=$MYSQL_ADDR"
+
# Wait for MSB initialization
echo "Wait for MSB initialization"
for i in {1..5}; do
@@ -23,6 +24,13 @@ for i in {1..5}; do
sleep $i
done
+# Wait for DB initialization
+echo "Wait for DB initialization"
+for i in {1..5}; do
+ curl -sS -m 1 $MYSQL_ADDR > /dev/null && break
+ sleep $i
+done
+
# Configure service based on docker environment variables
vfc/gvnfm/vnfres/res/docker/instance_config.sh
diff --git a/res/docker/instance_config.sh b/res/docker/instance_config.sh
index edf1beb..d6eedbd 100755
--- a/res/docker/instance_config.sh
+++ b/res/docker/instance_config.sh
@@ -15,25 +15,13 @@ if [ $SERVICE_IP ]; then
sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
fi
-if [ $REDIS_HOST ]; then
- sed -i "s|REDIS_HOST.*|REDIS_HOST = '$REDIS_HOST'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
-fi
-
-sed -i "s|DB_NAME.*|DB_NAME = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
-sed -i "s|DB_USER.*|DB_USER = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
-sed -i "s|DB_PASSWD.*|DB_PASSWD = 'gvnfm'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
-
# Configure MYSQL
-if [ -z "$MYSQL_ADDR" ]; then
- export MYSQL_IP=`hostname -i`
- export MYSQL_PORT=3306
- export MYSQL_ADDR=$MYSQL_IP:$MYSQL_PORT
-else
- MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
- MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
-fi
+MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1`
+MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2`
echo "MYSQL_ADDR=$MYSQL_ADDR"
+
sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
+sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/gvnfm/vnfres/res/res/pub/config/config.py
cat vfc/gvnfm/vnfres/res/res/pub/config/config.py
diff --git a/res/docker/instance_init.sh b/res/docker/instance_init.sh
index 11753d9..cfc9b0d 100755
--- a/res/docker/instance_init.sh
+++ b/res/docker/instance_init.sh
@@ -1,23 +1,2 @@
#!/bin/bash
-
-function start_redis_server {
- redis-server &
-}
-
-function start_mysql {
- service mysql start
- sleep 1
-}
-
-function create_database {
- cd /service/vfc/gvnfm/vnfres/res/assembly/bin
- if [ ! -f dbexist.txt ]; then
- echo 1 > dbexist.txt
- bash initDB.sh root $MYSQL_ROOT_PASSWORD 3306 127.0.0.1
- fi
- cd /service
-}
-
-start_redis_server
-start_mysql
-create_database
+echo "No service needs init."