blob: 679cbabba1de69b2665701e0e48b695b63eb10d8 [file] [log] [blame]
Lusheng Ji819aa7f2018-04-16 02:24:39 -04001#!/bin/bash
Lusheng Jibd838e72018-04-16 21:27:17 -04002#############################################################################
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 Ji819aa7f2018-04-16 02:24:39 -040018
19
20NETWORK="config_default"
21
22echo "Cleaning up any previously deployed cludify manager and registrator"
23docker stop registrator cloudify-manager
24docker rm registrator cloudify-manager
25
26echo "Launching registrator on dockerhost"
27docker 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 \
33onapdcae/registrator:v7
34
Lusheng Jibd838e72018-04-16 21:27:17 -040035
36
37
38rm -rf scripts-in-container
39mkdir scripts-in-container
40cat > scripts-in-container/install-plugins.sh << EOL
41#!/bin/bash
42source /cfy42/bin/activate
43pip install pip==9.0.3
44cfy profiles use 127.0.0.1 -u admin -p admin -t default_tenant
45cfy status
46cd /tmp/bin
Vijay Venkatesh Kumar3ed26732019-05-06 16:56:23 +000047./build-plugins.sh https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5 https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/releases
Lusheng Jibd838e72018-04-16 21:27:17 -040048for wagon in ./wagons/*.wgn; do cfy plugins upload \$wagon ; done
49deactivate
50EOL
51
Vijay Venkatesh Kumarb654b732018-10-08 14:15:06 +000052#wget -O scripts-in-container/build-plugins.sh https://git.onap.org/dcaegen2/deployments/plain/k8s-bootstrap-container/build-plugins.sh
53cat > 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#
62set -x
63DEST=wagons
64
65# For DCAE, we get zips of the archives and build wagons
66DCAEPLUGINFILES=\
67"\
68relationshipplugin/1.0.0/relationshipplugin-1.0.0.tgz
69dcaepolicyplugin/2.3.0/dcaepolicyplugin-2.3.0.tgz
Schmalzried, Terry (ts862m)ba636572019-02-07 10:25:55 -050070dockerplugin/3.2.1/dockerplugin-3.2.1.tgz \
Vijay Venkatesh Kumarb654b732018-10-08 14:15:06 +000071"
72
73# For CCSDK, we pull down the wagon files directly
74CCSDKPLUGINFILES=\
75"\
76plugins/pgaas-1.1.0-py27-none-any.wgn
77plugins/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
83function 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
100function get_wagons {
101 for wagon in $2
102 do
103 target=$(basename ${wagon})
104 curl -Ss $1/${wagon} > ${DEST}/${target}
105 done
106}
107
108mkdir ${DEST}
109build $1 "${DCAEPLUGINFILES}"
110get_wagons $2 "${CCSDKPLUGINFILES}"
111EOL
112
Lusheng Jibd838e72018-04-16 21:27:17 -0400113chmod 777 scripts-in-container/*
114
115echo "Launching Cloudify Manager container"
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400116docker run -d \
117--network="${NETWORK}" \
118--name cloudify-manager \
119--restart unless-stopped \
120-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
Lusheng Jibd838e72018-04-16 21:27:17 -0400121-v /opt/app/config/scripts-in-container:/tmp/bin \
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400122-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 Jibd838e72018-04-16 21:27:17 -0400131{{ nexus_docker_repo }}/onap/org.onap.dcaegen2.deployments.cm-container:{{ dcae_docker_cm }}
132
133echo "Cloudify Manager deployed, waiting for completion"
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400134while ! nc -z localhost 80; do sleep 1; done
135
Lusheng Jibd838e72018-04-16 21:27:17 -0400136echo "Upload plugins to Cloudify Manager"
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400137
Lusheng Jic5afcd02018-04-17 11:13:03 -0400138# run as detached because this script is intended to be run in background
139docker exec -itd cloudify-manager /tmp/bin/install-plugins.sh
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400140
Lusheng Jibd838e72018-04-16 21:27:17 -0400141echo "Cloudify Manager setup complete"
Lusheng Ji819aa7f2018-04-16 02:24:39 -0400142