diff options
Diffstat (limited to 'dovetail/utils/local_db/launch_db.sh')
-rwxr-xr-x | dovetail/utils/local_db/launch_db.sh | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/dovetail/utils/local_db/launch_db.sh b/dovetail/utils/local_db/launch_db.sh index 722dc227..956ccfe8 100755 --- a/dovetail/utils/local_db/launch_db.sh +++ b/dovetail/utils/local_db/launch_db.sh @@ -8,20 +8,23 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -if [ "$#" -ne 1 ]; then +if [ "$#" -ne 2 ]; then echo "Error: missing parameter! try again like this:" echo "" - echo "./launch_db.sh 192.168.115.2" + echo "./launch_db.sh 192.168.115.2 http://116.66.187.136:9999" echo "" echo "parameters:" - echo " db_host_ip: your localhost ip address " + echo " host_ip: your localhost ip address " + echo " base_url: your public url for website" echo "" exit 1 fi export mongodb_port=${mongodb_port:-"27017"} -export testapi_port=${testapi_port:-"8000"} +export testapi_port=${testapi_port:-"8010"} export db_host_ip=${db_host_ip:-"$1"} +export base_url=${base_url:-"$2"} + set -e @@ -47,7 +50,7 @@ fi # run mongodb container echo "Step3: run ${container_name} container." -cmd="sudo docker run -itd -p ${mongodb_port}:27017 --name ${container_name} ${mongodb_img}" +cmd="sudo docker run -itd -p ${mongodb_port}:27017 -v /home/testapi/mongo:/data/db --name ${container_name} ${mongodb_img}" echo $cmd ${cmd} @@ -59,8 +62,7 @@ echo "Create the testapi service." echo "==========================" set +e -# pull image opnfv/testapi:cvp.0.3.0 -testapi_img="opnfv/testapi:cvp.0.3.0" +testapi_img="opnfv/testapi:cvp.0.5.0" echo "Step1: pull the image $testapi_img." sudo docker pull $testapi_img set -e @@ -76,20 +78,46 @@ fi # run testapi container echo "Step3: run ${container_name} container." -cmd="sudo docker run -itd -p ${testapi_port}:8000 --name ${container_name} -e mongodb_url=mongodb://${db_host_ip}:${mongodb_port}/ ${testapi_img}" +cmd="sudo docker run -itd -p 8010:8010 --name ${container_name} -v /home/testapi/logs:/home/testapi/logs -e mongodb_url=mongodb://${db_host_ip}:${mongodb_port}/ -e base_url=${base_url} ${testapi_img}" echo $cmd ${cmd} echo "Wait for testapi to work..." sleep 10 +set +e +nginx_img="opnfv/dovetail:nginx.cvp.0.5.0" +echo "Step1: pull the image $nginx_img." +sudo docker pull $nginx_img +set -e + +container_name='nginx_cvp' + +echo "Step2: remove the exist container with the same name '$container_name' if exists." +sudo docker ps -a -f "name=${container_name}" + +if [[ ! -z $(sudo docker ps -aq -f "name=${container_name}") ]]; then + sudo docker ps -aq -f "name=${container_name}" | xargs sudo docker rm -f +fi + +# run nginx container +echo "Step3: run ${container_name} container." +cmd="sudo docker run -itd -p 8000:8000 -v /home/testapi/logs:/home/testapi/logs --name ${container_name} -e testapi_url=${db_host_ip}:8010 ${nginx_img}" +echo $cmd +${cmd} + echo "=================================" echo "Upload default project info to DB" echo "=================================" echo "Init DB info..." -cmd="python ./init_db.py ${db_host_ip} ${testapi_port}" -echo ${cmd} +cmd="python ./init_db.py ${db_host_ip} 8010" +echo $cmd +${cmd} + +echo "Init dovetail testcase" +cmd="python ./init_dovetail.py ${base_url}/api/v1" +echo $cmd ${cmd} echo "Successfully load DB info." |