blob: cbf5c5f7db8db770a74426a3021e4da34f278893 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
6
7hbase_version=1.2.3
Victor Morales8e08c872017-08-21 16:15:57 -05008aai_src_folder=$git_src_folder/aai
Victor Morales158c18c2017-08-06 11:23:15 -05009aai_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 Morales455bece2017-07-31 18:40:39 -050010
11# install_hadoop() - Function that installs Hadoop
12function 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 Morales158c18c2017-08-06 11:23:15 -050024 # 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 Morales455bece2017-07-31 18:40:39 -050029 ./bin/titan.sh start
30 popd
31 fi
32}
33
34# install_haproxy() - Function that install HAProxy
35function install_haproxy {
36 install_package haproxy
37 sed -i "s|ENABLED=0|ENABLED=1|g" /etc/default/haproxy
38# cp /var/onap/files/haproxy.cfg /etc/haproxy/
39 cp /var/onap/files/aai.pem /etc/ssl/private/
40 chmod 640 /etc/ssl/private/aai.pem
41 chown root:ssl-cert /etc/ssl/private/aai.pem
42 mkdir /usr/local/etc/haproxy
43 echo "127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resources.api.simpledemo.openecomp.org" >> /etc/hosts
44
45 service haproxy restart
46}
Victor Morales89ce3212017-06-16 18:32:48 -050047
Victor Moralesdd074802017-07-26 16:06:35 -050048# clone_all_aai_repos() - Function that clones AAI source repo.
49function clone_all_aai_repos {
Victor Morales455bece2017-07-31 18:40:39 -050050 for dirc in ${aai_repos[@]}; do
Victor Morales8e08c872017-08-21 16:15:57 -050051 clone_repo aai/$dirc $aai_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050052 done
53}
54
Victor Morales455bece2017-07-31 18:40:39 -050055# compile_aai_repos() - Function that compiles AAI source repo.
56function compile_aai_repos {
57 local repos=("aai-common" "resources" "logging-service" "traversal")
58 if [[ "$compile_repo" == "True" ]]; then
Victor Morales158c18c2017-08-06 11:23:15 -050059 repos=("${aai_repos[@]}")
Victor Morales455bece2017-07-31 18:40:39 -050060 fi
Victor Moralesdd074802017-07-26 16:06:35 -050061
Victor Morales455bece2017-07-31 18:40:39 -050062 for dirc in ${repos[@]}; do
Victor Morales8e08c872017-08-21 16:15:57 -050063 compile_src $aai_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050064 done
65}
66
Victor Morales455bece2017-07-31 18:40:39 -050067# setup_titan() - Function that configures AAI services to connect to Hadoop Titan
68function setup_titan {
69 local $subdirectory=bundleconfig-local/etc/appprops
70 install_python_package crudini
71
72 for dirc in resources/aai-resources traversal/aai-travers; do
73 for file in titan-cached.properties titan-realtime.properties; do
Victor Morales8e08c872017-08-21 16:15:57 -050074 crudini --set --existing $aai_src_folder/$dirc/$subdirectory/$file "" storage.backend cassandra
75 crudini --set --existing $aai_src_folder/$dirc/$subdirectory/$file "" storage.hostname localhost
Victor Morales455bece2017-07-31 18:40:39 -050076 done
77 done
78
79 # Addthe schema to the local isntance
Victor Morales8e08c872017-08-21 16:15:57 -050080 pushd $aai_src_folder
Victor Morales158c18c2017-08-06 11:23:15 -050081 install_java
Victor Morales8e08c872017-08-21 16:15:57 -050082 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 Morales455bece2017-07-31 18:40:39 -050083 popd
84}
85
86# start_aai_microservices() - Function that starts AAI microservices
87function start_aai_microservices {
88 MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"
89 for svc in resources traversal; do
Victor Morales8e08c872017-08-21 16:15:57 -050090 pushd $aai_src_folder/resources
Victor Morales455bece2017-07-31 18:40:39 -050091 mvn -P runAjsc
92 popd
93 done
94}
95
Victor Morales158c18c2017-08-06 11:23:15 -050096# _pull_hbase_image() - Pull HBase container image from a Docker Registry Hub
97function _pull_hbase_image {
Victor Moralesdd074802017-07-26 16:06:35 -050098 docker_openecomp_login
Victor Morales89ce3212017-06-16 18:32:48 -050099 docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
100}
101
102# install_hbase() - Install HBase Service
103function install_hbase {
104 docker rm -f hbase
Victor Morales158c18c2017-08-06 11:23:15 -0500105 _pull_hbase_image
Victor Morales89ce3212017-06-16 18:32:48 -0500106 docker run -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
107}
108
109# install_ajsc() - Install ASJC Java service container
110function install_ajsc_aai {
111 cat <<EOL > /etc/ajsc-aai.conf
112AAI_REPO_PATH=r/aai
113AAI_CHEF_ENV=simpledemo
114AAI_CHEF_LOC=/var/chef/aai-data/environments
115docker_gitbranch=master
116EOL
117 docker rm -f aai-service
Victor Moralesdd074802017-07-26 16:06:35 -0500118 if [[ "$build_image" == "True" ]]; then
Victor Morales8e08c872017-08-21 16:15:57 -0500119 build_docker_image $aai_src_folder/aai-service/ajsc-aai
Victor Moralesdd074802017-07-26 16:06:35 -0500120 else
121 pull_openecomp_image ajsc-aai
122 fi
123
Victor Morales89ce3212017-06-16 18:32:48 -0500124 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
125}
126
127# install_model_loader() Install Model Loader
128function install_model_loader {
Victor Morales89ce3212017-06-16 18:32:48 -0500129 cat <<EOL > /etc/model-loader.conf
130DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443}
131DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup}
132DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB}
133DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic}
134DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp}
135DISTR_CLIENT_USER=${SDC_USER:-aai}
136
137APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443}
138APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader}
139APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
140APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw}
141EOL
142
Victor Moralesdd074802017-07-26 16:06:35 -0500143 ARGS=""
144
Victor Morales89ce3212017-06-16 18:32:48 -0500145 docker rm -f model-loader-service
146 if [[ "$build_image" == "True" ]]; then
Victor Morales8e08c872017-08-21 16:15:57 -0500147 build_docker_image $aai_src_folder/model-loader/
Victor Moralesdd074802017-07-26 16:06:35 -0500148 ARGS+="--env-file /etc/model-loader.conf model-loader"
Victor Morales89ce3212017-06-16 18:32:48 -0500149 else
150 pull_openecomp_image model-loader
Victor Moralesdd074802017-07-26 16:06:35 -0500151 ARGS+="--name=model-loader-service -it -d --env-file /etc/model-loader.conf $nexus_docker_repo/openecomp/model-loader:$docker_version"
Victor Morales89ce3212017-06-16 18:32:48 -0500152 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500153 docker run ${ARGS}
Victor Morales89ce3212017-06-16 18:32:48 -0500154}
155
Victor Morales158c18c2017-08-06 11:23:15 -0500156# _wait_for_sdc() - Function that determines if SDC is up and running
157function _wait_for_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -0500158 if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then
159 SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt)
160 else
161 SDC_IP_ADDR="10.0.3.1"
162 fi
163
164 # Run Health Check against SDC and verify that all five components are up
165 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
166 while [[ $RES -lt 5 ]]; do
167 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
168 done
169}
170
171# init_aai() - Function that initialize AAI services
172function init_aai {
Victor Morales455bece2017-07-31 18:40:39 -0500173 install_hadoop
174 install_haproxy
Victor Morales89ce3212017-06-16 18:32:48 -0500175
Victor Moralesdd074802017-07-26 16:06:35 -0500176 clone_all_aai_repos
Victor Morales455bece2017-07-31 18:40:39 -0500177 compile_aai_repos
178
179 setup_titan
180 start_aai_microservices
181
182 mkdir -p /opt/openecomp/aai/logs
183 mkdir -p /opt/openecomp/aai/data
Victor Moralesdd074802017-07-26 16:06:35 -0500184
Victor Morales89ce3212017-06-16 18:32:48 -0500185 install_hbase
186
187 # Wait 3 minutes before instantiating the A&AI container
188 sleep 180
189
190 install_ajsc_aai
Victor Morales158c18c2017-08-06 11:23:15 -0500191 _wait_for_sdc
Victor Morales89ce3212017-06-16 18:32:48 -0500192 install_model_loader
193}