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