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