aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/aai
blob: 316a981ff042aa24b22c939bbb45b80fc739f0e1 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/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
}