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 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 60 | # clone_all_dcae_repos() - Function that clones DCAE source repo. |
| 61 | function clone_all_dcae_repos { |
| 62 | local src_folder=/opt/dcae |
| 63 | clone_repo dcae $src_folder |
| 64 | |
| 65 | for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \ |
| 66 | demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do |
| 67 | clone_repo dcae/$dirc $src_folder/$dirc |
| 68 | done |
| 69 | } |
| 70 | |
| 71 | # compile_all_dcae_repos() - Function that compiles DCAE source repo. |
| 72 | function compile_all_dcae_repos { |
| 73 | local src_folder=/opt/dcae |
| 74 | |
| 75 | for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \ |
| 76 | demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do |
| 77 | compile_src $src_folder/$dirc |
| 78 | done |
| 79 | } |
| 80 | |
| 81 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 82 | # install_dcae() - Function that clones and installs the DCAE controller services from source code |
| 83 | function install_dcae { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 84 | install_docker_compose |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 85 | |
| 86 | clone_all_dcae_repos |
| 87 | if [[ "$compile_repo" == "True" ]]; then |
| 88 | compile_all_dcae_repos |
| 89 | fi |
| 90 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 91 | if [[ "$build_image" == "True" ]]; then |
| 92 | install_docker |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 93 | local src_folder=/opt/dcae |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 94 | |
| 95 | compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc |
| 96 | compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher |
| 97 | |
| 98 | clone_repo dcae/demo $src_folder/demo |
| 99 | compile_src $src_folder/demo |
| 100 | pushd $src_folder/demo |
| 101 | bash dcae-demo-controller/src/main/docker-build/build.sh |
| 102 | asserts_image dcae-controller |
| 103 | popd |
| 104 | |
| 105 | clone_repo dcae/dcae-inventory $src_folder/dcae-inventory |
| 106 | compile_src $src_folder/dcae-inventory |
| 107 | build_docker_image $src_folder/dcae-inventory |
| 108 | asserts_image dcae-inventory |
| 109 | |
| 110 | dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'` |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 111 | pushd $src_folder/demo/startup/controller |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 112 | sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml |
| 113 | sed -i "s|MTU|$MTU|g" docker-compose.yml |
| 114 | /opt/docker/docker-compose up -d |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 115 | popd |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 116 | else |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 117 | pushd /opt/dcae/demo/startup/controller |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 118 | bash init.sh |
| 119 | install_package make |
| 120 | make up |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 121 | popd |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 122 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | # init_dcae() - Function that initialize DCAE Controller services |
| 126 | function init_dcae { |
| 127 | create_config_file |
| 128 | install_dcae |
| 129 | } |