Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 3 | source /var/onap/functions |
| 4 | |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 5 | hbase_version=1.2.0 |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 6 | |
| 7 | # install_hadoop() - Function that installs Hadoop |
| 8 | function 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 Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 19 | fi |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 20 | |
| 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 Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | # install_haproxy() - Function that install HAProxy |
| 32 | function install_haproxy { |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 33 | 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 Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 38 | update_repos |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 39 | install_package haproxy |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 40 | cp /var/onap/files/haproxy.cfg /etc/haproxy/ |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 41 | 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 Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 44 | mkdir -p /usr/local/etc/haproxy |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 45 | #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] | 46 | |
| 47 | service haproxy restart |
| 48 | } |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 49 | |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 50 | # compile_aai_repos() - Function that compiles AAI source repo. |
| 51 | function compile_aai_repos { |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 52 | local repos="aai/aai-common aai/resources aai/logging-service aai/traversal" |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 53 | if [[ "$compile_repo" == "True" ]]; then |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 54 | repos="${repos[aai]}" |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 55 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 56 | |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 57 | for repo in ${repos[@]}; do |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 58 | compile_src ${src_folders[aai]}${repo#*aai} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 59 | done |
| 60 | } |
| 61 | |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 62 | # setup_titan() - Function that configures AAI services to connect to Hadoop Titan |
| 63 | function setup_titan { |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 64 | local subdirectory="bundleconfig-local/etc/appprops" |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 65 | install_python_package crudini |
| 66 | |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 67 | for dirc in resources/aai-resources traversal/aai-traversal; do |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 68 | for file in titan-cached.properties titan-realtime.properties; do |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 69 | crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.backend" "cassandra" |
| 70 | crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.hostname" "localhost" |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 71 | done |
| 72 | done |
| 73 | |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 74 | # Add the schema to the local instance |
| 75 | compile_src ${src_folders[aai]}/resources/aai-resources/ |
Victor Morales | 7ae05a4 | 2017-08-22 14:39:00 -0500 | [diff] [blame] | 76 | uninstall_packages default-jre openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 77 | 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 |
| 83 | function _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 Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 91 | popd |
| 92 | } |
| 93 | |
| 94 | # start_aai_microservices() - Function that starts AAI microservices |
| 95 | function start_aai_microservices { |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 96 | _start_data_managment resources 9446 |
| 97 | sleep 360 |
| 98 | _start_data_managment traversal 9447 |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 99 | } |
| 100 | |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 101 | # install_aai() - Install AAI Services |
| 102 | function 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 |
| 111 | function get_aai_images { |
| 112 | pull_docker_image elasticsearch:2.4.1 |
Victor Morales | 9d205bc | 2017-12-01 17:52:07 -0800 | [diff] [blame] | 113 | docker_openecomp_login |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 114 | pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/aaionap/hbase:${hbase_version} |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 115 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 116 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 117 | unset MAVEN_OPTS |
Victor Morales | f8730f5 | 2018-03-02 13:24:33 -0800 | [diff] [blame] | 118 | 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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 121 | else |
Victor Morales | f8730f5 | 2018-03-02 13:24:33 -0800 | [diff] [blame] | 122 | 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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 125 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | # init_aai() - Function that initialize AAI services |
| 129 | function init_aai { |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 130 | install_hadoop |
| 131 | install_haproxy |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 132 | |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 133 | if [[ "$clone_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 134 | clone_repos "aai" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 135 | fi |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 136 | compile_aai_repos |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 137 | |
| 138 | setup_titan |
Victor Morales | 1461312 | 2017-08-22 19:51:35 -0500 | [diff] [blame] | 139 | #start_aai_microservices |
Victor Morales | 455bece | 2017-07-31 18:40:39 -0500 | [diff] [blame] | 140 | |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 141 | if [[ "$skip_get_images" == "False" ]]; then |
| 142 | get_aai_images |
| 143 | fi |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 144 | if [[ "$skip_install" == "False" ]]; then |
Victor Morales | be84471 | 2018-01-22 10:07:28 -0800 | [diff] [blame] | 145 | install_aai |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 146 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 147 | } |