#!/bin/bash source /var/onap/functions hbase_version=1.2.0 # install_hadoop() - Function that installs Hadoop function install_hadoop { local release=titan local version=1.0.0 local filename=$release-$version-hadoop1 local dest_folder=/opt/hadoop/current if [ ! -d $dest_folder ]; then curl http://s3.thinkaurelius.com/downloads/$release/$filename.zip -o /tmp/${filename}.zip install_package unzip mkdir -p $dest_folder unzip /tmp/${filename}.zip -d $dest_folder fi pushd $dest_folder/${filename} # Change commitlog_directory and data_file_directories values (https://stackoverflow.com/a/26856246/1707651) sed -i "s|db/cassandra/data|/tmp/data|g" conf/cassandra/cassandra.yaml sed -i "s|db/cassandra/commitlog|/tmp/commitlog|g" conf/cassandra/cassandra.yaml install_java ./bin/titan.sh start popd } # install_haproxy() - Function that install HAProxy function install_haproxy { if is_package_installed haproxy; then return fi install_package software-properties-common add-apt-repository -y ppa:vbernat/haproxy-1.7 update_repos install_package haproxy cp /var/onap/files/haproxy.cfg /etc/haproxy/ cp /var/onap/files/aai.pem /etc/ssl/private/ chmod 640 /etc/ssl/private/aai.pem chown root:ssl-cert /etc/ssl/private/aai.pem mkdir -p /usr/local/etc/haproxy #echo "127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resources.api.simpledemo.openecomp.org" >> /etc/hosts service haproxy restart } # compile_aai_repos() - Function that compiles AAI source repo. function compile_aai_repos { local repos="aai/aai-common aai/resources aai/logging-service aai/traversal" if [[ "$compile_repo" == "True" ]]; then repos="${repos[aai]}" fi for repo in ${repos[@]}; do compile_src ${src_folders[aai]}${repo#*aai} done } # setup_titan() - Function that configures AAI services to connect to Hadoop Titan function setup_titan { local subdirectory="bundleconfig-local/etc/appprops" install_python_package crudini for dirc in resources/aai-resources traversal/aai-traversal; do for file in titan-cached.properties titan-realtime.properties; do crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.backend" "cassandra" crudini --set "${src_folders[aai]}/$dirc/$subdirectory/$file" "" "storage.hostname" "localhost" done done # Add the schema to the local instance compile_src ${src_folders[aai]}/resources/aai-resources/ uninstall_packages default-jre openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless pushd ${src_folders[aai]} 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 popd } # _start_data_managment() - Funtion that start a data management service function _start_data_managment { local service=$1 local debug_port=$2 install_maven pushd ${src_folders[aai]}/$service export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$debug_port,server=y,suspend=n" mvn -P runAjsc & popd } # start_aai_microservices() - Function that starts AAI microservices function start_aai_microservices { _start_data_managment resources 9446 sleep 360 _start_data_managment traversal 9447 } # install_aai() - Install AAI Services function install_aai { install_docker_compose pushd ${src_folders[aai]}/test-config ./deploy_vm2.sh ./deploy_vm1.sh popd } # get_aai_images() - Function that pulls or creates AAI docker images function get_aai_images { pull_docker_image elasticsearch:2.4.1 docker_openecomp_login pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/aaionap/hbase:${hbase_version} if [[ "$build_image" == "True" ]]; then unset MAVEN_OPTS build_docker_image ${src_folders[aai]}/resources/aai-resources build_docker_image ${src_folders[aai]}/traversal/aai-traversal build_docker_image ${src_folders[aai]}/search-data-service build_docker_image ${src_folders[aai]}/data-router build_docker_image ${src_folders[aai]}/model-loader build_docker_image ${src_folders[aai]}/sparky-be else pull_onap_image aai-resources pull_onap_image aai-traversal pull_onap_image search-data-service pull_onap_image data-router pull_onap_image model-loader pull_onap_image sparky-be fi } # init_aai() - Function that initialize AAI services function init_aai { install_hadoop install_haproxy if [[ "$clone_repo" == "True" ]]; then clone_repos "aai" fi compile_aai_repos setup_titan #start_aai_microservices if [[ "$skip_get_images" == "False" ]]; then get_aai_images fi if [[ "$skip_install" == "False" ]]; then install_aai fi }