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 | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 6 | source /var/onap/asserts |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 7 | |
| 8 | hbase_version=1.2.3 |
| 9 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 10 | # clone_all_aai_repos() - Function that clones AAI source repo. |
| 11 | function clone_all_aai_repos { |
| 12 | local src_folder=/opt/aai |
| 13 | |
| 14 | for dirc in aai-common aai-config aai-data aai-service data-router logging-service model-loader resources rest-client router-core search-data-service sparky-be sparky-fe test-config traversal; do |
| 15 | clone_repo aai/$dirc $src_folder/$dirc |
| 16 | done |
| 17 | } |
| 18 | |
| 19 | # compile_all_aai_repos() - Function that compiles AAI source repo. |
| 20 | function compile_all_aai_repos { |
| 21 | local src_folder=/opt/aai |
| 22 | |
| 23 | for dirc in aai-common aai-config aai-data aai-service data-router logging-service model-loader resources rest-client router-core search-data-service sparky-be sparky-fe test-config traversal; do |
| 24 | compile_src $src_folder/$dirc |
| 25 | done |
| 26 | } |
| 27 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 28 | # pull_hbase_image() - Pull HBase container image from a Docker Registry Hub |
| 29 | function pull_hbase_image { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 30 | docker_openecomp_login |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 31 | docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} |
| 32 | } |
| 33 | |
| 34 | # install_hbase() - Install HBase Service |
| 35 | function install_hbase { |
| 36 | docker rm -f hbase |
| 37 | pull_hbase_image |
| 38 | docker run -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} |
| 39 | } |
| 40 | |
| 41 | # install_ajsc() - Install ASJC Java service container |
| 42 | function install_ajsc_aai { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 43 | local src_folder=/opt/aai/aai-service |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 44 | cat <<EOL > /etc/ajsc-aai.conf |
| 45 | AAI_REPO_PATH=r/aai |
| 46 | AAI_CHEF_ENV=simpledemo |
| 47 | AAI_CHEF_LOC=/var/chef/aai-data/environments |
| 48 | docker_gitbranch=master |
| 49 | EOL |
| 50 | docker rm -f aai-service |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 51 | if [[ "$build_image" == "True" ]]; then |
| 52 | clone_repo aai/aai-service $src_folder |
| 53 | build_docker_image $src_folder/ajsc-aai |
| 54 | else |
| 55 | pull_openecomp_image ajsc-aai |
| 56 | fi |
| 57 | |
| 58 | asserts_image openecomp/ajsc-aai |
| 59 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 60 | docker run --env-file /etc/ajsc-aai.conf --name=aai-service --net=host -v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt -it -d $nexus_docker_repo/openecomp/ajsc-aai:$docker_version |
| 61 | } |
| 62 | |
| 63 | # install_model_loader() Install Model Loader |
| 64 | function install_model_loader { |
| 65 | local src_folder=/opt/aai/model-loader/ |
| 66 | cat <<EOL > /etc/model-loader.conf |
| 67 | DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443} |
| 68 | DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup} |
| 69 | DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB} |
| 70 | DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic} |
| 71 | DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp} |
| 72 | DISTR_CLIENT_USER=${SDC_USER:-aai} |
| 73 | |
| 74 | APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443} |
| 75 | APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader} |
| 76 | APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o |
| 77 | APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw} |
| 78 | EOL |
| 79 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 80 | ARGS="" |
| 81 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 82 | docker rm -f model-loader-service |
| 83 | if [[ "$build_image" == "True" ]]; then |
| 84 | clone_repo aai/model-loader $src_folder |
| 85 | build_docker_image $src_folder |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 86 | ARGS+="--env-file /etc/model-loader.conf model-loader" |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 87 | else |
| 88 | pull_openecomp_image model-loader |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 89 | ARGS+="--name=model-loader-service -it -d --env-file /etc/model-loader.conf $nexus_docker_repo/openecomp/model-loader:$docker_version" |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 90 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 91 | asserts_image openecomp/model-loader |
| 92 | docker run ${ARGS} |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | # wait_for_sdc() - Function that determines if SDC is up and running |
| 96 | function wait_for_sdc { |
| 97 | if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then |
| 98 | SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt) |
| 99 | else |
| 100 | SDC_IP_ADDR="10.0.3.1" |
| 101 | fi |
| 102 | |
| 103 | # Run Health Check against SDC and verify that all five components are up |
| 104 | RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") |
| 105 | while [[ $RES -lt 5 ]]; do |
| 106 | RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") |
| 107 | done |
| 108 | } |
| 109 | |
| 110 | # init_aai() - Function that initialize AAI services |
| 111 | function init_aai { |
| 112 | mkdir -p /opt/openecomp/aai/logs |
| 113 | mkdir -p /opt/openecomp/aai/data |
| 114 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame^] | 115 | clone_all_aai_repos |
| 116 | if [[ "$compile_repo" == "True" ]]; then |
| 117 | compile_all_aai_repos |
| 118 | fi |
| 119 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 120 | install_hbase |
| 121 | |
| 122 | # Wait 3 minutes before instantiating the A&AI container |
| 123 | sleep 180 |
| 124 | |
| 125 | install_ajsc_aai |
| 126 | wait_for_sdc |
| 127 | install_model_loader |
| 128 | } |