Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 2 | ############################################################################# |
| 3 | # |
| 4 | # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | ############################################################################# |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 18 | |
| 19 | |
| 20 | NETWORK="config_default" |
| 21 | |
| 22 | echo "Cleaning up any previously deployed cludify manager and registrator" |
| 23 | docker stop registrator cloudify-manager |
| 24 | docker rm registrator cloudify-manager |
| 25 | |
| 26 | echo "Launching registrator on dockerhost" |
| 27 | docker run -d \ |
| 28 | --network=${NETWORK} \ |
| 29 | --name=registrator \ |
| 30 | -e EXTERNAL_IP={{ dcae_ip_addr }} \ |
| 31 | -e CONSUL_HOST=consul \ |
| 32 | -v /var/run/docker.sock:/tmp/docker.sock \ |
| 33 | onapdcae/registrator:v7 |
| 34 | |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 35 | |
| 36 | |
| 37 | |
| 38 | rm -rf scripts-in-container |
| 39 | mkdir scripts-in-container |
| 40 | cat > scripts-in-container/install-plugins.sh << EOL |
| 41 | #!/bin/bash |
| 42 | source /cfy42/bin/activate |
| 43 | pip install pip==9.0.3 |
| 44 | cfy profiles use 127.0.0.1 -u admin -p admin -t default_tenant |
| 45 | cfy status |
| 46 | cd /tmp/bin |
Lusheng Ji | a253c17 | 2018-07-16 23:28:49 -0400 | [diff] [blame] | 47 | ./build-plugins.sh https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R3 https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/releases |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 48 | for wagon in ./wagons/*.wgn; do cfy plugins upload \$wagon ; done |
| 49 | deactivate |
| 50 | EOL |
| 51 | |
Vijay Venkatesh Kumar | b654b73 | 2018-10-08 14:15:06 +0000 | [diff] [blame^] | 52 | #wget -O scripts-in-container/build-plugins.sh https://git.onap.org/dcaegen2/deployments/plain/k8s-bootstrap-container/build-plugins.sh |
| 53 | cat > scripts-in-container/build-plugins.sh << EOL |
| 54 | #!/bin/bash |
| 55 | |
| 56 | # Pull plugin archives from repos |
| 57 | # Build wagons |
| 58 | # $1 is the DCAE repo URL |
| 59 | # $2 is the CCSDK repo URL |
| 60 | # (This script runs at Docker image build time) |
| 61 | # |
| 62 | set -x |
| 63 | DEST=wagons |
| 64 | |
| 65 | # For DCAE, we get zips of the archives and build wagons |
| 66 | DCAEPLUGINFILES=\ |
| 67 | "\ |
| 68 | relationshipplugin/1.0.0/relationshipplugin-1.0.0.tgz |
| 69 | dcaepolicyplugin/2.3.0/dcaepolicyplugin-2.3.0.tgz |
| 70 | dockerplugin/3.2.0/dockerplugin-3.2.0.tgz \ |
| 71 | " |
| 72 | |
| 73 | # For CCSDK, we pull down the wagon files directly |
| 74 | CCSDKPLUGINFILES=\ |
| 75 | "\ |
| 76 | plugins/pgaas-1.1.0-py27-none-any.wgn |
| 77 | plugins/sshkeyshare-1.0.0-py27-none-any.wgn |
| 78 | " |
| 79 | |
| 80 | # Build a set of wagon files from archives in a repo |
| 81 | # $1 -- repo base URL |
| 82 | # $2 -- list of paths to archive files in the repo |
| 83 | function build { |
| 84 | for plugin in $2 |
| 85 | do |
| 86 | # Could just do wagon create with the archive URL as source, |
| 87 | # but can't use a requirements file with that approach |
| 88 | mkdir work |
| 89 | target=$(basename ${plugin}) |
| 90 | curl -Ss $1/${plugin} > ${target} |
| 91 | tar zxvf ${target} --strip-components=2 -C work |
| 92 | wagon create -t tar.gz -o ${DEST} -r work/requirements.txt --validate ./work |
| 93 | rm -rf work |
| 94 | done |
| 95 | } |
| 96 | |
| 97 | # Copy a set of wagons from a repo |
| 98 | # $1 -- repo baseURL |
| 99 | # $2 -- list of paths to wagons in the repo |
| 100 | function get_wagons { |
| 101 | for wagon in $2 |
| 102 | do |
| 103 | target=$(basename ${wagon}) |
| 104 | curl -Ss $1/${wagon} > ${DEST}/${target} |
| 105 | done |
| 106 | } |
| 107 | |
| 108 | mkdir ${DEST} |
| 109 | build $1 "${DCAEPLUGINFILES}" |
| 110 | get_wagons $2 "${CCSDKPLUGINFILES}" |
| 111 | EOL |
| 112 | |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 113 | chmod 777 scripts-in-container/* |
| 114 | |
| 115 | echo "Launching Cloudify Manager container" |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 116 | docker run -d \ |
| 117 | --network="${NETWORK}" \ |
| 118 | --name cloudify-manager \ |
| 119 | --restart unless-stopped \ |
| 120 | -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 121 | -v /opt/app/config/scripts-in-container:/tmp/bin \ |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 122 | -p 80:80 \ |
| 123 | --tmpfs /run \ |
| 124 | --tmpfs /run/lock \ |
| 125 | --security-opt seccomp:unconfined \ |
| 126 | --cap-add SYS_ADMIN \ |
| 127 | --label "SERVICE_80_NAME=cloudify_manager" \ |
| 128 | --label "SERVICE_80_CHECK_TCP=true" \ |
| 129 | --label "SERVICE_80_CHECK_INTERVAL=15s" \ |
| 130 | --label "SERVICE_80_CHECK_INITIAL_STATUS=passing" \ |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 131 | {{ nexus_docker_repo }}/onap/org.onap.dcaegen2.deployments.cm-container:{{ dcae_docker_cm }} |
| 132 | |
| 133 | echo "Cloudify Manager deployed, waiting for completion" |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 134 | while ! nc -z localhost 80; do sleep 1; done |
| 135 | |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 136 | echo "Upload plugins to Cloudify Manager" |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 137 | |
Lusheng Ji | c5afcd0 | 2018-04-17 11:13:03 -0400 | [diff] [blame] | 138 | # run as detached because this script is intended to be run in background |
| 139 | docker exec -itd cloudify-manager /tmp/bin/install-plugins.sh |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 140 | |
Lusheng Ji | bd838e7 | 2018-04-16 21:27:17 -0400 | [diff] [blame] | 141 | echo "Cloudify Manager setup complete" |
Lusheng Ji | 819aa7f | 2018-04-16 02:24:39 -0400 | [diff] [blame] | 142 | |