blob: 1ce3485c6d18a4ad93e4e805baced312c8ed4a7a [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
Victor Moralesbe844712018-01-22 10:07:28 -08005hbase_version=1.2.0
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
Victor Morales455bece2017-07-31 18:40:39 -050019 fi
Victor Moralesbe844712018-01-22 10:07:28 -080020
21 pushd $dest_folder/${filename}
22 # Change commitlog_directory and data_file_directories values (https://stackoverflow.com/a/26856246/1707651)
23 sed -i "s|db/cassandra/data|/tmp/data|g" conf/cassandra/cassandra.yaml
24 sed -i "s|db/cassandra/commitlog|/tmp/commitlog|g" conf/cassandra/cassandra.yaml
25
26 install_java
27 ./bin/titan.sh start
28 popd
Victor Morales455bece2017-07-31 18:40:39 -050029}
30
31# install_haproxy() - Function that install HAProxy
32function install_haproxy {
Victor Morales7ae05a42017-08-22 14:39:00 -050033 if is_package_installed haproxy; then
34 return
35 fi
36 install_package software-properties-common
37 add-apt-repository -y ppa:vbernat/haproxy-1.7
Victor Moralesbe844712018-01-22 10:07:28 -080038 update_repos
Victor Morales455bece2017-07-31 18:40:39 -050039 install_package haproxy
Victor Morales7ae05a42017-08-22 14:39:00 -050040 cp /var/onap/files/haproxy.cfg /etc/haproxy/
Victor Morales455bece2017-07-31 18:40:39 -050041 cp /var/onap/files/aai.pem /etc/ssl/private/
42 chmod 640 /etc/ssl/private/aai.pem
43 chown root:ssl-cert /etc/ssl/private/aai.pem
Victor Moralesbe844712018-01-22 10:07:28 -080044 mkdir -p /usr/local/etc/haproxy
Victor Morales7ae05a42017-08-22 14:39:00 -050045 #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 -050046
47 service haproxy restart
48}
Victor Morales89ce3212017-06-16 18:32:48 -050049
Victor Morales455bece2017-07-31 18:40:39 -050050# compile_aai_repos() - Function that compiles AAI source repo.
51function compile_aai_repos {
Victor Morales54646642017-12-08 11:57:42 -080052 local repos="aai/aai-common aai/resources aai/logging-service aai/traversal"
Victor Morales455bece2017-07-31 18:40:39 -050053 if [[ "$compile_repo" == "True" ]]; then
Victor Morales54646642017-12-08 11:57:42 -080054 repos="${repos[aai]}"
Victor Morales455bece2017-07-31 18:40:39 -050055 fi
Victor Moralesdd074802017-07-26 16:06:35 -050056
Victor Moralesf6c0bf12017-10-27 11:08:04 -070057 for repo in ${repos[@]}; do
Victor Moralesbe844712018-01-22 10:07:28 -080058 compile_src ${src_folders[aai]}${repo#*aai}
Victor Moralesdd074802017-07-26 16:06:35 -050059 done
60}
61
Victor Morales455bece2017-07-31 18:40:39 -050062# setup_titan() - Function that configures AAI services to connect to Hadoop Titan
63function setup_titan {
Victor Morales7ae05a42017-08-22 14:39:00 -050064 local subdirectory="bundleconfig-local/etc/appprops"
Victor Morales455bece2017-07-31 18:40:39 -050065 install_python_package crudini
66
Victor Morales7ae05a42017-08-22 14:39:00 -050067 for dirc in resources/aai-resources traversal/aai-traversal; do
Victor Morales455bece2017-07-31 18:40:39 -050068 for file in titan-cached.properties titan-realtime.properties; do
Victor Moralesbe844712018-01-22 10:07:28 -080069 crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.backend" "cassandra"
70 crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.hostname" "localhost"
Victor Morales455bece2017-07-31 18:40:39 -050071 done
72 done
73
Victor Moralesbe844712018-01-22 10:07:28 -080074 # Add the schema to the local instance
75 compile_src ${src_folders[aai]}/resources/aai-resources/
Victor Morales7ae05a42017-08-22 14:39:00 -050076 uninstall_packages default-jre openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless
Victor Moralesbe844712018-01-22 10:07:28 -080077 pushd ${src_folders[aai]}
78 java -DAJSC_HOME=${src_folders[aai]}/resources/aai-resources -DBUNDLECONFIG_DIR="bundleconfig-local" -cp aai-common/aai-core/target/aai-core-*.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/* org.onap.aai.dbgen.GenTester
79 popd
80}
81
82# _start_data_managment() - Funtion that start a data management service
83function _start_data_managment {
84 local service=$1
85 local debug_port=$2
86
87 install_maven
88 pushd ${src_folders[aai]}/$service
89 export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$debug_port,server=y,suspend=n"
90 mvn -P runAjsc &
Victor Morales455bece2017-07-31 18:40:39 -050091 popd
92}
93
94# start_aai_microservices() - Function that starts AAI microservices
95function start_aai_microservices {
Victor Moralesbe844712018-01-22 10:07:28 -080096 _start_data_managment resources 9446
97 sleep 360
98 _start_data_managment traversal 9447
Victor Morales455bece2017-07-31 18:40:39 -050099}
100
Victor Moralesbe844712018-01-22 10:07:28 -0800101# install_aai() - Install AAI Services
102function install_aai {
103 install_docker_compose
104 pushd ${src_folders[aai]}/test-config
105 ./deploy_vm2.sh
106 ./deploy_vm1.sh
107 popd
108}
109
110# get_aai_images() - Function that pulls or creates AAI docker images
111function get_aai_images {
112 pull_docker_image elasticsearch:2.4.1
Victor Morales9d205bc2017-12-01 17:52:07 -0800113 docker_openecomp_login
Victor Moralesbe844712018-01-22 10:07:28 -0800114 pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/aaionap/hbase:${hbase_version}
Victor Morales89ce3212017-06-16 18:32:48 -0500115
Victor Moralesdd074802017-07-26 16:06:35 -0500116 if [[ "$build_image" == "True" ]]; then
Victor Moralesbe844712018-01-22 10:07:28 -0800117 unset MAVEN_OPTS
Victor Moralesf8730f52018-03-02 13:24:33 -0800118 for project in resources/aai-resources traversal/aai-traversal search-data-service data-router model-loader sparky-be; do
119 build_docker_image ${src_folders[aai]}/$project
120 done
Victor Moralesdd074802017-07-26 16:06:35 -0500121 else
Victor Moralesf8730f52018-03-02 13:24:33 -0800122 for image in aai-resources aai-traversal search-data-service data-router model-loader sparky-be; do
123 pull_onap_image $image
124 done
Victor Moralesdd074802017-07-26 16:06:35 -0500125 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500126}
127
128# init_aai() - Function that initialize AAI services
129function init_aai {
Victor Morales455bece2017-07-31 18:40:39 -0500130 install_hadoop
131 install_haproxy
Victor Morales89ce3212017-06-16 18:32:48 -0500132
Idan Amit1690e082017-08-20 08:58:14 +0300133 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -0800134 clone_repos "aai"
Idan Amit1690e082017-08-20 08:58:14 +0300135 fi
Victor Moralesbe844712018-01-22 10:07:28 -0800136 compile_aai_repos
Victor Morales455bece2017-07-31 18:40:39 -0500137
138 setup_titan
Victor Morales14613122017-08-22 19:51:35 -0500139 #start_aai_microservices
Victor Morales455bece2017-07-31 18:40:39 -0500140
Victor Moralesbe844712018-01-22 10:07:28 -0800141 if [[ "$skip_get_images" == "False" ]]; then
142 get_aai_images
143 fi
Victor Morales6a919972017-09-28 18:29:54 -0700144 if [[ "$skip_install" == "False" ]]; then
Victor Moralesbe844712018-01-22 10:07:28 -0800145 install_aai
Victor Morales6a919972017-09-28 18:29:54 -0700146 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500147}