blob: d048c2b8c5cd132976060ab7d0d7e526d115c64f [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05006source /var/onap/asserts
Victor Morales89ce3212017-06-16 18:32:48 -05007
8hbase_version=1.2.3
9
Victor Moralesdd074802017-07-26 16:06:35 -050010# clone_all_aai_repos() - Function that clones AAI source repo.
11function clone_all_aai_repos {
12 local src_folder=/opt/aai
13
14 for dirc in aai-common aai-config aai-data aai-service data-router logging-service model-loader resources rest-client router-core search-data-service sparky-be sparky-fe test-config traversal; do
15 clone_repo aai/$dirc $src_folder/$dirc
16 done
17}
18
19# compile_all_aai_repos() - Function that compiles AAI source repo.
20function compile_all_aai_repos {
21 local src_folder=/opt/aai
22
23 for dirc in aai-common aai-config aai-data aai-service data-router logging-service model-loader resources rest-client router-core search-data-service sparky-be sparky-fe test-config traversal; do
24 compile_src $src_folder/$dirc
25 done
26}
27
Victor Morales89ce3212017-06-16 18:32:48 -050028# pull_hbase_image() - Pull HBase container image from a Docker Registry Hub
29function pull_hbase_image {
Victor Moralesdd074802017-07-26 16:06:35 -050030 docker_openecomp_login
Victor Morales89ce3212017-06-16 18:32:48 -050031 docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
32}
33
34# install_hbase() - Install HBase Service
35function install_hbase {
36 docker rm -f hbase
37 pull_hbase_image
38 docker run -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version}
39}
40
41# install_ajsc() - Install ASJC Java service container
42function install_ajsc_aai {
Victor Moralesdd074802017-07-26 16:06:35 -050043 local src_folder=/opt/aai/aai-service
Victor Morales89ce3212017-06-16 18:32:48 -050044 cat <<EOL > /etc/ajsc-aai.conf
45AAI_REPO_PATH=r/aai
46AAI_CHEF_ENV=simpledemo
47AAI_CHEF_LOC=/var/chef/aai-data/environments
48docker_gitbranch=master
49EOL
50 docker rm -f aai-service
Victor Moralesdd074802017-07-26 16:06:35 -050051 if [[ "$build_image" == "True" ]]; then
52 clone_repo aai/aai-service $src_folder
53 build_docker_image $src_folder/ajsc-aai
54 else
55 pull_openecomp_image ajsc-aai
56 fi
57
58 asserts_image openecomp/ajsc-aai
59
Victor Morales89ce3212017-06-16 18:32:48 -050060 docker run --env-file /etc/ajsc-aai.conf --name=aai-service --net=host -v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt -it -d $nexus_docker_repo/openecomp/ajsc-aai:$docker_version
61}
62
63# install_model_loader() Install Model Loader
64function install_model_loader {
65 local src_folder=/opt/aai/model-loader/
66 cat <<EOL > /etc/model-loader.conf
67DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443}
68DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup}
69DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB}
70DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic}
71DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp}
72DISTR_CLIENT_USER=${SDC_USER:-aai}
73
74APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443}
75APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader}
76APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
77APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw}
78EOL
79
Victor Moralesdd074802017-07-26 16:06:35 -050080 ARGS=""
81
Victor Morales89ce3212017-06-16 18:32:48 -050082 docker rm -f model-loader-service
83 if [[ "$build_image" == "True" ]]; then
84 clone_repo aai/model-loader $src_folder
85 build_docker_image $src_folder
Victor Moralesdd074802017-07-26 16:06:35 -050086 ARGS+="--env-file /etc/model-loader.conf model-loader"
Victor Morales89ce3212017-06-16 18:32:48 -050087 else
88 pull_openecomp_image model-loader
Victor Moralesdd074802017-07-26 16:06:35 -050089 ARGS+="--name=model-loader-service -it -d --env-file /etc/model-loader.conf $nexus_docker_repo/openecomp/model-loader:$docker_version"
Victor Morales89ce3212017-06-16 18:32:48 -050090 fi
Victor Moralesdd074802017-07-26 16:06:35 -050091 asserts_image openecomp/model-loader
92 docker run ${ARGS}
Victor Morales89ce3212017-06-16 18:32:48 -050093}
94
95# wait_for_sdc() - Function that determines if SDC is up and running
96function wait_for_sdc {
97 if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then
98 SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt)
99 else
100 SDC_IP_ADDR="10.0.3.1"
101 fi
102
103 # Run Health Check against SDC and verify that all five components are up
104 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
105 while [[ $RES -lt 5 ]]; do
106 RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK")
107 done
108}
109
110# init_aai() - Function that initialize AAI services
111function init_aai {
112 mkdir -p /opt/openecomp/aai/logs
113 mkdir -p /opt/openecomp/aai/data
114
Victor Moralesdd074802017-07-26 16:06:35 -0500115 clone_all_aai_repos
116 if [[ "$compile_repo" == "True" ]]; then
117 compile_all_aai_repos
118 fi
119
Victor Morales89ce3212017-06-16 18:32:48 -0500120 install_hbase
121
122 # Wait 3 minutes before instantiating the A&AI container
123 sleep 180
124
125 install_ajsc_aai
126 wait_for_sdc
127 install_model_loader
128}