aboutsummaryrefslogtreecommitdiffstats
path: root/lib/aai
blob: e993dacac8d031e90f025e4bc6cc6ffa9891b71a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2017-2018
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#############################################################################

source /var/onap/functions

# 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 {
    local aai_docker_version="1.2-STAGING-latest"
    local cassandra_version=2.1
    local elasticsearch_version=2.4.1
    local hbase_version=1.2.0

    pull_docker_image cassandra:${cassandra_version}
    pull_docker_image elasticsearch:${elasticsearch_version} &
    docker_openecomp_login
    pull_docker_image ${nexus_docker_repo:-nexus3.onap.org:10001}/aaionap/hbase:${hbase_version} &
    wait_docker_pull

    if [[ "$build_image" == "True" ]]; then
        unset MAVEN_OPTS
        if [[ "$compile_repo" != "True" ]]; then
            compile_aai_repos
        fi
        for project in resources/aai-resources traversal/aai-traversal; do
            build_docker_image ${src_folders[aai]}/$project docker
        done
        for project in search-data-service data-router model-loader sparky-be/sparkybe-onap-application; do
            build_docker_image ${src_folders[aai]}/$project
        done
        for image in aai-resources aai-traversal search-data-service data-router model-loader sparky-be; do
            docker tag onap/$image ${nexus_docker_repo:-nexus3.onap.org:10001}/onap/$image $aai_docker_version
        done
    else
        for image in aai-resources aai-traversal search-data-service data-router model-loader sparky-be; do
            pull_onap_image $image $aai_docker_version &
        done
        wait_docker_pull
    fi
}

# init_aai() - Function that initialize AAI services
function init_aai {
    if [[ "$clone_repo" == "True" ]]; then
        clone_repos "aai"
        if [[ "$compile_repo" == "True" ]]; then
            compile_aai_repos
        fi
    fi

    if [[ "$skip_get_images" == "False" ]]; then
        get_aai_images
        if [[ "$skip_install" == "False" ]]; then
            install_hadoop
            install_haproxy
            setup_titan
            #start_aai_microservices
            install_aai
        fi
    fi
}