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 |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 9 | src_folder=$git_src_folder/aai |
| 10 | aai_repos=("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") |
| 11 | |
| 12 | # install_hadoop() - Function that installs Hadoop |
| 13 | function install_hadoop { |
| 14 | local release=titan |
| 15 | local version=1.0.0 |
| 16 | local filename=$release-$version-hadoop1 |
| 17 | local dest_folder=/opt/hadoop/current |
| 18 | |
| 19 | if [ ! -d $dest_folder ]; then |
| 20 | curl http://s3.thinkaurelius.com/downloads/$release/$filename.zip -o /tmp/${filename}.zip |
| 21 | install_package unzip |
| 22 | mkdir -p $dest_folder |
| 23 | unzip /tmp/${filename}.zip -d $dest_folder |
| 24 | pushd $dest_folder/${filename} |
| 25 | ./bin/titan.sh start |
| 26 | popd |
| 27 | fi |
| 28 | } |
| 29 | |
| 30 | # install_haproxy() - Function that install HAProxy |
| 31 | function install_haproxy { |
| 32 | install_package haproxy |
| 33 | sed -i "s|ENABLED=0|ENABLED=1|g" /etc/default/haproxy |
| 34 | # cp /var/onap/files/haproxy.cfg /etc/haproxy/ |
| 35 | cp /var/onap/files/aai.pem /etc/ssl/private/ |
| 36 | chmod 640 /etc/ssl/private/aai.pem |
| 37 | chown root:ssl-cert /etc/ssl/private/aai.pem |
| 38 | mkdir /usr/local/etc/haproxy |
| 39 | echo "127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resources.api.simpledemo.openecomp.org" >> /etc/hosts |
| 40 | |
| 41 | service haproxy restart |
| 42 | } |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 43 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 44 | # clone_all_aai_repos() - Function that clones AAI source repo. |
| 45 | function clone_all_aai_repos { |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 46 | for dirc in ${aai_repos[@]}; do |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 47 | clone_repo aai/$dirc $src_folder/$dirc |
| 48 | done |
| 49 | } |
| 50 | |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 51 | # compile_aai_repos() - Function that compiles AAI source repo. |
| 52 | function compile_aai_repos { |
| 53 | local repos=("aai-common" "resources" "logging-service" "traversal") |
| 54 | if [[ "$compile_repo" == "True" ]]; then |
| 55 | repos=aai_repos |
| 56 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 57 | |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 58 | for dirc in ${repos[@]}; do |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 59 | compile_src $src_folder/$dirc |
| 60 | done |
| 61 | } |
| 62 | |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 63 | # setup_titan() - Function that configures AAI services to connect to Hadoop Titan |
| 64 | function setup_titan { |
| 65 | local $subdirectory=bundleconfig-local/etc/appprops |
| 66 | install_python_package crudini |
| 67 | |
| 68 | for dirc in resources/aai-resources traversal/aai-travers; do |
| 69 | for file in titan-cached.properties titan-realtime.properties; do |
| 70 | crudini --set --existing $src_folder/$dirc/$subdirectory/$file "" storage.backend cassandra |
| 71 | crudini --set --existing $src_folder/$dirc/$subdirectory/$file "" storage.hostname localhost |
| 72 | done |
| 73 | done |
| 74 | |
| 75 | # Addthe schema to the local isntance |
| 76 | pushd $src_folder |
| 77 | java -DAJSC_HOME=$src_folder/resources/aai-resources -DBUNDLECONFIG_DIR="bundleconfig-local" -cp aai-common/aai-core/target/aai-core-1.1.0-SNAPSHOT.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/* org.openecomp.aai.dbgen.GenTester |
| 78 | popd |
| 79 | } |
| 80 | |
| 81 | # start_aai_microservices() - Function that starts AAI microservices |
| 82 | function start_aai_microservices { |
| 83 | MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n" |
| 84 | for svc in resources traversal; do |
| 85 | pushd $src_folder/resources |
| 86 | mvn -P runAjsc |
| 87 | popd |
| 88 | done |
| 89 | } |
| 90 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 91 | # pull_hbase_image() - Pull HBase container image from a Docker Registry Hub |
| 92 | function pull_hbase_image { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 93 | docker_openecomp_login |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 94 | docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} |
| 95 | } |
| 96 | |
| 97 | # install_hbase() - Install HBase Service |
| 98 | function install_hbase { |
| 99 | docker rm -f hbase |
| 100 | pull_hbase_image |
| 101 | docker run -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} |
| 102 | } |
| 103 | |
| 104 | # install_ajsc() - Install ASJC Java service container |
| 105 | function install_ajsc_aai { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 106 | local src_folder=/opt/aai/aai-service |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 107 | cat <<EOL > /etc/ajsc-aai.conf |
| 108 | AAI_REPO_PATH=r/aai |
| 109 | AAI_CHEF_ENV=simpledemo |
| 110 | AAI_CHEF_LOC=/var/chef/aai-data/environments |
| 111 | docker_gitbranch=master |
| 112 | EOL |
| 113 | docker rm -f aai-service |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 114 | if [[ "$build_image" == "True" ]]; then |
| 115 | clone_repo aai/aai-service $src_folder |
| 116 | build_docker_image $src_folder/ajsc-aai |
| 117 | else |
| 118 | pull_openecomp_image ajsc-aai |
| 119 | fi |
| 120 | |
| 121 | asserts_image openecomp/ajsc-aai |
| 122 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 123 | 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 |
| 124 | } |
| 125 | |
| 126 | # install_model_loader() Install Model Loader |
| 127 | function install_model_loader { |
| 128 | local src_folder=/opt/aai/model-loader/ |
| 129 | cat <<EOL > /etc/model-loader.conf |
| 130 | DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443} |
| 131 | DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup} |
| 132 | DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB} |
| 133 | DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic} |
| 134 | DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp} |
| 135 | DISTR_CLIENT_USER=${SDC_USER:-aai} |
| 136 | |
| 137 | APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443} |
| 138 | APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader} |
| 139 | APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o |
| 140 | APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw} |
| 141 | EOL |
| 142 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 143 | ARGS="" |
| 144 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 145 | docker rm -f model-loader-service |
| 146 | if [[ "$build_image" == "True" ]]; then |
| 147 | clone_repo aai/model-loader $src_folder |
| 148 | build_docker_image $src_folder |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 149 | ARGS+="--env-file /etc/model-loader.conf model-loader" |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 150 | else |
| 151 | pull_openecomp_image model-loader |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 152 | 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] | 153 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 154 | asserts_image openecomp/model-loader |
| 155 | docker run ${ARGS} |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | # wait_for_sdc() - Function that determines if SDC is up and running |
| 159 | function wait_for_sdc { |
| 160 | if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then |
| 161 | SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt) |
| 162 | else |
| 163 | SDC_IP_ADDR="10.0.3.1" |
| 164 | fi |
| 165 | |
| 166 | # Run Health Check against SDC and verify that all five components are up |
| 167 | RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") |
| 168 | while [[ $RES -lt 5 ]]; do |
| 169 | RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") |
| 170 | done |
| 171 | } |
| 172 | |
| 173 | # init_aai() - Function that initialize AAI services |
| 174 | function init_aai { |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 175 | install_hadoop |
| 176 | install_haproxy |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 177 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 178 | clone_all_aai_repos |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 179 | compile_aai_repos |
| 180 | |
| 181 | setup_titan |
| 182 | start_aai_microservices |
| 183 | |
| 184 | mkdir -p /opt/openecomp/aai/logs |
| 185 | mkdir -p /opt/openecomp/aai/data |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 186 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 187 | install_hbase |
| 188 | |
| 189 | # Wait 3 minutes before instantiating the A&AI container |
| 190 | sleep 180 |
| 191 | |
| 192 | install_ajsc_aai |
| 193 | wait_for_sdc |
| 194 | install_model_loader |
| 195 | } |