aboutsummaryrefslogtreecommitdiffstats
path: root/lib/aai
blob: c0e18374536766a32e5a0a19f6750e537b2e3700 (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
128
129
130
131
132
133
134
135
#!/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_janus() - Function that configures AAI services to connect to JanusGraph
function setup_janus {
    local subdirectory="src/main/resources/etc/appprops"
    install_python_package crudini

    for repo in resources/aai-resources traversal/aai-traversal graphadmin; do
        for file in janusgraph-cached.properties janus-realtime.properties; do
            crudini --set "${src_folders[aai]}/$repo/$subdirectory/$file" "" "storage.backend" "cassandra"
            crudini --set "${src_folders[aai]}/$repo/$subdirectory/$file" "" "storage.hostname" "localhost"
            crudini --set "${src_folders[aai]}/$repo/$subdirectory/$file" "" "storage.cassandra.keyspace" "onap"
        done
    done

    # Add the schema to the local instance
    for repo in aai-common resources traversal graphadmin logging-service; do
        compile_src ${src_folders[aai]}/$repo
    done
    export PROJECT_HOME=$(find ${src_folders[aai]} -name "aai-graphadmin-*build" -print -quit)
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
    sh /var/onap/files/createDbSchemaLocal.sh
}

# _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"
    java -DAJSC_HOME=aai-$service -DBUNDLECONFIG_DIR=src/main/resources/ -jar $(find ${src_folders[aai]}/$service -name "aai-$service-*-SNAPSHOT.jar" -print -quit) &
    popd
    sleep 180
}

# start_aai_microservices() - Function that starts AAI microservices
function start_aai_microservices {
    _start_data_managment resources 9446
    pushd /var/onap/files/
    install_package jq
    ./test-complex
    popd
    _start_data_managment traversal 9447
}

# install_aai() - Install AAI Services
function install_aai {
    install_nodejs
    install_maven
    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_janus
            start_aai_microservices
            #install_aai
        fi
    fi
}