blob: 7a68fbbf4369f02de16c58367f58ae91012e303d [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Morales89ce3212017-06-16 18:32:48 -05003source /var/onap/functions
4
5hbase_version=1.2.3
Victor Morales455bece2017-07-31 18:40:39 -05006
7# install_hadoop() - Function that installs Hadoop
8function install_hadoop {
9 local release=titan
10 local version=1.0.0
11 local filename=$release-$version-hadoop1
12 local dest_folder=/opt/hadoop/current
13
14 if [ ! -d $dest_folder ]; then
15 curl http://s3.thinkaurelius.com/downloads/$release/$filename.zip -o /tmp/${filename}.zip
16 install_package unzip
17 mkdir -p $dest_folder
18 unzip /tmp/${filename}.zip -d $dest_folder
19 pushd $dest_folder/${filename}
Victor Morales158c18c2017-08-06 11:23:15 -050020 # Change commitlog_directory and data_file_directories values (https://stackoverflow.com/a/26856246/1707651)
21 sed -i "s|db/cassandra/data|/tmp/data|g" conf/cassandra/cassandra.yaml
22 sed -i "s|db/cassandra/commitlog|/tmp/commitlog|g" conf/cassandra/cassandra.yaml
23
24 install_java
Victor Morales455bece2017-07-31 18:40:39 -050025 ./bin/titan.sh start
26 popd
27 fi
28}
29
30# install_haproxy() - Function that install HAProxy
31function install_haproxy {
Victor Morales7ae05a42017-08-22 14:39:00 -050032 if is_package_installed haproxy; then
33 return
34 fi
35 install_package software-properties-common
36 add-apt-repository -y ppa:vbernat/haproxy-1.7
Victor Morales455bece2017-07-31 18:40:39 -050037 install_package haproxy
Victor Morales7ae05a42017-08-22 14:39:00 -050038 cp /var/onap/files/haproxy.cfg /etc/haproxy/
Victor Morales455bece2017-07-31 18:40:39 -050039 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
Victor Morales7ae05a42017-08-22 14:39:00 -050043 #echo "127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resources.api.simpledemo.openecomp.org" >> /etc/hosts
Victor Morales455bece2017-07-31 18:40:39 -050044
45 service haproxy restart
46}
Victor Morales89ce3212017-06-16 18:32:48 -050047
Victor Moralesdd074802017-07-26 16:06:35 -050048
Victor Morales455bece2017-07-31 18:40:39 -050049# compile_aai_repos() - Function that compiles AAI source repo.
50function compile_aai_repos {
Victor Morales54646642017-12-08 11:57:42 -080051 local repos="aai/aai-common aai/resources aai/logging-service aai/traversal"
Victor Morales455bece2017-07-31 18:40:39 -050052 if [[ "$compile_repo" == "True" ]]; then
Victor Morales54646642017-12-08 11:57:42 -080053 repos="${repos[aai]}"
Victor Morales455bece2017-07-31 18:40:39 -050054 fi
Victor Moralesdd074802017-07-26 16:06:35 -050055
Victor Moralesf6c0bf12017-10-27 11:08:04 -070056 for repo in ${repos[@]}; do
57 compile_src $aai_src_folder${repo#*aai}
Victor Moralesdd074802017-07-26 16:06:35 -050058 done
59}
60
Victor Morales455bece2017-07-31 18:40:39 -050061# setup_titan() - Function that configures AAI services to connect to Hadoop Titan
62function setup_titan {
Victor Morales7ae05a42017-08-22 14:39:00 -050063 local subdirectory="bundleconfig-local/etc/appprops"
Victor Morales455bece2017-07-31 18:40:39 -050064 install_python_package crudini
65
Victor Morales7ae05a42017-08-22 14:39:00 -050066 for dirc in resources/aai-resources traversal/aai-traversal; do
Victor Morales455bece2017-07-31 18:40:39 -050067 for file in titan-cached.properties titan-realtime.properties; do
Victor Morales7ae05a42017-08-22 14:39:00 -050068 crudini --set "$aai_src_folder/$dirc/$subdirectory/$file" "" "storage.backend" "cassandra"
69 crudini --set "$aai_src_folder/$dirc/$subdirectory/$file" "" "storage.hostname" "localhost"
Victor Morales455bece2017-07-31 18:40:39 -050070 done
71 done
72
Victor Morales7ae05a42017-08-22 14:39:00 -050073 # Add the schema to the local isntance
74 compile_src $aai_src_folder/resources/aai-resources/
75 uninstall_packages default-jre openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless
Victor Morales8e08c872017-08-21 16:15:57 -050076 pushd $aai_src_folder
Victor Morales8e08c872017-08-21 16:15:57 -050077 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 -050078 popd
79}
80
81# start_aai_microservices() - Function that starts AAI microservices
82function start_aai_microservices {
Victor Morales7ae05a42017-08-22 14:39:00 -050083 install_maven
84 export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"
Victor Morales455bece2017-07-31 18:40:39 -050085 for svc in resources traversal; do
Victor Morales8e08c872017-08-21 16:15:57 -050086 pushd $aai_src_folder/resources
Victor Morales455bece2017-07-31 18:40:39 -050087 mvn -P runAjsc
88 popd
89 done
90}
91
Victor Morales89ce3212017-06-16 18:32:48 -050092# install_hbase() - Install HBase Service
93function install_hbase {
94 docker rm -f hbase
Victor Morales9d205bc2017-12-01 17:52:07 -080095 docker_openecomp_login
96 docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
97 run_docker_image -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
Victor Morales89ce3212017-06-16 18:32:48 -050098}
99
100# install_ajsc() - Install ASJC Java service container
101function install_ajsc_aai {
102 cat <<EOL > /etc/ajsc-aai.conf
103AAI_REPO_PATH=r/aai
104AAI_CHEF_ENV=simpledemo
105AAI_CHEF_LOC=/var/chef/aai-data/environments
106docker_gitbranch=master
107EOL
108 docker rm -f aai-service
Victor Moralesdd074802017-07-26 16:06:35 -0500109 if [[ "$build_image" == "True" ]]; then
Victor Morales8e08c872017-08-21 16:15:57 -0500110 build_docker_image $aai_src_folder/aai-service/ajsc-aai
Victor Moralesdd074802017-07-26 16:06:35 -0500111 else
112 pull_openecomp_image ajsc-aai
113 fi
114
Victor Morales9d205bc2017-12-01 17:52:07 -0800115 run_docker_image --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
Victor Morales89ce3212017-06-16 18:32:48 -0500116}
117
118# install_model_loader() Install Model Loader
119function install_model_loader {
Victor Morales89ce3212017-06-16 18:32:48 -0500120 cat <<EOL > /etc/model-loader.conf
121DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443}
122DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup}
123DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB}
124DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic}
125DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp}
126DISTR_CLIENT_USER=${SDC_USER:-aai}
127
128APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443}
129APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader}
130APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
131APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw}
132EOL
133
Victor Moralesdd074802017-07-26 16:06:35 -0500134 ARGS=""
135
Victor Morales89ce3212017-06-16 18:32:48 -0500136 docker rm -f model-loader-service
137 if [[ "$build_image" == "True" ]]; then
Victor Morales8e08c872017-08-21 16:15:57 -0500138 build_docker_image $aai_src_folder/model-loader/
Victor Moralesdd074802017-07-26 16:06:35 -0500139 ARGS+="--env-file /etc/model-loader.conf model-loader"
Victor Morales89ce3212017-06-16 18:32:48 -0500140 else
141 pull_openecomp_image model-loader
Victor Moralesdd074802017-07-26 16:06:35 -0500142 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 -0500143 fi
Victor Morales9d205bc2017-12-01 17:52:07 -0800144 run_docker_image ${ARGS}
Victor Morales89ce3212017-06-16 18:32:48 -0500145}
146
Victor Morales158c18c2017-08-06 11:23:15 -0500147# _wait_for_sdc() - Function that determines if SDC is up and running
148function _wait_for_sdc {
Victor Morales89ce3212017-06-16 18:32:48 -0500149 if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then
150 SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt)
151 else
152 SDC_IP_ADDR="10.0.3.1"
153 fi
154
155 # Run Health Check against SDC and verify that all five components are up
156 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
157 while [[ $RES -lt 5 ]]; do
158 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
159 done
160}
161
162# init_aai() - Function that initialize AAI services
163function init_aai {
Victor Morales455bece2017-07-31 18:40:39 -0500164 install_hadoop
165 install_haproxy
Victor Morales89ce3212017-06-16 18:32:48 -0500166
Idan Amit1690e082017-08-20 08:58:14 +0300167 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -0800168 clone_repos "aai"
Idan Amit1690e082017-08-20 08:58:14 +0300169 if [[ "$compile_repo" == "True" ]]; then
170 compile_aai_repos
171 fi
172 fi
Victor Morales455bece2017-07-31 18:40:39 -0500173
174 setup_titan
Victor Morales14613122017-08-22 19:51:35 -0500175 #start_aai_microservices
Victor Morales455bece2017-07-31 18:40:39 -0500176
177 mkdir -p /opt/openecomp/aai/logs
178 mkdir -p /opt/openecomp/aai/data
Victor Moralesdd074802017-07-26 16:06:35 -0500179
Victor Morales89ce3212017-06-16 18:32:48 -0500180 install_hbase
181
182 # Wait 3 minutes before instantiating the A&AI container
183 sleep 180
184
185 install_ajsc_aai
Victor Morales158c18c2017-08-06 11:23:15 -0500186 _wait_for_sdc
Victor Morales6a919972017-09-28 18:29:54 -0700187 if [[ "$skip_install" == "False" ]]; then
188 install_model_loader
189 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500190}