| #!/bin/bash |
| |
| set -o xtrace |
| |
| source /var/onap/functions |
| |
| dcae_src_folder=$git_src_folder/dcae |
| dcae_repos=("apod" "apod/analytics" "apod/buildtools" "apod/cdap" "collectors" "collectors/ves" "controller" "controller/analytics" "dcae-inventory" |
| "demo" "demo/startup" "demo/startup/aaf" "demo/startup/controller" "demo/startup/message-router" "dmaapbc" "operation" "operation/utils" "pgaas" "utils" "utils/buildtools") |
| |
| # _create_config_file() - Creates a configuration yaml file for the controller |
| function _create_config_file { |
| cat > $dcae_src_folder/controller/config.yaml << EOL |
| ZONE: $dcae_zone |
| STATE: $dcae_state |
| DCAE-VERSION: $artifacts_version |
| HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id |
| KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0 |
| OPENSTACK-TENANT-ID: $tenant_id |
| OPENSTACK-TENANT-NAME: OPEN-ECOMP |
| OPENSTACK-REGION: $openstack_region |
| OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name |
| OPENSTACK-USER: $openstack_user |
| OPENSTACK-PASSWORD: $openstack_password |
| OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae |
| OPENSTACK-PUBKEY: $pub_key |
| |
| NEXUS-URL-ROOT: $nexus_repo_root |
| NEXUS-USER: $nexus_username |
| NEXUS-PASSWORD: $nexus_password |
| NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots |
| NEXUS-RAWURL: $nexus_repo |
| |
| DOCKER-REGISTRY: $nexus_docker_repo |
| |
| GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git |
| EOL |
| } |
| |
| # _build_docker_image() - Function that clones, compiles and build a Docker image |
| function _build_docker_image { |
| local src_folder=$1 |
| local name=$2 |
| install_docker |
| |
| pushd $src_folder |
| # TODO(electrocucaracha) Workaround for dmmapbc images |
| sed -i '/LocalKey/d' Dockerfile |
| local docker_build="docker build -t $name -f ./Dockerfile ." |
| if [ $http_proxy ]; then |
| docker_build+=" --build-arg http_proxy=$http_proxy" |
| fi |
| if [ $https_proxy ]; then |
| docker_build+=" --build-arg https_proxy=$https_proxy" |
| fi |
| eval $docker_build |
| popd |
| } |
| |
| # clone_all_dcae_repos() - Function that clones DCAE source repo. |
| function clone_all_dcae_repos { |
| clone_repo dcae $dcae_src_folder |
| for dirc in ${dcae_repos[@]}; do |
| clone_repo dcae/$dirc $dcae_src_folder/$dirc |
| done |
| } |
| |
| # compile_all_dcae_repos() - Function that compiles DCAE source repo. |
| function compile_all_dcae_repos { |
| for dirc in ${dcae_repos[@]}; do |
| compile_src $dcae_src_folder/$dirc |
| done |
| } |
| |
| # _build_dcae_images() Function that builds DCAE docker images from source code. |
| function _build_dcae_images { |
| if [[ "$compile_repo" != "True" ]]; then |
| compile_src $dcae_src_folder/dmaapbc |
| compile_src $dcae_src_folder/orch-dispatcher |
| compile_src $dcae_src_folder/demo |
| compile_src $dcae_src_folder/dcae-inventory |
| fi |
| _build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc |
| _build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher |
| |
| pushd $dcae_src_folder/demo |
| bash dcae-demo-controller/src/main/docker-build/build.sh |
| popd |
| |
| build_docker_image $dcae_src_folder/dcae-inventory |
| } |
| |
| # get_dcae_images() - Function that retrieves or builds DCAE docker images. |
| function get_dcae_images { |
| if [[ "$build_image" == "True" ]]; then |
| _build_dcae_images |
| else |
| pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc |
| pull_openecomp_image dcae-controller |
| fi |
| } |
| |
| # install_dcae() - Function that clones and installs the DCAE controller services from source code |
| function install_dcae { |
| install_docker_compose |
| pushd $dcae_src_folder/demo/startup/controller |
| if [[ "$build_image" == "True" ]]; then |
| dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'` |
| sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml |
| sed -i "s|MTU|$MTU|g" docker-compose.yml |
| /opt/docker/docker-compose up -d |
| else |
| bash init.sh |
| install_package make |
| make up |
| fi |
| popd |
| # docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version> |
| } |
| |
| # init_dcae() - Function that initialize DCAE Controller services |
| function init_dcae { |
| clone_all_dcae_repos |
| if [[ "$compile_repo" == "True" ]]; then |
| compile_all_dcae_repos |
| fi |
| |
| _create_config_file |
| get_dcae_images |
| install_dcae |
| } |