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 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 6 | |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 7 | dcae_src_folder=$git_src_folder/dcae |
| 8 | dcae_repos=("apod" "apod/analytics" "apod/buildtools" "apod/cdap" "collectors" "collectors/ves" "controller" "controller/analytics" "dcae-inventory" |
| 9 | "demo" "demo/startup" "demo/startup/aaf" "demo/startup/controller" "demo/startup/message-router" "dmaapbc" "operation" "operation/utils" "pgaas" "utils" "utils/buildtools") |
| 10 | |
| 11 | # _create_config_file() - Creates a configuration yaml file for the controller |
| 12 | function _create_config_file { |
| 13 | cat > $dcae_src_folder/controller/config.yaml << EOL |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 14 | ZONE: $dcae_zone |
| 15 | STATE: $dcae_state |
| 16 | DCAE-VERSION: $artifacts_version |
| 17 | HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id |
| 18 | KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0 |
| 19 | OPENSTACK-TENANT-ID: $tenant_id |
| 20 | OPENSTACK-TENANT-NAME: OPEN-ECOMP |
| 21 | OPENSTACK-REGION: $openstack_region |
| 22 | OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name |
| 23 | OPENSTACK-USER: $openstack_user |
| 24 | OPENSTACK-PASSWORD: $openstack_password |
| 25 | OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae |
| 26 | OPENSTACK-PUBKEY: $pub_key |
| 27 | |
| 28 | NEXUS-URL-ROOT: $nexus_repo_root |
| 29 | NEXUS-USER: $nexus_username |
| 30 | NEXUS-PASSWORD: $nexus_password |
| 31 | NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots |
| 32 | NEXUS-RAWURL: $nexus_repo |
| 33 | |
| 34 | DOCKER-REGISTRY: $nexus_docker_repo |
| 35 | |
| 36 | GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git |
| 37 | EOL |
| 38 | } |
| 39 | |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 40 | # _build_docker_image() - Function that clones, compiles and build a Docker image |
| 41 | function _build_docker_image { |
| 42 | local src_folder=$1 |
| 43 | local name=$2 |
| 44 | install_docker |
| 45 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 46 | pushd $src_folder |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 47 | # TODO(electrocucaracha) Workaround for dmmapbc images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 48 | sed -i '/LocalKey/d' Dockerfile |
| 49 | local docker_build="docker build -t $name -f ./Dockerfile ." |
| 50 | if [ $http_proxy ]; then |
| 51 | docker_build+=" --build-arg http_proxy=$http_proxy" |
| 52 | fi |
| 53 | if [ $https_proxy ]; then |
| 54 | docker_build+=" --build-arg https_proxy=$https_proxy" |
| 55 | fi |
| 56 | eval $docker_build |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 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 { |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 62 | clone_repo dcae $dcae_src_folder |
| 63 | for dirc in ${dcae_repos[@]}; do |
| 64 | clone_repo dcae/$dirc $dcae_src_folder/$dirc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 65 | done |
| 66 | } |
| 67 | |
| 68 | # compile_all_dcae_repos() - Function that compiles DCAE source repo. |
| 69 | function compile_all_dcae_repos { |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 70 | for dirc in ${dcae_repos[@]}; do |
| 71 | compile_src $dcae_src_folder/$dirc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 72 | done |
| 73 | } |
| 74 | |
Victor Morales | 10d21db | 2017-08-23 13:26:09 -0500 | [diff] [blame] | 75 | # _build_dcae_images() Function that builds DCAE docker images from source code. |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 76 | function _build_dcae_images { |
| 77 | if [[ "$compile_repo" != "True" ]]; then |
| 78 | compile_src $dcae_src_folder/dmaapbc |
| 79 | compile_src $dcae_src_folder/orch-dispatcher |
| 80 | compile_src $dcae_src_folder/demo |
| 81 | compile_src $dcae_src_folder/dcae-inventory |
| 82 | fi |
| 83 | _build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc |
| 84 | _build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher |
| 85 | |
| 86 | pushd $dcae_src_folder/demo |
| 87 | bash dcae-demo-controller/src/main/docker-build/build.sh |
| 88 | popd |
| 89 | |
| 90 | build_docker_image $dcae_src_folder/dcae-inventory |
| 91 | } |
| 92 | |
| 93 | # get_dcae_images() - Function that retrieves or builds DCAE docker images. |
| 94 | function get_dcae_images { |
| 95 | if [[ "$build_image" == "True" ]]; then |
| 96 | _build_dcae_images |
| 97 | else |
| 98 | pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc |
| 99 | pull_openecomp_image dcae-controller |
| 100 | fi |
| 101 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 102 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 103 | # install_dcae() - Function that clones and installs the DCAE controller services from source code |
| 104 | function install_dcae { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 105 | install_docker_compose |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 106 | pushd $dcae_src_folder/demo/startup/controller |
| 107 | if [[ "$build_image" == "True" ]]; then |
| 108 | dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'` |
| 109 | sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml |
| 110 | sed -i "s|MTU|$MTU|g" docker-compose.yml |
| 111 | /opt/docker/docker-compose up -d |
| 112 | else |
| 113 | bash init.sh |
| 114 | install_package make |
| 115 | make up |
| 116 | fi |
| 117 | popd |
| 118 | # docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version> |
| 119 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 120 | |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 121 | # init_dcae() - Function that initialize DCAE Controller services |
| 122 | function init_dcae { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 123 | if [[ "$clone_repo" == "True" ]]; then |
| 124 | clone_all_dcae_repos |
| 125 | if [[ "$compile_repo" == "True" ]]; then |
| 126 | compile_all_dcae_repos |
| 127 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 128 | fi |
| 129 | |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 130 | _create_config_file |
| 131 | get_dcae_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 132 | install_dcae |
| 133 | } |