From bd838e7a4830217d3d0483067671dcb03965ece3 Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Mon, 16 Apr 2018 21:27:17 -0400 Subject: Fix docker script as healthcheck etc 1. fix docker script as healthcheck for service change handler 2. improve docker compose blocks for stretch goal container 3. fix instaling plugins to cloudify manager 4. add one more plugin to build/upload: dockerplugin. Issue-ID: DCAEGEN2-434 Change-Id: I997d8564fe0ee0cf5a013b042eb6c0e9fb331276 Signed-off-by: Lusheng Ji --- heat/build-plugins.sh | 75 -------------------------------- heat/docker-compose-3.yaml | 2 +- heat/docker-compose-4.yaml | 56 ++++++++++++++---------- heat/setup.sh | 55 ++++++++++++++++++----- k8s-bootstrap-container/build-plugins.sh | 3 +- 5 files changed, 80 insertions(+), 111 deletions(-) delete mode 100755 heat/build-plugins.sh diff --git a/heat/build-plugins.sh b/heat/build-plugins.sh deleted file mode 100755 index 812ae19..0000000 --- a/heat/build-plugins.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# 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. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. - -# Pull plugin archives from repos -# Build wagons -# $1 is the DCAE repo URL -# $2 is the CCSDK repo URL -# (This script runs at Docker image build time) -# -set -x -DEST=wagons - -# For DCAE, we get zips of the archives and build wagons -DCAEPLUGINFILES=\ -"\ -k8splugin/1.0.1/k8splugin-1.0.1.tgz -dcaepolicyplugin/2.2.1/dcaepolicyplugin-2.2.1.tgz \ -" - -# For CCSDK, we pull down the wagon files directly -CCSDKPLUGINFILES=\ -"\ -plugins/pgaas-1.1.0-py27-none-any.wgn -plugins/sshkeyshare-1.0.0-py27-none-any.wgn -" - -# Build a set of wagon files from archives in a repo -# $1 -- repo base URL -# $2 -- list of paths to archive files in the repo -function build { - for plugin in $2 - do - # Could just do wagon create with the archive URL as source, - # but can't use a requirements file with that approach - mkdir work - target=$(basename ${plugin}) - curl -Ss $1/${plugin} > ${target} - tar zxvf ${target} --strip-components=2 -C work - wagon create -t tar.gz -o ${DEST} -r work/requirements.txt --validate ./work - rm -rf work - done -} - -# Copy a set of wagons from a repo -# $1 -- repo baseURL -# $2 -- list of paths to wagons in the repo -function get_wagons { - for wagon in $2 - do - target=$(basename ${wagon}) - curl -Ss $1/${wagon} > ${DEST}/${target} - done -} - -mkdir ${DEST} -build $1 "${DCAEPLUGINFILES}" -get_wagons $2 "${CCSDKPLUGINFILES}" diff --git a/heat/docker-compose-3.yaml b/heat/docker-compose-3.yaml index 870c25e..f6c9212 100644 --- a/heat/docker-compose-3.yaml +++ b/heat/docker-compose-3.yaml @@ -29,7 +29,7 @@ services: - "POSTGRES_PASSWORD=inventorypwd" labels: - "SERVICE_NAME=service_change_handler" - - "SERVICE_CHECK_SCRIPT=/opt/health.sh" + - "SERVICE_CHECK_DOCKER_SCRIPT=/opt/health.sh" - "SERVICE_CHECK_INTERVAL=15s" - "SERVICE_CHECK_INITIAL_STATUS=passing" diff --git a/heat/docker-compose-4.yaml b/heat/docker-compose-4.yaml index f132ea9..0bfa0e5 100644 --- a/heat/docker-compose-4.yaml +++ b/heat/docker-compose-4.yaml @@ -2,19 +2,22 @@ version: '2.1' services: heartbeat: image: "{{ nexus_docker_repo}}/onap/org.onap.dcaegen2.platform.heartbeat:{{ dcae_docker_heartbeat }}" - - #image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.heartbeat:latest - container_name: heartbeat - hostname: heartbeat + container_name: static-dcaegen2-services-heartbeat + hostname: static-dcaegen2-services-heartbeat environment: - - CONSUL_HOST=consul - - CONSUL_PORT=8500 - - HOSTNAME= + - "DMAAPHOST={{ mr_ip_addr }}" + - "CONSUL_HOST=consul" + - "CONSUL_PORT=8500" + - "CONFIG_BINDING_SERVICE=config_binding_service" + - "SERVICE_NAME=static-dcaegen2-services-heartbeat" + - "HOSTNAME=static-dcaegen2-services-heartbeat" ports: - - "1003:1003" + - "10001:10000" labels: - - SERVICE_NAME=static-dcaegen2-services-heartbeat - - SERVICE_CHECK_INITIAL_STATUS=passing + - "SERVICE_NAME=static-dcaegen2-services-heartbeat" + - "SERVICE_CHECK_DOCKER_SCRIPT=/app/bin/check_health.py" + - "SERVICE_CHECK_INTERVAL=15s" + - "SERVICE_CHECK_INITIAL_STATUS=passing" prh: @@ -22,28 +25,35 @@ services: container_name: prh hostname: prh environment: - - CONSUL_HOST=consul - - CONSUL_PORT=8500 - - HOSTNAME= + - "DMAAPHOST={{ mr_ip_addr }}" + - "CONSUL_HOST=consul" + - "CONSUL_PORT=8500" + - "CONFIG_BINDING_SERVICE=config_binding_service" + - "SERVICE_NAME=static-dcaegen2-services-prh" + - "HOSTNAME=static-dcaegen2-services-prh" ports: - - "1002:1002" + - "8100:8100" labels: - - SERVICE_NAME=static-dcaegen2-services-prh-prh-app-server - - SERVICE_CHECK_INITIAL_STATUS=passing + - "SERVICE_8100_NAME=static-dcaegen2-services-prh" + - "SERVICE_8100_CHECK_TCP=true" + - "SERVICE_8100_CHECK_INTERVAL=15s" + - "SERVICE_8100_CHECK_INITIAL_STATUS=passing" snmptrap: - image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.snmptrap:latest image: "{{ nexus_docker_repo}}/onap/org.onap.dcaegen2.collectors.snmptrap:{{ dcae_docker_snmptrap }}" - container_name: snmptrap - hostname: snmptrap + container_name: static-dcaegen2-collectors-snmptrap + hostname: static-dcaegen2-collectors-snmptrap environment: - - CONSUL_HOST=consul - - CONSUL_PORT=8500 - - HOSTNAME= + - "DMAAPHOST={{ mr_ip_addr }}" + - "CONSUL_HOST=consul" + - "CONSUL_PORT=8500" + - "CONFIG_BINDING_SERVICE=config_binding_service" + - "SERVICE_NAME=static-dcaegen2-collectors-snmptrap" + - "HOSTNAME=static-dcaegen2-collectors-snmptrap" ports: - "162:162/udp" labels: - - SERVICE_NAME=static-dcaegen2-collectors-snamptrap + - SERVICE_NAME=static-dcaegen2-collectors-snmptrap - SERVICE_CHECK_INITIAL_STATUS=passing diff --git a/heat/setup.sh b/heat/setup.sh index c11c062..22f4bb0 100755 --- a/heat/setup.sh +++ b/heat/setup.sh @@ -1,4 +1,20 @@ #!/bin/bash +############################################################################# +# +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# +# 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. +# +############################################################################# NETWORK="config_default" @@ -16,12 +32,33 @@ docker run -d \ -v /var/run/docker.sock:/tmp/docker.sock \ onapdcae/registrator:v7 -echo "Launching Cloudify Manager" + + + +rm -rf scripts-in-container +mkdir scripts-in-container +cat > scripts-in-container/install-plugins.sh << EOL +#!/bin/bash +source /cfy42/bin/activate +pip install pip==9.0.3 +cfy profiles use 127.0.0.1 -u admin -p admin -t default_tenant +cfy status +cd /tmp/bin +./build-plugins.sh https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2 https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/releases +for wagon in ./wagons/*.wgn; do cfy plugins upload \$wagon ; done +deactivate +EOL + +wget -O scripts-in-container/build-plugins.sh https://git.onap.org/dcaegen2/deployments/plain/k8s-bootstrap-container/build-plugins.sh +chmod 777 scripts-in-container/* + +echo "Launching Cloudify Manager container" docker run -d \ --network="${NETWORK}" \ --name cloudify-manager \ --restart unless-stopped \ -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ +-v /opt/app/config/scripts-in-container:/tmp/bin \ -p 80:80 \ --tmpfs /run \ --tmpfs /run/lock \ @@ -31,18 +68,14 @@ docker run -d \ --label "SERVICE_80_CHECK_TCP=true" \ --label "SERVICE_80_CHECK_INTERVAL=15s" \ --label "SERVICE_80_CHECK_INITIAL_STATUS=passing" \ -{{i nexus_docker_repo }}/onap/org.onap.dcaegen2.deployments.cm-container:{{ dcae_docker_cm }} -echo "Cloudify Manager deployed, waiting for completion" +{{ nexus_docker_repo }}/onap/org.onap.dcaegen2.deployments.cm-container:{{ dcae_docker_cm }} + +echo "Cloudify Manager deployed, waiting for completion" while ! nc -z localhost 80; do sleep 1; done -echo "configure Cloudify Manager" -#8080, 5432 ports occupied -pip install cloudify==4.2 -cfy profiles use 127.0.0.1 -u admin -p admin -t default_tenant -cfy status +echo "Upload plugins to Cloudify Manager" -./build-plugins.sh https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2 https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/plugins/releases +docker exec -it cloudify-manager /tmp/bin/install-plugins.sh -for wagon in ./wagons/*.wgn; do cfy plugins upload ${wagon}; done +echo "Cloudify Manager setup complete" -echo "Setup complete" diff --git a/k8s-bootstrap-container/build-plugins.sh b/k8s-bootstrap-container/build-plugins.sh index ad98b24..ed7428c 100755 --- a/k8s-bootstrap-container/build-plugins.sh +++ b/k8s-bootstrap-container/build-plugins.sh @@ -32,6 +32,7 @@ DEST=wagons DCAEPLUGINFILES=\ "\ k8splugin/1.0.1/k8splugin-1.0.1.tgz +dockerplugin/3.2.0/dockerplugin-3.2.0.tgz dcaepolicyplugin/2.2.1/dcaepolicyplugin-2.2.1.tgz \ " @@ -72,4 +73,4 @@ function get_wagons { mkdir ${DEST} build $1 "${DCAEPLUGINFILES}" -get_wagons $2 "${CCSDKPLUGINFILES}" \ No newline at end of file +get_wagons $2 "${CCSDKPLUGINFILES}" -- cgit 1.2.3-korg