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