diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-08 15:13:25 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-08 15:13:25 +0800 |
commit | be8a3ac8d84b2bffd32d5d5e5f2609706e93d33d (patch) | |
tree | 5280f77cc1821cd054c6248191a7be0b49d61060 /lcm | |
parent | 5e0b0a3a63ce9c70b3486cd6e5cd38e072f7c3e0 (diff) |
Remove DB and redis service from vnflcm
Change-Id: I83f9bc8b0ccaaaad1f04a9590c1bfba43ce5be51
Issue-ID: VFC-979
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rwxr-xr-x | lcm/docker/Dockerfile | 18 | ||||
-rwxr-xr-x | lcm/docker/docker-entrypoint.sh | 18 | ||||
-rwxr-xr-x | lcm/docker/instance_config.sh | 16 | ||||
-rwxr-xr-x | lcm/docker/instance_init.sh | 23 |
4 files changed, 18 insertions, 57 deletions
diff --git a/lcm/docker/Dockerfile b/lcm/docker/Dockerfile index 61ad7815..cf1e0844 100755 --- a/lcm/docker/Dockerfile +++ b/lcm/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,23 +32,10 @@ RUN wget -q -O vfc-gvnfm-vnflcm-lcm.zip 'https://nexus.onap.org/service/local/ar unzip vfc-gvnfm-vnflcm-lcm.zip && \ rm -rf vfc-gvnfm-vnflcm-lcm.zip -# get db scripts from nexus -RUN wget -q -O vfc-gvnfm-vnfres-res.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.gvnfm.vnfres.res&a=vfc-gvnfm-vnfres-res&v=LATEST&e=zip' && \ - unzip vfc-gvnfm-vnfres-res.zip vfc/gvnfm/vnfres/res/assembly/*.* && \ - mv ./vfc/gvnfm/vnfres/res/assembly/bin ./bin && \ - mv ./vfc/gvnfm/vnfres/res/assembly/dbscripts ./dbscripts && \ - rm -rf vfc-gvnfm-vnfres-res.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/vnflcm/lcm RUN pip install -r requirements.txt EXPOSE 8801 -EXPOSE 3306 -EXPOSE 6379 WORKDIR /service ENTRYPOINT vfc/gvnfm/vnflcm/lcm/docker/docker-entrypoint.sh diff --git a/lcm/docker/docker-entrypoint.sh b/lcm/docker/docker-entrypoint.sh index aa475feb..ed413828 100755 --- a/lcm/docker/docker-entrypoint.sh +++ b/lcm/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/vnflcm/lcm/docker/instance_config.sh diff --git a/lcm/docker/instance_config.sh b/lcm/docker/instance_config.sh index e5d92279..48a157c4 100755 --- a/lcm/docker/instance_config.sh +++ b/lcm/docker/instance_config.sh @@ -11,10 +11,6 @@ if [ $MSB_PORT ]; then sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py fi -sed -i "s|DB_NAME.*|DB_NAME = 'gvnfm'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py -sed -i "s|DB_USER.*|DB_USER = 'gvnfm'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py -sed -i "s|DB_PASSWD.*|DB_PASSWD = 'gvnfm'|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py - if [ $SERVICE_IP ]; then sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" vfc/gvnfm/vnflcm/lcm/lcm/pub/config/config.py fi @@ -22,16 +18,12 @@ fi sed -i "s/127.0.0.1:80/$MSB_IP:$MSB_PORT/" vfc/gvnfm/vnflcm/lcm/lcm/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/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 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 2764a07a..cfc9b0d5 100755 --- a/lcm/docker/instance_init.sh +++ b/lcm/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/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." |