Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START========================================== |
| 4 | # =================================================================== |
| 5 | # Copyright © 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | # =================================================================== |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # ============LICENSE_END============================================ |
| 19 | # |
| 20 | # ECOMP and OpenECOMP are trademarks |
| 21 | # and service marks of AT&T Intellectual Property. |
| 22 | # |
| 23 | |
| 24 | # URLs for artifacts needed for installation |
| 25 | DESIGTYPES={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml |
| 26 | DESIGPLUG={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/dnsdesig-1.0.0-py27-none-any.wgn |
| 27 | SSHKEYTYPES={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/sshkeyshare/sshkey_types.yaml |
| 28 | SSHKEYPLUG={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/sshkeyshare-1.0.0-py27-none-any.wgn |
| 29 | OSPLUGINZIP=https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.4.zip |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 30 | OSPLUGINWGN=https://github.com/cloudify-cosmo/cloudify-openstack-plugin/releases/download/2.2.0/cloudify_openstack_plugin-2.2.0-py27-none-linux_x86_64-centos-Core.wgn |
| 31 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 32 | PLATBPSRC={{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints |
| 33 | DOCKERBP=DockerBP.yaml |
| 34 | CBSBP=config_binding_service.yaml |
| 35 | CDAPBP=cdapbp7.yaml |
| 36 | CDAPBROKERBP=cdap_broker.yaml |
| 37 | INVBP=inventory.yaml |
| 38 | DHBP=DeploymentHandler.yaml |
| 39 | PHBP=policy_handler.yaml |
| 40 | |
| 41 | DOCKERBPURL="${PLATBPSRC}/${DOCKERBP}" |
| 42 | CBSBPURL="${PLATBPSRC}/${CBSBP}" |
| 43 | CDAPBPURL="${PLATBPSRC}/${CDAPBP}" |
| 44 | CDAPBROKERBPURL="${PLATBPSRC}/${CDAPBROKERBP}" |
| 45 | INVBPURL="${PLATBPSRC}/${INVBP}" |
| 46 | DHBPURL="${PLATBPSRC}/${DHBP}" |
| 47 | PHBPURL="${PLATBPSRC}/${PHBP}" |
| 48 | |
| 49 | LOCATIONID=$(printenv LOCATION) |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 50 | |
| 51 | # Make sure ssh doesn't prompt for new host or choke on a new host with an IP it's seen before |
| 52 | SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" |
| 53 | STARTDIR=$(pwd) |
| 54 | |
Lusheng Ji | 10388fd | 2017-10-20 16:14:38 -0400 | [diff] [blame] | 55 | # clear out files for writing out floating IP addresses |
| 56 | rm -f "$STARTDIR"/config/runtime.ip.consul |
| 57 | rm -f "$STARTDIR"/config/runtime.ip.cm |
| 58 | |
| 59 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 60 | SSHUSER=centos |
| 61 | PVTKEY=./config/key |
| 62 | INPUTS=./config/inputs.yaml |
| 63 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 64 | if [ "$LOCATION" = "" ] |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 65 | then |
| 66 | echo 'Environment variable LOCATION not set. Should be set to location ID for this installation.' |
| 67 | exit 1 |
| 68 | fi |
| 69 | |
| 70 | set -e |
| 71 | set -x |
| 72 | |
| 73 | # Docker workaround for SSH key |
| 74 | # In order for the container to be able to access the key when it's mounted from the Docker host, |
| 75 | # the key file has to be world-readable. But ssh itself will not work with a private key that's world readable. |
| 76 | # So we make a copy and change permissions on the copy. |
| 77 | # NB -- the key on the Docker host has to be world-readable, which means that, from the host machine, you |
| 78 | # can't use it with ssh. It needs to be a world-readable COPY. |
| 79 | PVTKEY=./key600 |
| 80 | cp ./config/key ${PVTKEY} |
| 81 | chmod 600 ${PVTKEY} |
| 82 | |
| 83 | # Create a virtual environment |
| 84 | virtualenv dcaeinstall |
| 85 | source dcaeinstall/bin/activate |
| 86 | |
| 87 | # Install Cloudify |
| 88 | pip install cloudify==3.4.0 |
| 89 | |
| 90 | # Install the Cloudify OpenStack plugin |
| 91 | wget -qO- ${OSPLUGINZIP} > openstack.zip |
| 92 | pip install openstack.zip |
| 93 | |
| 94 | # Spin up a VM |
| 95 | |
| 96 | # Get the Designate and SSH key type files and plugins |
| 97 | mkdir types |
| 98 | wget -qO- ${DESIGTYPES} > types/dns_types.yaml |
| 99 | wget -qO- ${SSHKEYTYPES} > types/sshkey_types.yaml |
| 100 | |
| 101 | wget -O dnsdesig.wgn ${DESIGPLUG} |
| 102 | wget -O sshkeyshare.wgn ${SSHKEYPLUG} |
| 103 | |
| 104 | wagon install -s dnsdesig.wgn |
| 105 | wagon install -s sshkeyshare.wgn |
| 106 | |
| 107 | ## Fix up the inputs file to get the private key locally |
| 108 | sed -e "s#key_filename:.*#key_filename: $PVTKEY#" < ${INPUTS} > /tmp/local_inputs |
| 109 | |
| 110 | # Now install the VM |
| 111 | # Don't exit on error after this point--keep container running so we can do uninstalls after a failure |
| 112 | set +e |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame^] | 113 | if wget -O /tmp/centos_vm.yaml {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints/centos_vm.yaml; then |
| 114 | mv -f /tmp/centos_vm.yaml ./blueprints/ |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 115 | echo "Succeeded in getting the newest centos_vm.yaml" |
| 116 | else |
| 117 | echo "Failed to update centos_vm.yaml, using default version" |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame^] | 118 | rm -f /tmp/centos_vm.yaml |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 119 | fi |
| 120 | set -e |
| 121 | cfy local init --install-plugins -p ./blueprints/centos_vm.yaml -i /tmp/local_inputs -i "datacenter=$LOCATION" |
| 122 | cfy local execute -w install --task-retries=10 |
| 123 | PUBIP=$(cfy local outputs | grep -Po '"public_ip": "\K.*?(?=")') |
| 124 | |
| 125 | |
| 126 | ## It's probably not completely ready when the installation finish, so wait |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame^] | 127 | #sleep 180 |
| 128 | while [ $( ping -c 1 $PUBIP 2> /dev/null | grep icmp* | wc -l ) -eq 0 ]; |
| 129 | do |
| 130 | sleep 5 |
| 131 | echo "." |
| 132 | done |
| 133 | sleep 10 |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 134 | |
| 135 | echo "Installing Cloudify Manager on ${PUBIP}." |
| 136 | |
| 137 | PVTIP=$(ssh $SSHOPTS -i "$PVTKEY" "$SSHUSER"@"$PUBIP" 'echo PVTIP=`curl --silent http://169.254.169.254/2009-04-04/meta-data/local-ipv4`' | grep PVTIP | sed 's/PVTIP=//') |
| 138 | if [ "$PVTIP" = "" ] |
| 139 | then |
| 140 | echo Cannot access specified machine at $PUBIP using supplied credentials |
| 141 | # Don't exit--keep the container up so we can uninstall the VM and supporting entities |
| 142 | while true |
| 143 | do |
| 144 | sleep 300 |
| 145 | done |
| 146 | fi |
| 147 | |
| 148 | |
| 149 | # Copy private key onto Cloudify Manager VM |
| 150 | PVTKEYPATH=$(cat ${INPUTS} | grep "key_filename" | cut -d "'" -f2) |
| 151 | PVTKEYNAME=$(basename $PVTKEYPATH) |
| 152 | PVTKEYDIR=$(dirname $PVTKEYPATH) |
| 153 | scp $SSHOPTS -i $PVTKEY $PVTKEY $SSHUSER@$PUBIP:/tmp/$PVTKEYNAME |
| 154 | ssh -t $SSHOPTS -i $PVTKEY $SSHUSER@$PUBIP sudo mkdir -p $PVTKEYDIR |
| 155 | ssh -t $SSHOPTS -i $PVTKEY $SSHUSER@$PUBIP sudo mv /tmp/$PVTKEYNAME $PVTKEYPATH |
| 156 | |
| 157 | ESMAGIC=$(uuidgen -r) |
| 158 | WORKDIR=$HOME/cmtmp |
| 159 | BSDIR=$WORKDIR/cmbootstrap |
| 160 | PVTKEY2=$BSDIR/id_rsa.cfybootstrap |
| 161 | TMPBASE=$WORKDIR/tmp |
| 162 | TMPDIR=$TMPBASE/lib |
| 163 | SRCS=$WORKDIR/srcs.tar |
| 164 | TOOL=$WORKDIR/tool.py |
| 165 | rm -rf $WORKDIR |
| 166 | mkdir -p $BSDIR $TMPDIR/cloudify/wheels $TMPDIR/cloudify/sources $TMPDIR/manager |
| 167 | chmod 700 $WORKDIR |
| 168 | cp "$PVTKEY" $PVTKEY2 |
| 169 | cat >$TOOL <<!EOF |
| 170 | #!/usr/local/bin/python |
| 171 | # |
| 172 | import yaml |
| 173 | import sys |
| 174 | bsdir = sys.argv[1] |
| 175 | with open(bsdir + '/simple-manager-blueprint-inputs.yaml', 'r') as f: |
| 176 | inpyaml = yaml.load(f) |
| 177 | with open(bsdir + '/simple-manager-blueprint.yaml', 'r') as f: |
| 178 | bpyaml = yaml.load(f) |
| 179 | for param, value in bpyaml['inputs'].items(): |
| 180 | if value.has_key('default') and not inpyaml.has_key(param): |
| 181 | inpyaml[param] = value['default'] |
| 182 | print inpyaml['manager_resources_package'] |
| 183 | !EOF |
| 184 | |
| 185 | # |
| 186 | # Try to disable attempt to download virtualenv when not needed |
| 187 | # |
| 188 | ssh $SSHOPTS -t -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "echo y; mkdir -p /root/.virtualenv; echo '"'"'[virtualenv]'"'"' >/root/.virtualenv/virtualenv.ini; echo no-download=true >>/root/.virtualenv/virtualenv.ini"' |
| 189 | |
| 190 | # Gather installation artifacts |
| 191 | # from documentation, URL for manager blueprints archive |
| 192 | BSURL=https://github.com/cloudify-cosmo/cloudify-manager-blueprints/archive/3.4.tar.gz |
| 193 | BSFILE=$(basename $BSURL) |
| 194 | |
| 195 | umask 022 |
| 196 | wget -qO- $BSURL >$BSDIR/$BSFILE |
| 197 | cd $BSDIR |
| 198 | tar xzvf $BSFILE |
| 199 | MRPURL=$(python $TOOL $BSDIR/cloudify-manager-blueprints-3.4) |
| 200 | MRPFILE=$(basename $MRPURL) |
| 201 | wget -qO- $MRPURL >$TMPDIR/cloudify/sources/$MRPFILE |
| 202 | |
| 203 | tar cf $SRCS -C $TMPDIR cloudify |
| 204 | rm -rf $TMPBASE |
| 205 | # |
| 206 | # Load required package files onto VM |
| 207 | # |
| 208 | scp $SSHOPTS -i $PVTKEY2 $SRCS $SSHUSER@$PUBIP:/tmp/. |
| 209 | ssh -t $SSHOPTS -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "cd /opt; tar xf /tmp/srcs.tar; chown -R root:root /opt/cloudify /opt/manager; rm -rf /tmp/srcs.tar"' |
| 210 | # |
| 211 | # Install config file -- was done by DCAE controller. What now? |
| 212 | # |
| 213 | ssh $SSHOPTS -t -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc '"'"'mkdir -p /opt/dcae; if [ -f /tmp/cfy-config.txt ]; then cp /tmp/cfy-config.txt /opt/dcae/config.txt && chmod 644 /opt/dcae/config.txt; fi'"'" |
| 214 | cd $WORKDIR |
| 215 | |
| 216 | # |
| 217 | # Check for and set up https certificate information |
| 218 | # |
| 219 | rm -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.key $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.crt |
| 220 | ssh -t $SSHOPTS -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "openssl pkcs12 -in /opt/app/dcae-certificate/certificate.pkcs12 -passin file:/opt/app/dcae-certificate/.password -nodes -chain"' | awk 'BEGIN{x="/dev/null";}/-----BEGIN CERTIFICATE-----/{x="'$BSDIR'/cloudify-manager-blueprints-3.4/resources/ssl/server.crt";}/-----BEGIN PRIVATE KEY-----/{x="'$BSDIR'/cloudify-manager-blueprints-3.4/resources/ssl/server.key";}{print >x;}/-----END /{x="/dev/null";}' |
| 221 | USESSL=false |
| 222 | if [ -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.key -a -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.crt ] |
| 223 | then |
| 224 | USESSL=true |
| 225 | fi |
| 226 | # |
| 227 | # Set up configuration for the bootstrap |
| 228 | # |
| 229 | export CLOUDIFY_USERNAME=admin CLOUDIFY_PASSWORD=encc0fba9f6d618a1a51935b42342b17658 |
| 230 | cd $BSDIR/cloudify-manager-blueprints-3.4 |
| 231 | cp simple-manager-blueprint.yaml bootstrap-blueprint.yaml |
| 232 | ed bootstrap-blueprint.yaml <<'!EOF' |
| 233 | /^node_types:/-1a |
| 234 | plugin_resources: |
| 235 | description: > |
| 236 | Holds any archives that should be uploaded to the manager. |
| 237 | default: [] |
| 238 | dsl_resources: |
| 239 | description: > |
| 240 | Holds a set of dsl required resources |
| 241 | default: [] |
| 242 | . |
| 243 | /^ upload_resources:/a |
| 244 | plugin_resources: { get_input: plugin_resources } |
| 245 | . |
| 246 | w |
| 247 | q |
| 248 | !EOF |
| 249 | |
| 250 | sed <simple-manager-blueprint-inputs.yaml >bootstrap-inputs.yaml \ |
| 251 | -e "s;.*public_ip: .*;public_ip: '$PUBIP';" \ |
| 252 | -e "s;.*private_ip: .*;private_ip: '$PVTIP';" \ |
| 253 | -e "s;.*ssh_user: .*;ssh_user: '$SSHUSER';" \ |
| 254 | -e "s;.*ssh_key_filename: .*;ssh_key_filename: '$PVTKEY2';" \ |
| 255 | -e "s;.*elasticsearch_java_opts: .*;elasticsearch_java_opts: '-Des.cluster.name=$ESMAGIC';" \ |
| 256 | -e "/ssl_enabled: /s/.*/ssl_enabled: $USESSL/" \ |
| 257 | -e "/security_enabled: /s/.*/security_enabled: $USESSL/" \ |
| 258 | -e "/admin_password: /s/.*/admin_password: '$CLOUDIFY_PASSWORD'/" \ |
| 259 | -e "/admin_username: /s/.*/admin_username: '$CLOUDIFY_USERNAME'/" \ |
| 260 | -e "s;.*manager_resources_package: .*;manager_resources_package: 'http://169.254.169.254/nosuchthing/$MRPFILE';" \ |
| 261 | -e "s;.*ignore_bootstrap_validations: .*;ignore_bootstrap_validations: true;" \ |
| 262 | |
| 263 | # Add plugin resources |
Jack Lucas | 1e353cb | 2017-10-11 21:10:08 +0000 | [diff] [blame] | 264 | # TODO Maintain plugin list as updates/additions occur |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 265 | cat >>bootstrap-inputs.yaml <<'!EOF' |
| 266 | plugin_resources: |
| 267 | - 'http://repository.cloudifysource.org/org/cloudify3/wagons/cloudify-openstack-plugin/1.4/cloudify_openstack_plugin-1.4-py27-none-linux_x86_64-centos-Core.wgn' |
| 268 | - 'http://repository.cloudifysource.org/org/cloudify3/wagons/cloudify-fabric-plugin/1.4.1/cloudify_fabric_plugin-1.4.1-py27-none-linux_x86_64-centos-Core.wgn' |
| 269 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/dnsdesig-1.0.0-py27-none-any.wgn' |
| 270 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/sshkeyshare-1.0.0-py27-none-any.wgn' |
Jack Lucas | 2574502 | 2017-10-20 18:39:00 +0000 | [diff] [blame] | 271 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/pgaas-1.0.0-py27-none-any.wgn' |
Jack Lucas | 1e353cb | 2017-10-11 21:10:08 +0000 | [diff] [blame] | 272 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/cdapcloudify/cdapcloudify-14.2.5-py27-none-any.wgn' |
| 273 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/dcaepolicyplugin/dcaepolicyplugin-1.0.0-py27-none-any.wgn' |
| 274 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/dockerplugin/dockerplugin-2.4.0-py27-none-any.wgn' |
| 275 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/relationshipplugin/relationshipplugin-1.0.0-py27-none-any.wgn' |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 276 | !EOF |
| 277 | # |
| 278 | # And away we go |
| 279 | # |
| 280 | cfy init -r |
| 281 | cfy bootstrap --install-plugins -p bootstrap-blueprint.yaml -i bootstrap-inputs.yaml |
| 282 | rm -f resources/ssl/server.key |
| 283 | |
| 284 | # Install Consul VM via a blueprint |
| 285 | cd $STARTDIR |
| 286 | mkdir consul |
| 287 | cd consul |
| 288 | cfy init -r |
| 289 | cfy use -t ${PUBIP} |
| 290 | echo "Deploying Consul VM" |
| 291 | |
| 292 | set +e |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame^] | 293 | if wget -O /tmp/consul_cluster.yaml {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints/consul_cluster.yaml; then |
| 294 | mv -f /tmp/consul_cluster.yaml ../blueprints/ |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 295 | echo "Succeeded in getting the newest consul_cluster.yaml" |
| 296 | else |
| 297 | echo "Failed to update consul_cluster.yaml, using default version" |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame^] | 298 | rm -f /tmp/consul_cluster.yaml |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 299 | fi |
| 300 | set -e |
| 301 | cfy install -p ../blueprints/consul_cluster.yaml -d consul -i ../${INPUTS} -i "datacenter=$LOCATION" |
| 302 | |
| 303 | # Get the floating IP for one member of the cluster |
| 304 | # Needed for instructing the Consul agent on CM host to join the cluster |
| 305 | CONSULIP=$(cfy deployments outputs -d consul | grep -Po 'Value: \K.*') |
| 306 | echo Consul deployed at $CONSULIP |
| 307 | |
| 308 | # Wait for Consul API to come up |
| 309 | until curl http://$CONSULIP:8500/v1/agent/services |
| 310 | do |
| 311 | echo Waiting for Consul API |
| 312 | sleep 60 |
| 313 | done |
| 314 | |
| 315 | # Wait for a leader to be elected |
| 316 | until [[ "$(curl -Ss http://$CONSULIP:8500/v1/status/leader)" != '""' ]] |
| 317 | do |
| 318 | echo Waiting for leader |
| 319 | sleep 30 |
| 320 | done |
| 321 | |
| 322 | # Instruct the client-mode Consul agent running on the CM to join the cluster |
| 323 | curl http://$PUBIP:8500/v1/agent/join/$CONSULIP |
| 324 | |
| 325 | # Register Cloudify Manager in Consul via the local agent on CM host |
| 326 | |
| 327 | REGREQ=" |
| 328 | { |
| 329 | \"Name\" : \"cloudify_manager\", |
| 330 | \"ID\" : \"cloudify_manager\", |
| 331 | \"Tags\" : [\"http://${PUBIP}/api/v2.1\"], |
| 332 | \"Address\": \"${PUBIP}\", |
| 333 | \"Port\": 80, |
| 334 | \"Check\" : { |
| 335 | \"Name\" : \"cloudify_manager_health\", |
| 336 | \"Interval\" : \"300s\", |
| 337 | \"HTTP\" : \"http://${PUBIP}/api/v2.1/status\", |
| 338 | \"Status\" : \"passing\", |
| 339 | \"DeregisterCriticalServiceAfter\" : \"30m\" |
| 340 | } |
| 341 | } |
| 342 | " |
| 343 | |
| 344 | curl -X PUT -H 'Content-Type: application/json' --data-binary "$REGREQ" http://$PUBIP:8500/v1/agent/service/register |
| 345 | # Make Consul address available to plugins on Cloudify Manager |
| 346 | # TODO probably not necessary anymore |
| 347 | ENVINI=$(mktemp) |
| 348 | cat <<!EOF > $ENVINI |
| 349 | [$LOCATION] |
| 350 | CONSUL_HOST=$CONSULIP |
| 351 | CONFIG_BINDING_SERVICE=config_binding_service |
| 352 | !EOF |
| 353 | scp $SSHOPTS -i ../$PVTKEY $ENVINI $SSHUSER@$PUBIP:/tmp/env.ini |
| 354 | ssh -t $SSHOPTS -i ../$PVTKEY $SSHUSER@$PUBIP sudo mv /tmp/env.ini /opt/env.ini |
| 355 | rm $ENVINI |
| 356 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 357 | |
| 358 | ##### INSTALLATION OF PLATFORM COMPONENTS |
| 359 | |
| 360 | # Get component blueprints |
| 361 | wget -P ./blueprints/docker/ ${DOCKERBPURL} |
| 362 | wget -P ./blueprints/cbs/ ${CBSBPURL} |
| 363 | wget -P ./blueprints/cdap/ ${CDAPBPURL} |
| 364 | wget -P ./blueprints/cdapbroker/ ${CDAPBROKERBPURL} |
| 365 | wget -P ./blueprints/inv/ ${INVBPURL} |
| 366 | wget -P ./blueprints/dh/ ${DHBPURL} |
| 367 | wget -P ./blueprints/ph/ ${PHBPURL} |
| 368 | |
| 369 | |
| 370 | # Set up the credentials for access to the Docker registry |
| 371 | curl -X PUT -H "Content-Type: application/json" --data-binary '[{"username":"docker", "password":"docker", "registry": "nexus3.onap.org:10001"}]' http://${CONSULIP}:8500/v1/kv/docker_plugin/docker_logins |
| 372 | |
| 373 | # Install platform Docker host |
| 374 | # Note we're still in the "consul" directory, which is init'ed for talking to CM |
| 375 | |
| 376 | set +e |
| 377 | # Docker host for platform containers |
| 378 | cfy install -v -p ./blueprints/docker/${DOCKERBP} -b DockerBP -d DockerPlatform -i ../${INPUTS} -i "registered_dockerhost_name=platform_dockerhost" -i "registrator_image=onapdcae/registrator:v7" -i "location_id=${LOCATION}" -i "node_name=dokp00" -i "target_datacenter=${LOCATION}" |
| 379 | |
| 380 | # Docker host for service containers |
| 381 | cfy deployments create -b DockerBP -d DockerComponent -i ../${INPUTS} -i "registered_dockerhost_name=component_dockerhost" -i "location_id=${LOCATION}" -i "registrator_image=onapdcae/registrator:v7" -i "node_name=doks00" -i "target_datacenter=${LOCATION}" |
| 382 | cfy executions start -d DockerComponent -w install |
| 383 | |
| 384 | # wait for the extended platform VMs settle |
| 385 | #sleep 180 |
| 386 | |
| 387 | |
| 388 | # CDAP cluster |
Jack Lucas | 53b024f | 2017-10-19 13:36:15 +0000 | [diff] [blame] | 389 | cfy install -p ./blueprints/cdap/${CDAPBP} -b cdapbp7 -d cdap7 -i ../${INPUTS} -i "location_id=${LOCATION}" |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 390 | |
| 391 | # config binding service |
| 392 | cfy install -p ./blueprints/cbs/${CBSBP} -b config_binding_service -d config_binding_service -i "location_id=${LOCATION}" |
| 393 | |
| 394 | |
| 395 | # Inventory |
| 396 | cfy install -p ./blueprints/inv/${INVBP} -b PlatformServicesInventory -d PlatformServicesInventory -i "location_id=${LOCATION}" -i ../config/invinputs.yaml |
| 397 | |
| 398 | |
| 399 | # Deployment Handler DH |
| 400 | cat >../dhinputs <<EOL |
| 401 | application_config: |
| 402 | cloudify: |
| 403 | protocol: "http" |
| 404 | inventory: |
| 405 | protocol: "http" |
| 406 | EOL |
| 407 | cfy install -p ./blueprints/dh/${DHBP} -b DeploymentHandlerBP -d DeploymentHandler -i "location_id=${LOCATION}" -i ../dhinputs |
| 408 | |
| 409 | |
| 410 | # Policy Handler PH |
| 411 | cfy install -p ./blueprints/ph/${PHBP} -b policy_handler_BP -d policy_handler -i 'policy_handler_image=nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.policy-handler:1.1-latest' -i "location_id=${LOCATION}" -i ../config/phinputs.yaml |
| 412 | |
| 413 | |
Jack Lucas | 53b024f | 2017-10-19 13:36:15 +0000 | [diff] [blame] | 414 | # Wait for the CDAP cluster to be registered in Consul |
| 415 | echo "Waiting for CDAP cluster to register" |
| 416 | until curl -Ss http://${CONSULIP}:8500/v1/catalog/service/cdap | grep cdap |
| 417 | do |
| 418 | echo -n . |
| 419 | sleep 30 |
| 420 | done |
| 421 | echo "CDAP cluster registered" |
| 422 | |
| 423 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 424 | # CDAP Broker |
Jack Lucas | 53b024f | 2017-10-19 13:36:15 +0000 | [diff] [blame] | 425 | cfy install -p ./blueprints/cdapbroker/${CDAPBROKERBP} -b cdapbroker -d cdapbroker -i "location_id=${LOCATION}" |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 426 | |
| 427 | |
Lusheng Ji | 10388fd | 2017-10-20 16:14:38 -0400 | [diff] [blame] | 428 | # write out IP addresses |
| 429 | echo "$CONSULIP" > "$STARTDIR"/config/runtime.ip.consul |
| 430 | echo "$PUBIP" > "$STARTDIR"/config/runtime.ip.cm |
| 431 | |
| 432 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 433 | # Keep the container up |
Lusheng Ji | c37f51b | 2017-10-15 22:17:30 -0400 | [diff] [blame] | 434 | rm -f /tmp/ready_to_exit |
| 435 | while [ ! -e /tmp/ready_to_exit ] |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 436 | do |
Lusheng Ji | c37f51b | 2017-10-15 22:17:30 -0400 | [diff] [blame] | 437 | sleep 30 |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 438 | done |