diff options
author | Michael Lando <ml636r@att.com> | 2017-02-19 10:28:42 +0200 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-02-19 10:51:01 +0200 |
commit | 451a3400b76511393c62a444f588a4ed15f4a549 (patch) | |
tree | e4f5873a863d1d3e55618eab48b83262f874719d /sdc-os-chef/scripts | |
parent | 5abfe4e1fb5fae4bbd5fbc340519f52075aff3ff (diff) |
Initial OpenECOMP SDC commit
Change-Id: I0924d5a6ae9cdc161ae17c68d3689a30d10f407b
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'sdc-os-chef/scripts')
-rw-r--r-- | sdc-os-chef/scripts/docker_clean.sh | 6 | ||||
-rw-r--r-- | sdc-os-chef/scripts/docker_health.sh | 22 | ||||
-rw-r--r-- | sdc-os-chef/scripts/docker_login.sh | 8 | ||||
-rw-r--r-- | sdc-os-chef/scripts/docker_run.sh | 128 | ||||
-rw-r--r-- | sdc-os-chef/scripts/docker_stats.sh | 36 | ||||
-rw-r--r-- | sdc-os-chef/scripts/docker_watchdog.sh | 43 | ||||
-rw-r--r-- | sdc-os-chef/scripts/restart_docker.sh | 97 |
7 files changed, 340 insertions, 0 deletions
diff --git a/sdc-os-chef/scripts/docker_clean.sh b/sdc-os-chef/scripts/docker_clean.sh new file mode 100644 index 0000000000..0b2227d45a --- /dev/null +++ b/sdc-os-chef/scripts/docker_clean.sh @@ -0,0 +1,6 @@ +pat=$1 +docker_ids=`docker ps -a | grep ${pat} | awk '{print $1}'` +for X in ${docker_ids} +do + docker rm -f ${X} +done diff --git a/sdc-os-chef/scripts/docker_health.sh b/sdc-os-chef/scripts/docker_health.sh new file mode 100644 index 0000000000..6fdf826084 --- /dev/null +++ b/sdc-os-chef/scripts/docker_health.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +curl localhost:9200/_cluster/health?pretty=true + +echo "BE health-Check:" +curl http://localhost:8080/sdc2/rest/healthCheck + +echo "" +echo "" +echo "FE health-Check:" +curl http://localhost:8181/sdc1/rest/healthCheck + + +echo "" +echo "" +res=`curl -s -X GET -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" "http://localhost:8080/sdc2/rest/v1/user/demo" | wc -l` +if [[ ${res} != 0 ]] +then + echo "Error [${res}] while user existance check" + exit ${res} +fi +echo "check user existance: OK" diff --git a/sdc-os-chef/scripts/docker_login.sh b/sdc-os-chef/scripts/docker_login.sh new file mode 100644 index 0000000000..15544f4d24 --- /dev/null +++ b/sdc-os-chef/scripts/docker_login.sh @@ -0,0 +1,8 @@ +pat=$1 +docker_ids=`docker ps | grep ${pat} | awk '{print $1}'|head -1` +if [ -z "$docker_ids" ]; then + echo "No dockers were found matching pattern [${pat}]" + exit 0 +else + docker exec -it ${docker_ids} bash +fi diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh new file mode 100644 index 0000000000..1b3f370d27 --- /dev/null +++ b/sdc-os-chef/scripts/docker_run.sh @@ -0,0 +1,128 @@ +#!/bin/bash + + +function usage +{ + echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]" +} + + +RELEASE=1.0.0-SNAPSHOT +[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ +PORT=51212 + +while [ "$1" != "" ]; do + case $1 in + -r | --release ) + shift + RELEASE=${1} + ;; + -e | --environment ) + shift + DEP_ENV=${1} + ;; + -p | --port ) + shift + PORT=${1} + ;; + -h | --help ) + usage + exit + ;; + * ) + usage + exit 1 + esac + shift +done + +[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release +[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW +[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT} + +[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO + + +# cleanup +echo "performing old dockers cleanup" +docker_ids=`docker ps -a | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'` +for X in ${docker_ids} +do + docker rm -f ${X} +done + +export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` + +echo "" + +# Elastic-Search +echo "docker run sdc-elasticsearch..." +docker pull ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} +docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 1g --memory-swap=1g --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro -e ES_HEAP_SIZE=1024M --volume /data/ES:/usr/share/elasticsearch/data --volume /data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} + + +# cassandra +echo "docker run sdc-cassandra..." +docker pull ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} +docker run --detach --name sdc-cs --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/CS:/var/lib/cassandra --volume /data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} + + +echo "please wait while CS is starting..." +echo "" +c=25 # seconds to wait +REWRITE="\e[25D\e[1A\e[K" +while [ $c -gt 0 ]; do + c=$((c-1)) + sleep 1 + echo -e "${REWRITE}$c" +done +echo -e "" + + +# kibana +echo "docker run sdc-kibana..." +docker pull ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} +docker run --detach --name sdc-kbn --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/environments:/root/chef-solo/environments --publish 5601:5601 ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} + + +# Back-End +echo "docker run sdc-backend..." +docker pull ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} +docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 4g --memory-swap=4g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/BE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} + +echo "please wait while BE is starting..." +echo "" +c=45 # seconds to wait +REWRITE="\e[45D\e[1A\e[K" +while [ $c -gt 0 ]; do + c=$((c-1)) + sleep 1 + echo -e "${REWRITE}$c" +done +echo -e "" + + +# Front-End +echo "docker run sdc-frontend..." +docker pull ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} +docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/FE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} + + + +# running healthCheck scripts +echo "Running health checks, please wait..." +echo "" +c=25 # seconds to wait +REWRITE="\e[45D\e[1A\e[K" +while [ $c -gt 0 ]; do + c=$((c-1)) + sleep 1 + echo -e "${REWRITE}$c" +done +echo -e "" + +/data/scripts/docker_health.sh + +if [ $? -ne 0 ]; then + exit 1 +fi diff --git a/sdc-os-chef/scripts/docker_stats.sh b/sdc-os-chef/scripts/docker_stats.sh new file mode 100644 index 0000000000..9258b3471d --- /dev/null +++ b/sdc-os-chef/scripts/docker_stats.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +FILE='/data/logs/docker_stats.out' +FE_ID=`docker ps|grep sdc-front|awk '{print $1}'` +BE_ID=`docker ps|grep sdc-back |awk '{print $1}'` + +echo `date` >> ${FILE} + +if [ ! -z "${FE_ID}" ]; then + docker stats ${FE_ID} --no-stream >> /data/logs/docker_stats.out +else + echo "frontend Docker is down!!!" >> /data/logs/docker_stats.out +fi + +if [ ! -z "${BE_ID}" ]; then + docker stats ${BE_ID} --no-stream >> /data/logs/docker_stats.out +else + echo "backend Docker is down!!!" >> /data/logs/docker_stats.out +fi + +echo "------------------------------------------" >> ${FILE} + +grep -v "^\-" ${FILE} |grep -v ^CONT| awk 'BEGIN { + split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",month) + for (i in month) { + month_nums[month[i]]=i + } +} +/UTC/ { + d=$6"-"$2"-"substr("00",0,2-length($3))$3"-"substr($4,0,5) + next +} +/GiB/ { + print $1" "d" "$3" "$8 + next +}' > `echo ${FILE}|awk -F"." '{ print $1".csv"}'` diff --git a/sdc-os-chef/scripts/docker_watchdog.sh b/sdc-os-chef/scripts/docker_watchdog.sh new file mode 100644 index 0000000000..cc8452537b --- /dev/null +++ b/sdc-os-chef/scripts/docker_watchdog.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +if [ $# -eq 0 ]; then + echo "No arguments supplied" + exit 1 +fi + + +RELEASE=$1 +DEP_ENV=$2 + + +docker_ids=`docker ps -a | egrep "Exit" | awk '{print $1}'` +for X in ${docker_ids} +do + docker rm -f ${X} +done + +export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` + +echo "" + +# Back-End +my_cnt=`docker ps|egrep -c "sdc-backend:${RELEASE}"` +if [ "${my_cnt}" -eq "1" ]; then +# echo "`date` - BE is running" >> /data/ASDC/logs/watchdog.log + echo "`date` - BE is running" > /dev/null +else + echo "`date` - BE was down" >> /data/ASDC/logs/watchdog.log + docker pull ecomp-nexus:51212/ecomp/sdc-backend:${RELEASE} + docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 3g --memory-swap=3g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/ASDC/logs/BE/:/var/lib/jetty/logs --volume /data/ASDC/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ecomp-nexus:51212/ecomp/sdc-backend:${RELEASE} +fi + +# Front-End +my_cnt=`docker ps|egrep -c "sdc-frontend:${RELEASE}"` +if [ "${my_cnt}" -eq "1" ]; then +# echo "`date` - FE is running" >> /data/ASDC/logs/watchdog.log + echo "`date` - FE is running" >> /dev/null +else + echo "`date` - FE was down" >> /data/ASDC/logs/watchdog.log + docker pull ecomp-nexus:51212/ecomp/sdc-frontend:${RELEASE} + docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/ASDC/logs/FE/:/var/lib/jetty/logs --volume /data/ASDC/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ecomp-nexus:51212/ecomp/sdc-frontend:${RELEASE} +fi diff --git a/sdc-os-chef/scripts/restart_docker.sh b/sdc-os-chef/scripts/restart_docker.sh new file mode 100644 index 0000000000..619f51af5c --- /dev/null +++ b/sdc-os-chef/scripts/restart_docker.sh @@ -0,0 +1,97 @@ +#!/bin/bash + + +function usage +{ + echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]" +} + + +RELEASE=__SDC-RELEASE__ +[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ +PORT=51212 + +while [ "$1" != "" ]; do + case $1 in + -d | --docker ) + shift + DOCKER=${1} + ;; + -r | --release ) + shift + RELEASE=${1} + ;; + -e | --environment ) + shift + DEP_ENV=${1} + ;; + -p | --port ) + shift + PORT=${1} + ;; + -h | --help ) + usage + exit + ;; + * ) + usage + exit 1 + esac + shift +done + +[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release +[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW +[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT} + +[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO + + +# cleanup +echo "performing old dockers cleanup" +docker_ids=`docker ps -a | egrep "${DOCKER}|Exit" | awk '{print $1}'` +for X in ${docker_ids} +do + docker rm -f ${X} +done + +export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` + +echo "" + +case ${DOCKER} in + elastic | es ) + # Elastic-Search + echo "docker run sdc-elasticsearch..." + docker pull ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} + docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 1g --memory-swap=1g --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro -e ES_HEAP_SIZE=1024M --volume /data/ES:/usr/share/elasticsearch/data --volume /data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ecomp-nexus:${PORT}/ecomp/sdc-elasticsearch:${RELEASE} + ;; + + cassandra | cs ) + # cassandra + echo "docker run sdc-cassandra..." + docker pull ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} + docker run --detach --name sdc-cs --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/CS:/var/lib/cassandra --volume /data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ecomp-nexus:${PORT}/ecomp/sdc-cassandra:${RELEASE} + ;; + + kibana | kbn ) + # kibana + echo "docker run sdc-kibana..." + docker pull ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} + docker run --detach --name sdc-kbn --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 1g --memory-swap=1g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/environments:/root/chef-solo/environments --publish 5601:5601 ecomp-nexus:${PORT}/ecomp/sdc-kibana:${RELEASE} + ;; + + backend | be ) + # Back-End + echo "docker run sdc-backend..." + docker pull ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} + docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 4g --memory-swap=4g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/BE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ecomp-nexus:${PORT}/ecomp/sdc-backend:${RELEASE} + ;; + + frontend | fe ) + # Front-End + echo "docker run sdc-frontend..." + docker pull ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} + docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 2g --memory-swap=2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/FE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ecomp-nexus:${PORT}/ecomp/sdc-frontend:${RELEASE} + ;; +esac |