Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
| 5 | source /var/onap/functions |
| 6 | source /var/onap/asserts |
| 7 | |
| 8 | # create_config_file() - Creates a configuration yaml file for the controller |
| 9 | function create_config_file { |
| 10 | mkdir -p /opt/app/dcae-controller |
| 11 | cat > /opt/app/dcae-controller/config.yaml << EOL |
| 12 | ZONE: $dcae_zone |
| 13 | STATE: $dcae_state |
| 14 | DCAE-VERSION: $artifacts_version |
| 15 | HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id |
| 16 | KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0 |
| 17 | OPENSTACK-TENANT-ID: $tenant_id |
| 18 | OPENSTACK-TENANT-NAME: OPEN-ECOMP |
| 19 | OPENSTACK-REGION: $openstack_region |
| 20 | OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name |
| 21 | OPENSTACK-USER: $openstack_user |
| 22 | OPENSTACK-PASSWORD: $openstack_password |
| 23 | OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae |
| 24 | OPENSTACK-PUBKEY: $pub_key |
| 25 | |
| 26 | NEXUS-URL-ROOT: $nexus_repo_root |
| 27 | NEXUS-USER: $nexus_username |
| 28 | NEXUS-PASSWORD: $nexus_password |
| 29 | NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots |
| 30 | NEXUS-RAWURL: $nexus_repo |
| 31 | |
| 32 | DOCKER-REGISTRY: $nexus_docker_repo |
| 33 | |
| 34 | GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git |
| 35 | EOL |
| 36 | } |
| 37 | |
| 38 | # compile_docker_image() - Function that clones, compiles and build a Docker image |
| 39 | function compile_docker_image { |
| 40 | local repo=$1 |
| 41 | local src_folder=$2 |
| 42 | local name=$3 |
| 43 | clone_repo dcae/dmaapbc $src_folder |
| 44 | compile_src $src_folder |
| 45 | pushd $src_folder |
| 46 | # TODO(electrocucaracha) Workaround for dmmapb images |
| 47 | sed -i '/LocalKey/d' Dockerfile |
| 48 | local docker_build="docker build -t $name -f ./Dockerfile ." |
| 49 | if [ $http_proxy ]; then |
| 50 | docker_build+=" --build-arg http_proxy=$http_proxy" |
| 51 | fi |
| 52 | if [ $https_proxy ]; then |
| 53 | docker_build+=" --build-arg https_proxy=$https_proxy" |
| 54 | fi |
| 55 | eval $docker_build |
| 56 | asserts_image $name |
| 57 | popd |
| 58 | } |
| 59 | |
| 60 | # install_dcae() - Function that clones and installs the DCAE controller services from source code |
| 61 | function install_dcae { |
| 62 | export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) |
| 63 | local src_folder=/opt/dcae-startup-vm-controller |
| 64 | clone_repo dcae/demo/startup/controller $src_folder |
| 65 | pushd $src_folder |
| 66 | install_docker_compose |
| 67 | if [[ "$build_image" == "True" ]]; then |
| 68 | install_docker |
| 69 | src_folder=/opt/dcae |
| 70 | |
| 71 | compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc |
| 72 | compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher |
| 73 | |
| 74 | clone_repo dcae/demo $src_folder/demo |
| 75 | compile_src $src_folder/demo |
| 76 | pushd $src_folder/demo |
| 77 | bash dcae-demo-controller/src/main/docker-build/build.sh |
| 78 | asserts_image dcae-controller |
| 79 | popd |
| 80 | |
| 81 | clone_repo dcae/dcae-inventory $src_folder/dcae-inventory |
| 82 | compile_src $src_folder/dcae-inventory |
| 83 | build_docker_image $src_folder/dcae-inventory |
| 84 | asserts_image dcae-inventory |
| 85 | |
| 86 | dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'` |
| 87 | sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml |
| 88 | sed -i "s|MTU|$MTU|g" docker-compose.yml |
| 89 | /opt/docker/docker-compose up -d |
| 90 | else |
| 91 | bash init.sh |
| 92 | install_package make |
| 93 | make up |
| 94 | fi |
| 95 | |
| 96 | popd |
| 97 | } |
| 98 | |
| 99 | # init_dcae() - Function that initialize DCAE Controller services |
| 100 | function init_dcae { |
| 101 | create_config_file |
| 102 | install_dcae |
| 103 | } |