Update stage_3 to use multi-stack install
[osm/devops.git] / installers / full_install_osm.sh
1 #!/bin/bash
2 # Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 function usage(){
17 echo -e "usage: $0 [OPTIONS]"
18 echo -e "Install OSM from binaries or source code (by default, from binaries)"
19 echo -e " OPTIONS"
20 echo -e " -r <repo>: use specified repository name for osm packages"
21 echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
22 echo -e " -u <repo base>: use specified repository url for osm packages"
23 echo -e " -k <repo key>: use specified repository public key url"
24 echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
25 echo -e " -b master (main dev branch)"
26 echo -e " -b v2.0 (v2.0 branch)"
27 echo -e " -b tags/v1.1.0 (a specific tag)"
28 echo -e " ..."
29 echo -e " -s <stack name> user defined stack name, default is osm"
30 echo -e " -H <VCA host> use specific juju host controller IP"
31 echo -e " -S <VCA secret> use VCA/juju secret key"
32 echo -e " --vimemu: additionally deploy the VIM emulator as a docker container"
33 echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging"
34 echo -e " --pm_stack: additionally deploy a Prometheus+Grafana stack for performance monitoring (PM)"
35 echo -e " -m <MODULE>: install OSM but only rebuild the specified docker images (RO, LCM, NBI, LW-UI, MON, KAFKA, MONGO, NONE)"
36 echo -e " -o <ADDON>: ONLY (un)installs one of the addons (vimemu, elk_stack, pm_stack)"
37 echo -e " -D <devops path> use local devops installation path"
38 echo -e " -w <work dir> Location to store runtime installation"
39 echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
40 echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
41 echo -e " --nojuju: do not juju, assumes already installed"
42 echo -e " --nodockerbuild:do not build docker images (use existing locally cached images)"
43 echo -e " --nohostports: do not expose docker ports to host (useful for creating multiple instances of osm on the same host)"
44 echo -e " --nohostclient: do not install the osmclient"
45 echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
46 echo -e " --source: install OSM from source code using the latest stable tag"
47 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
48 echo -e " --soui: install classic build of OSM (Rel THREE v3.1, based on LXD containers, with SO and UI)"
49 echo -e " --lxdimages: (only for Rel THREE with --soui) download lxd images from OSM repository instead of creating them from scratch"
50 echo -e " -l <lxd_repo>: (only for Rel THREE with --soui) use specified repository url for lxd images"
51 echo -e " -p <path>: (only for Rel THREE with --soui) use specified repository path for lxd images"
52 # echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
53 echo -e " --nat: (only for Rel THREE with --soui) install only NAT rules"
54 echo -e " --noconfigure: (only for Rel THREE with --soui) DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
55 # echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
56 echo -e " --showopts: print chosen options and exit (only for debugging)"
57 echo -e " -y: do not prompt for confirmation, assumes yes"
58 echo -e " -h / --help: print this help"
59 }
60
61 #Uninstall OSM: remove containers
62 function uninstall(){
63 echo -e "\nUninstalling OSM"
64 if [ $RC_CLONE ] || [ -n "$TEST_INSTALLER" ]; then
65 $OSM_DEVOPS/jenkins/host/clean_container RO
66 $OSM_DEVOPS/jenkins/host/clean_container VCA
67 $OSM_DEVOPS/jenkins/host/clean_container MON
68 $OSM_DEVOPS/jenkins/host/clean_container SO
69 #$OSM_DEVOPS/jenkins/host/clean_container UI
70 else
71 lxc stop RO && lxc delete RO
72 lxc stop VCA && lxc delete VCA
73 lxc stop MON && lxc delete MON
74 lxc stop SO-ub && lxc delete SO-ub
75 fi
76 echo -e "\nDeleting imported lxd images if they exist"
77 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
78 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
79 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
80 return 0
81 }
82
83 # takes a juju/accounts.yaml file and returns the password specific
84 # for a controller. I wrote this using only bash tools to minimize
85 # additions of other packages
86 function parse_juju_password {
87 password_file="${HOME}/.local/share/juju/accounts.yaml"
88 local controller_name=$1
89 local s='[[:space:]]*' w='[a-zA-Z0-9_-]*' fs=$(echo @|tr @ '\034')
90 sed -ne "s|^\($s\):|\1|" \
91 -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
92 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $password_file |
93 awk -F$fs -v controller=$controller_name '{
94 indent = length($1)/2;
95 vname[indent] = $2;
96 for (i in vname) {if (i > indent) {delete vname[i]}}
97 if (length($3) > 0) {
98 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
99 if (match(vn,controller) && match($2,"password")) {
100 printf("%s",$3);
101 }
102 }
103 }'
104 }
105
106 function remove_volumes() {
107 stack=$1
108 volumes="mongo_db mon_db osm_packages ro_db"
109 for volume in $volumes; do
110 sg docker -c "docker volume rm ${stack}_${volume}"
111 done
112 }
113
114 function remove_network() {
115 stack=$1
116 sg docker -c "docker network rm net${stack}"
117 }
118
119 function remove_stack() {
120 stack=$1
121 if sg docker -c "docker stack ps ${stack}" ; then
122 echo -e "\nRemoving stack ${stack}" && sg docker -c "docker stack rm ${stack}"
123 COUNTER=0
124 result=1
125 while [ ${COUNTER} -lt 30 ]; do
126 result=$(sg docker -c "docker stack ps ${stack}" | wc -l)
127 #echo "Dockers running: $result"
128 if [ "${result}" == "0" ]; then
129 break
130 fi
131 let COUNTER=COUNTER+1
132 sleep 1
133 done
134 if [ "${result}" == "0" ]; then
135 echo "All dockers of the stack ${stack} were removed"
136 else
137 FATAL "Some dockers of the stack ${stack} could not be removed. Could not clean it."
138 fi
139 sleep 5
140 fi
141 }
142
143 #Uninstall lightweight OSM: remove dockers
144 function uninstall_lightweight() {
145 if [ -n "$INSTALL_ONLY" ]; then
146 if [ -n "$INSTALL_ELK" ]; then
147 echo -e "\nUninstalling OSM ELK stack"
148 remove_stack osm_elk
149 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR/osm_elk
150 fi
151 if [ -n "$INSTALL_PERFMON" ]; then
152 echo -e "\nUninstalling OSM Performance Monitoring stack"
153 remove_stack osm_metrics
154 sg docker -c "docker image rm osm/kafka-exporter"
155 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR/osm_metrics
156 fi
157 else
158 echo -e "\nUninstalling OSM"
159 remove_stack $OSM_STACK_NAME
160 remove_stack osm_elk
161 remove_stack osm_metrics
162 echo "Now osm docker images and volumes will be deleted"
163 newgrp docker << EONG
164 docker image rm osm/ro
165 docker image rm osm/lcm
166 docker image rm osm/light-ui
167 docker image rm osm/nbi
168 docker image rm osm/mon
169 docker image rm osm/pm
170 docker image rm osm/kafka-exporter
171 EONG
172 remove_volumes $OSM_STACK_NAME
173 remove_network $OSM_STACK_NAME
174 echo "Removing $OSM_DOCKER_WORK_DIR"
175 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR
176 sg lxd -c "juju destroy-controller --yes $OSM_STACK_NAME"
177 fi
178 echo "Some docker images will be kept in case they are used by other docker stacks"
179 echo "To remove them, just run 'docker image prune' in a terminal"
180 return 0
181 }
182
183 #Configure NAT rules, based on the current IP addresses of containers
184 function nat(){
185 echo -e "\nChecking required packages: iptables-persistent"
186 dpkg -l iptables-persistent &>/dev/null || ! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
187 sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install iptables-persistent
188 echo -e "\nConfiguring NAT rules"
189 echo -e " Required root privileges"
190 sudo $OSM_DEVOPS/installers/nat_osm
191 }
192
193 function FATAL(){
194 echo "FATAL error: Cannot install OSM due to \"$1\""
195 exit 1
196 }
197
198 #Update RO, SO and UI:
199 function update(){
200 echo -e "\nUpdating components"
201
202 echo -e " Updating RO"
203 CONTAINER="RO"
204 MDG="RO"
205 INSTALL_FOLDER="/opt/openmano"
206 echo -e " Fetching the repo"
207 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
208 BRANCH=""
209 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
210 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
211 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
212 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
213 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
214 # COMMIT_ID either was previously set with -b option, or is an empty string
215 CHECKOUT_ID=$COMMIT_ID
216 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
217 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
218 if [[ $CHECKOUT_ID == "tags/"* ]]; then
219 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
220 else
221 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
222 fi
223 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
224 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
225 echo " Nothing to be done."
226 else
227 echo " Update required."
228 lxc exec $CONTAINER -- service osm-ro stop
229 lxc exec $CONTAINER -- git -C /opt/openmano stash
230 lxc exec $CONTAINER -- git -C /opt/openmano pull --rebase
231 lxc exec $CONTAINER -- git -C /opt/openmano checkout $CHECKOUT_ID
232 lxc exec $CONTAINER -- git -C /opt/openmano stash pop
233 lxc exec $CONTAINER -- /opt/openmano/database_utils/migrate_mano_db.sh
234 lxc exec $CONTAINER -- service osm-ro start
235 fi
236 echo
237
238 echo -e " Updating SO and UI"
239 CONTAINER="SO-ub"
240 MDG="SO"
241 INSTALL_FOLDER="" # To be filled in
242 echo -e " Fetching the repo"
243 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
244 BRANCH=""
245 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
246 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
247 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
248 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
249 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
250 # COMMIT_ID either was previously set with -b option, or is an empty string
251 CHECKOUT_ID=$COMMIT_ID
252 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
253 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
254 if [[ $CHECKOUT_ID == "tags/"* ]]; then
255 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
256 else
257 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
258 fi
259 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
260 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
261 echo " Nothing to be done."
262 else
263 echo " Update required."
264 # Instructions to be added
265 # lxc exec SO-ub -- ...
266 fi
267 echo
268 echo -e "Updating MON Container"
269 CONTAINER="MON"
270 MDG="MON"
271 INSTALL_FOLDER="/root/MON"
272 echo -e " Fetching the repo"
273 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
274 BRANCH=""
275 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
276 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
277 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
278 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
279 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
280 # COMMIT_ID either was previously set with -b option, or is an empty string
281 CHECKOUT_ID=$COMMIT_ID
282 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
283 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
284 if [[ $CHECKOUT_ID == "tags/"* ]]; then
285 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
286 else
287 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
288 fi
289 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
290 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
291 echo " Nothing to be done."
292 else
293 echo " Update required."
294 fi
295 echo
296 }
297
298 function so_is_up() {
299 if [ -n "$1" ]; then
300 SO_IP=$1
301 else
302 SO_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
303 fi
304 time=0
305 step=5
306 timelength=300
307 while [ $time -le $timelength ]
308 do
309 if [[ `curl -k -X GET https://$SO_IP:8008/api/operational/vcs/info \
310 -H 'accept: application/vnd.yang.data+json' \
311 -H 'authorization: Basic YWRtaW46YWRtaW4=' \
312 -H 'cache-control: no-cache' 2> /dev/null | jq '.[].components.component_info[] | select(.component_name=="RW.Restconf")' 2>/dev/null | grep "RUNNING" | wc -l` -eq 1 ]]
313 then
314 echo "RW.Restconf running....SO is up"
315 return 0
316 fi
317
318 sleep $step
319 echo -n "."
320 time=$((time+step))
321 done
322
323 FATAL "OSM Failed to startup. SO failed to startup"
324 }
325
326 function vca_is_up() {
327 if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
328 echo "VCA is up and running"
329 return 0
330 fi
331
332 FATAL "OSM Failed to startup. VCA failed to startup"
333 }
334
335 function mon_is_up() {
336 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
337 echo "MON is up and running"
338 return 0
339 fi
340
341 FATAL "OSM Failed to startup. MON failed to startup"
342 }
343
344 function ro_is_up() {
345 if [ -n "$1" ]; then
346 RO_IP=$1
347 else
348 RO_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
349 fi
350 time=0
351 step=2
352 timelength=20
353 while [ $time -le $timelength ]; do
354 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
355 echo "RO is up and running"
356 return 0
357 fi
358 sleep $step
359 echo -n "."
360 time=$((time+step))
361 done
362
363 FATAL "OSM Failed to startup. RO failed to startup"
364 }
365
366
367 function configure_RO(){
368 . $OSM_DEVOPS/installers/export_ips
369 echo -e " Configuring RO"
370 lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc/osm/openmanod.cfg
371 lxc exec RO -- service osm-ro restart
372
373 ro_is_up
374
375 lxc exec RO -- openmano tenant-delete -f osm >/dev/null
376 lxc exec RO -- openmano tenant-create osm > /dev/null
377 lxc exec RO -- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
378 lxc exec RO -- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
379 lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
380 }
381
382 function configure_VCA(){
383 echo -e " Configuring VCA"
384 JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
385 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
386 }
387
388 function configure_SOUI(){
389 . $OSM_DEVOPS/installers/export_ips
390 JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
391 RO_TENANT_ID=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
392
393 echo -e " Configuring MON"
394 #Information to be added about SO socket for logging
395
396 echo -e " Configuring SO"
397 sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP
398 sudo ip route add 10.44.127.0/24 via $VCA_CONTAINER_IP
399 sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local
400 sudo sed -i "$ i ip route add 10.44.127.0/24 via $VCA_CONTAINER_IP" /etc/rc.local
401 # make journaling persistent
402 lxc exec SO-ub -- mkdir -p /var/log/journal
403 lxc exec SO-ub -- systemd-tmpfiles --create --prefix /var/log/journal
404 lxc exec SO-ub -- systemctl restart systemd-journald
405
406 echo RIFT_EXTERNAL_ADDRESS=$DEFAULT_IP | lxc exec SO-ub -- tee -a /usr/rift/etc/default/launchpad
407
408 lxc exec SO-ub -- systemctl restart launchpad
409
410 so_is_up $SO_CONTAINER_IP
411
412 #delete existing config agent (could be there on reconfigure)
413 curl -k --request DELETE \
414 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent/account/osmjuju \
415 --header 'accept: application/vnd.yang.data+json' \
416 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
417 --header 'cache-control: no-cache' \
418 --header 'content-type: application/vnd.yang.data+json' &> /dev/null
419
420 result=$(curl -k --request POST \
421 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent \
422 --header 'accept: application/vnd.yang.data+json' \
423 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
424 --header 'cache-control: no-cache' \
425 --header 'content-type: application/vnd.yang.data+json' \
426 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}')
427 [[ $result =~ .*success.* ]] || FATAL "Failed config-agent configuration: $result"
428
429 #R1/R2 config line
430 #result=$(curl -k --request PUT \
431 # --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \
432 # --header 'accept: application/vnd.yang.data+json' \
433 # --header 'authorization: Basic YWRtaW46YWRtaW4=' \
434 # --header 'cache-control: no-cache' \
435 # --header 'content-type: application/vnd.yang.data+json' \
436 # --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }')
437
438 result=$(curl -k --request PUT \
439 --url https://$SO_CONTAINER_IP:8008/api/config/project/default/ro-account/account \
440 --header 'accept: application/vnd.yang.data+json' \
441 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
442 --header 'cache-control: no-cache' \
443 --header 'content-type: application/vnd.yang.data+json' \
444 --data '{"rw-ro-account:account": [ { "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'"}, "name": "osmopenmano", "ro-account-type": "openmano" }]}')
445 [[ $result =~ .*success.* ]] || FATAL "Failed resource-orchestrator configuration: $result"
446
447 result=$(curl -k --request PATCH \
448 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/redirect-uri \
449 --header 'accept: application/vnd.yang.data+json' \
450 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
451 --header 'cache-control: no-cache' \
452 --header 'content-type: application/vnd.yang.data+json' \
453 --data '{"redirect-uri": "https://'$DEFAULT_IP':8443/callback" }')
454 [[ $result =~ .*success.* ]] || FATAL "Failed redirect-uri configuration: $result"
455
456 result=$(curl -k --request PATCH \
457 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/post-logout-redirect-uri \
458 --header 'accept: application/vnd.yang.data+json' \
459 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
460 --header 'cache-control: no-cache' \
461 --header 'content-type: application/vnd.yang.data+json' \
462 --data '{"post-logout-redirect-uri": "https://'$DEFAULT_IP':8443/?api_server=https://'$DEFAULT_IP'" }')
463 [[ $result =~ .*success.* ]] || FATAL "Failed post-logout-redirect-uri configuration: $result"
464
465 lxc exec SO-ub -- tee /etc/network/interfaces.d/60-rift.cfg <<EOF
466 auto lo:1
467 iface lo:1 inet static
468 address $DEFAULT_IP
469 netmask 255.255.255.255
470 EOF
471 lxc exec SO-ub ifup lo:1
472 }
473
474 #Configure RO, VCA, and SO with the initial configuration:
475 # RO -> tenant:osm, logs to be sent to SO
476 # VCA -> juju-password
477 # SO -> route to Juju Controller, add RO account, add VCA account
478 function configure(){
479 #Configure components
480 echo -e "\nConfiguring components"
481 configure_RO
482 configure_VCA
483 configure_SOUI
484 }
485
486 function install_lxd() {
487 sudo apt-get update
488 sudo apt-get install -y lxd
489 newgrp lxd
490 lxd init --auto
491 lxd waitready
492 lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
493 DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
494 DEFAULT_MTU=$(ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
495 lxc profile device set default eth0 mtu $DEFAULT_MTU
496 #sudo systemctl stop lxd-bridge
497 #sudo systemctl --system daemon-reload
498 #sudo systemctl enable lxd-bridge
499 #sudo systemctl start lxd-bridge
500 }
501
502 function ask_user(){
503 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
504 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
505 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
506 read -e -p "$1" USER_CONFIRMATION
507 while true ; do
508 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
509 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
510 [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
511 [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
512 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
513 done
514 }
515
516 function launch_container_from_lxd(){
517 export OSM_MDG=$1
518 OSM_load_config
519 export OSM_BASE_IMAGE=$2
520 if ! container_exists $OSM_BUILD_CONTAINER; then
521 CONTAINER_OPTS=""
522 [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true"
523 [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true"
524 create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
525 wait_container_up $OSM_BUILD_CONTAINER
526 fi
527 }
528
529 function install_osmclient(){
530 CLIENT_RELEASE=${RELEASE#"-R "}
531 CLIENT_REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
532 CLIENT_REPOSITORY=${REPOSITORY#"-r "}
533 CLIENT_REPOSITORY_BASE=${REPOSITORY_BASE#"-u "}
534 key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
535 curl $key_location | sudo apt-key add -
536 sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
537 sudo apt-get update
538 sudo apt-get install -y python-pip
539 sudo -H pip install pip==9.0.3
540 sudo -H pip install python-magic
541 sudo apt-get install -y python-osmclient
542 #sed 's,OSM_SOL005=[^$]*,OSM_SOL005=True,' -i ${HOME}/.bashrc
543 #echo 'export OSM_HOSTNAME=localhost' >> ${HOME}/.bashrc
544 #echo 'export OSM_SOL005=True' >> ${HOME}/.bashrc
545 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
546 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
547 [ -n "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=127.0.0.1
548 echo -e "\nOSM client installed"
549 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
550 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
551 [ -n "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_SOL005=True"
552 [ -z "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
553 return 0
554 }
555
556 function install_from_lxdimages(){
557 LXD_RELEASE=${RELEASE#"-R "}
558 if [ -n "$LXD_REPOSITORY_PATH" ]; then
559 LXD_IMAGE_DIR="$LXD_REPOSITORY_PATH"
560 else
561 LXD_IMAGE_DIR="$(mktemp -d -q --tmpdir "osmimages.XXXXXX")"
562 trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
563 fi
564 echo -e "\nDeleting previous lxd images if they exist"
565 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
566 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
567 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
568 echo -e "\nImporting osm-ro"
569 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-ro.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.tar.gz
570 lxc image import $LXD_IMAGE_DIR/osm-ro.tar.gz --alias osm-ro
571 rm -f $LXD_IMAGE_DIR/osm-ro.tar.gz
572 echo -e "\nImporting osm-vca"
573 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-vca.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.tar.gz
574 lxc image import $LXD_IMAGE_DIR/osm-vca.tar.gz --alias osm-vca
575 rm -f $LXD_IMAGE_DIR/osm-vca.tar.gz
576 echo -e "\nImporting osm-soui"
577 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-soui.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.tar.gz
578 lxc image import $LXD_IMAGE_DIR/osm-soui.tar.gz --alias osm-soui
579 rm -f $LXD_IMAGE_DIR/osm-soui.tar.gz
580 launch_container_from_lxd RO osm-ro
581 ro_is_up && track RO
582 launch_container_from_lxd VCA osm-vca
583 vca_is_up && track VCA
584 launch_container_from_lxd MON osm-mon
585 mon_is_up && track MON
586 launch_container_from_lxd SO osm-soui
587 #so_is_up && track SOUI
588 track SOUI
589 }
590
591 function install_docker_ce() {
592 # installs and configures Docker CE
593 echo "Installing Docker CE ..."
594 sudo apt-get -qq update
595 sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
596 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
597 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
598 sudo apt-get -qq update
599 sudo apt-get install -y docker-ce
600 echo "Adding user to group 'docker'"
601 sudo groupadd -f docker
602 sudo usermod -aG docker $USER
603 sleep 2
604 sudo service docker restart
605 echo "... restarted Docker service"
606 sg docker -c "docker version" || FATAL "Docker installation failed"
607 echo "... Docker CE installation done"
608 return 0
609 }
610
611 function install_docker_compose() {
612 # installs and configures docker-compose
613 echo "Installing Docker Compose ..."
614 sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
615 sudo chmod +x /usr/local/bin/docker-compose
616 echo "... Docker Compose installation done"
617 }
618
619 function install_juju() {
620 echo "Installing juju"
621 sudo snap install juju --classic
622 [ -z "$INSTALL_NOLXD" ] && sudo dpkg-reconfigure -p medium lxd
623 echo "Finished installation of juju"
624 return 0
625 }
626
627 function juju_createcontroller() {
628 if ! sg lxd -c "juju show-controller $OSM_STACK_NAME &> /dev/null"; then
629 # Not found created, create the controller
630 sg lxd -c "juju bootstrap --bootstrap-series=xenial localhost $OSM_STACK_NAME"
631 fi
632 [ $(sg lxd -c "juju controllers" |grep "$OSM_STACK_NAME" |wc -l) -eq 1 ] || FATAL "Juju installation failed"
633 }
634
635 function generate_docker_images() {
636 echo "Pulling and generating docker images"
637 _build_from=$COMMIT_ID
638 [ -z "$_build_from" ] && _build_from="master"
639
640 echo "OSM Docker images generated from $_build_from"
641
642 BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY")
643 BUILD_ARGS+=(--build-arg RELEASE="$RELEASE")
644 BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY")
645 BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE")
646
647 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then
648 sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image"
649 sg docker -c "docker pull wurstmeister/kafka" || FATAL "cannot get kafka docker image"
650 fi
651 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MONGO ; then
652 sg docker -c "docker pull mongo" || FATAL "cannot get mongo docker image"
653 fi
654 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MON ; then
655 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON
656 git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID}
657 sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL "cannot build MON docker image"
658 sg docker -c "docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm --no-cache" || FATAL "cannot build PM docker image"
659 fi
660 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI ; then
661 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI
662 git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID}
663 sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL "cannot build NBI docker image"
664 fi
665 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then
666 sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image"
667 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO
668 git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID}
669 sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL "cannot build RO docker image"
670 fi
671 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LCM ; then
672 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM
673 git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID}
674 sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL "cannot build LCM docker image"
675 fi
676 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-UI ; then
677 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI
678 git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID}
679 sg docker -c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile --no-cache" || FATAL "cannot build LW-UI docker image"
680 fi
681 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-osmclient; then
682 sg docker -c "docker build -t osm/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
683 fi
684 echo "Finished generation of docker images"
685 }
686
687 function cmp_overwrite() {
688 file1="$1"
689 file2="$2"
690 if ! $(cmp "${file1}" "${file2}" >/dev/null 2>&1); then
691 if [ -f "${file2}" ]; then
692 ask_user "The file ${file2} already exists. Overwrite (y/N)? " n && cp -b ${file1} ${file2}
693 else
694 cp -b ${file1} ${file2}
695 fi
696 fi
697 }
698
699 function generate_config_log_folders() {
700 echo "Generating config and log folders"
701 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml
702 echo "Finished generation of config and log folders"
703 }
704
705 function generate_docker_env_files() {
706 echo "Generating docker env files"
707 echo "OSMLCM_VCA_HOST=${OSMLCM_VCA_HOST}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/lcm.env
708 echo "OSMLCM_VCA_SECRET=${OSMLCM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
709
710 MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
711 if [ ! -f $OSM_DOCKER_WORK_DIR/ro-db.env ]; then
712 echo "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro-db.env
713 fi
714 if [ ! -f $OSM_DOCKER_WORK_DIR/ro.env ]; then
715 echo "RO_DB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro.env
716 fi
717 echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/mon.env
718
719 echo "Finished generation of docker env files"
720 }
721
722 function generate_osmclient_script () {
723 echo "docker run -ti --network net${OSM_STACK_NAME} osm/osmclient" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm
724 $WORKDIR_SUDO chmod +x "$OSM_DOCKER_WORK_DIR/osm"
725 echo "osmclient sidecar container can be found at: $OSM_DOCKER_WORK_DIR/osm"
726 }
727
728 function init_docker_swarm() {
729 if [ "${DEFAULT_MTU}" != "1500" ]; then
730 DOCKER_NETS=`sg docker -c "docker network list" | awk '{print $2}' | egrep -v "^ID$" | paste -d " " -s`
731 DOCKER_GW_NET=`sg docker -c "docker network inspect ${DOCKER_NETS}" | grep Subnet | awk -F\" '{print $4}' | egrep "^172" | sort -u | tail -1 | awk -F\. '{if ($2 != 255) print $1"."$2+1"."$3"."$4; else print "-1";}'`
732 sg docker -c "docker network create --subnet ${DOCKER_GW_NET} --opt com.docker.network.bridge.name=docker_gwbridge --opt com.docker.network.bridge.enable_icc=false --opt com.docker.network.bridge.enable_ip_masquerade=true --opt com.docker.network.driver.mtu=${DEFAULT_MTU} docker_gwbridge"
733 fi
734 sg docker -c "docker swarm init --advertise-addr ${DEFAULT_IP}"
735 return 0
736 }
737
738 function create_docker_network() {
739 echo "creating network"
740 sg docker -c "docker network create --driver=overlay --attachable --opt com.docker.network.driver.mtu=${DEFAULT_MTU} net${OSM_STACK_NAME}"
741 echo "creating network DONE"
742 }
743
744 function deploy_lightweight() {
745
746 echo "Deploying lightweight build"
747 OSM_NBI_PORT=9999
748 OSM_RO_PORT=9090
749 OSM_UI_PORT=80
750
751 if [ -n "$NO_HOST_PORTS" ]; then
752 OSM_PORTS+=(OSM_NBI_PORTS=$OSM_NBI_PORT)
753 OSM_PORTS+=(OSM_RO_PORTS=$OSM_RO_PORT)
754 OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT)
755 else
756 OSM_PORTS+=(OSM_NBI_PORTS=$OSM_NBI_PORT:$OSM_NBI_PORT)
757 OSM_PORTS+=(OSM_RO_PORTS=$OSM_RO_PORT:$OSM_RO_PORT)
758 OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT:$OSM_UI_PORT)
759 fi
760 echo "export ${OSM_PORTS[@]}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm_ports.sh
761 echo "export OSM_NETWORK=net${OSM_STACK_NAME}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
762
763 pushd $OSM_DOCKER_WORK_DIR
764 sg docker -c "source ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml $OSM_STACK_NAME"
765 popd
766
767 echo "Finished deployment of lightweight build"
768 }
769
770 function deploy_elk() {
771 echo "Pulling docker images for ELK"
772 sg docker -c "docker pull docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3" || FATAL "cannot get elasticsearch docker image"
773 sg docker -c "docker pull docker.elastic.co/logstash/logstash-oss:6.2.3" || FATAL "cannot get logstash docker image"
774 sg docker -c "docker pull docker.elastic.co/kibana/kibana-oss:6.2.3" || FATAL "cannot get kibana docker image"
775 echo "Finished pulling elk docker images"
776 $WORKDIR_SUDO mkdir -p "$OSM_DOCKER_WORK_DIR/osm_elk"
777 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_elk/* $OSM_DOCKER_WORK_DIR/osm_elk
778 remove_stack osm_elk
779 echo "Deploying ELK stack"
780 sg docker -c "OSM_NETWORK=net${OSM_STACK_NAME} docker stack deploy -c $OSM_DOCKER_WORK_DIR/osm_elk/docker-compose.yml osm_elk"
781 echo "Waiting for ELK stack to be up and running"
782 time=0
783 step=5
784 timelength=40
785 elk_is_up=1
786 while [ $time -le $timelength ]; do
787 if [[ $(curl -f -XGET http://127.0.0.1:5601/status -I 2>/dev/null | grep "HTTP/1.1 200 OK" | wc -l ) -eq 1 ]]; then
788 elk_is_up=0
789 break
790 fi
791 sleep $step
792 time=$((time+step))
793 done
794 if [ $elk_is_up -eq 0 ]; then
795 echo "ELK is up and running. Trying to create index pattern..."
796 #Create index pattern
797 curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
798 "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
799 -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}" 2>/dev/null
800 #Make it the default index
801 curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
802 "http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
803 -d"{\"value\":\"logstash-*\"}" 2>/dev/null
804 else
805 echo "Cannot connect to Kibana to create index pattern."
806 echo "Once Kibana is running, you can use the following instructions to create index pattern:"
807 echo 'curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
808 "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
809 -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}"'
810 echo 'curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
811 "http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
812 -d"{\"value\":\"logstash-*\"}"'
813 fi
814 echo "Finished deployment of ELK stack"
815 return 0
816 }
817
818 function deploy_perfmon() {
819 echo "Pulling docker images for PM (Grafana and Prometheus)"
820 sg docker -c "docker pull prom/prometheus" || FATAL "cannot get prometheus docker image"
821 sg docker -c "docker pull grafana/grafana" || FATAL "cannot get grafana docker image"
822 echo "Finished pulling PM docker images"
823 echo "Generating osm/kafka-exporter docker image"
824 sg docker -c "docker build ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter -f ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter/Dockerfile -t osm/kafka-exporter --no-cache" || FATAL "cannot build kafka-exporter docker image"
825 echo "Finished generation of osm/kafka-exporter docker image"
826 $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/osm_metrics
827 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.yml $OSM_DOCKER_WORK_DIR/osm_metrics
828 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.json $OSM_DOCKER_WORK_DIR/osm_metrics
829 remove_stack osm_metrics
830 echo "Deploying PM stack (Kafka exporter + Prometheus + Grafana)"
831 sg docker -c "OSM_NETWORK=net${OSM_STACK_NAME} docker stack deploy -c $OSM_DOCKER_WORK_DIR/osm_metrics/docker-compose.yml osm_metrics"
832 echo "Finished deployment of PM stack"
833 return 0
834 }
835
836 function install_lightweight() {
837 OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
838 [ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
839
840 [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
841 [ -z "$ASSUME_YES" ] && ! ask_user "The installation will configure LXD, install juju, install docker CE and init a docker swarm, as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
842 track proceed
843 echo "Installing lightweight build of OSM"
844 LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
845 trap 'rm -rf "${LWTEMPDIR}"' EXIT
846 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
847 [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
848 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
849 [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
850 DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
851
852 # if no host is passed in, we need to install lxd/juju, unless explicilty asked not to
853 if [ -z "$OSMLCM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ]; then
854 need_packages_lw="lxd"
855 echo -e "Checking required packages: $need_packages_lw"
856 dpkg -l $need_packages_lw &>/dev/null \
857 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
858 || sudo apt-get update \
859 || FATAL "failed to run apt-get update"
860 dpkg -l $need_packages_lw &>/dev/null \
861 || ! echo -e "Installing $need_packages_lw requires root privileges." \
862 || sudo apt-get install -y $need_packages_lw \
863 || FATAL "failed to install $need_packages_lw"
864 fi
865 track prereqok
866 [ -z "$INSTALL_NOJUJU" ] && install_juju
867
868 if [ -z "$OSMLCM_VCA_HOST" ]; then
869 juju_createcontroller
870 OSMLCM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
871 [ -z "$OSMLCM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
872 fi
873 if [ -z "$OSMLCM_VCA_SECRET" ]; then
874 OSMLCM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
875 [ -z "$OSMLCM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
876 fi
877
878 track juju
879 [ -n "$INSTALL_NODOCKER" ] || install_docker_ce
880 track docker_ce
881 #install_docker_compose
882 [ -z "$DOCKER_NOBUILD" ] && generate_docker_images
883 track docker_build
884 generate_docker_env_files
885 generate_config_log_folders
886
887 [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
888 # remove old stack
889 remove_stack $OSM_STACK_NAME
890 create_docker_network
891 deploy_lightweight
892 generate_osmclient_script
893 track docker_deploy
894 [ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
895 [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
896 [ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
897 [ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
898 track osmclient
899 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
900 track end
901 return 0
902 }
903
904 function install_vimemu() {
905 echo "\nInstalling vim-emu"
906 EMUTEMPDIR="$(mktemp -d -q --tmpdir "installosmvimemu.XXXXXX")"
907 trap 'rm -rf "${EMUTEMPDIR}"' EXIT
908 # clone vim-emu repository (attention: branch is currently master only)
909 echo "Cloning vim-emu repository ..."
910 git clone https://osm.etsi.org/gerrit/osm/vim-emu.git $EMUTEMPDIR
911 # build vim-emu docker
912 echo "Building vim-emu Docker container..."
913
914 sg docker -c "docker build -t vim-emu-img -f $EMUTEMPDIR/Dockerfile --no-cache $EMUTEMPDIR/" || FATAL "cannot build vim-emu-img docker image"
915 # start vim-emu container as daemon
916 echo "Starting vim-emu Docker container 'vim-emu' ..."
917 if [ -n "$INSTALL_LIGHTWEIGHT" ]; then
918 # in lightweight mode, the emulator needs to be attached to netOSM
919 sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' --network=net${OSM_STACK_NAME} -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
920 else
921 # classic build mode
922 sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
923 fi
924 echo "Waiting for 'vim-emu' container to start ..."
925 sleep 5
926 export VIMEMU_HOSTNAME=$(sg docker -c "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu")
927 echo "vim-emu running at ${VIMEMU_HOSTNAME} ..."
928 # print vim-emu connection info
929 echo -e "\nYou might be interested in adding the following vim-emu env variables to your .bashrc file:"
930 echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
931 echo -e "To add the emulated VIM to OSM you should do:"
932 echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
933 }
934
935 function dump_vars(){
936 echo "DEVELOP=$DEVELOP"
937 echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
938 echo "UNINSTALL=$UNINSTALL"
939 echo "NAT=$NAT"
940 echo "UPDATE=$UPDATE"
941 echo "RECONFIGURE=$RECONFIGURE"
942 echo "TEST_INSTALLER=$TEST_INSTALLER"
943 echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
944 echo "INSTALL_LXD=$INSTALL_LXD"
945 echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
946 echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
947 echo "LXD_REPOSITORY_PATH=$LXD_REPOSITORY_PATH"
948 echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
949 echo "INSTALL_ONLY=$INSTALL_ONLY"
950 echo "INSTALL_ELK=$INSTALL_ELK"
951 echo "INSTALL_PERFMON=$INSTALL_PERFMON"
952 echo "TO_REBUILD=$TO_REBUILD"
953 echo "INSTALL_NOLXD=$INSTALL_NOLXD"
954 echo "INSTALL_NODOCKER=$INSTALL_NODOCKER"
955 echo "RELEASE=$RELEASE"
956 echo "REPOSITORY=$REPOSITORY"
957 echo "REPOSITORY_BASE=$REPOSITORY_BASE"
958 echo "REPOSITORY_KEY=$REPOSITORY_KEY"
959 echo "NOCONFIGURE=$NOCONFIGURE"
960 echo "SHOWOPTS=$SHOWOPTS"
961 echo "Install from specific refspec (-b): $COMMIT_ID"
962 }
963
964 function track(){
965 ctime=`date +%s`
966 duration=$((ctime - SESSION_ID))
967 url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
968 #url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
969 event_name="bin"
970 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_SOURCE" ] && event_name="binsrc"
971 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
972 [ -n "$INSTALL_LIGHTWEIGHT" ] && event_name="lw"
973 event_name="${event_name}_$1"
974 url="${url}&event=${event_name}&ce_duration=${duration}"
975 wget -q -O /dev/null $url
976 }
977
978 UNINSTALL=""
979 DEVELOP=""
980 NAT=""
981 UPDATE=""
982 RECONFIGURE=""
983 TEST_INSTALLER=""
984 INSTALL_LXD=""
985 SHOWOPTS=""
986 COMMIT_ID=""
987 ASSUME_YES=""
988 INSTALL_FROM_SOURCE=""
989 RELEASE="ReleaseFOUR"
990 REPOSITORY="stable"
991 INSTALL_VIMEMU=""
992 INSTALL_FROM_LXDIMAGES=""
993 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
994 LXD_REPOSITORY_PATH=""
995 INSTALL_LIGHTWEIGHT="y"
996 INSTALL_ONLY=""
997 INSTALL_ELK=""
998 INSTALL_PERFMON=""
999 TO_REBUILD=""
1000 INSTALL_NOLXD=""
1001 INSTALL_NODOCKER=""
1002 INSTALL_NOJUJU=""
1003 NOCONFIGURE=""
1004 RELEASE_DAILY=""
1005 SESSION_ID=`date +%s`
1006 OSM_DEVOPS=
1007 OSMLCM_VCA_HOST=
1008 OSMLCM_VCA_SECRET=
1009 OSM_STACK_NAME=osm
1010 NO_HOST_PORTS=""
1011 DOCKER_NOBUILD=""
1012 REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
1013 REPOSITORY_BASE="http://osm-download.etsi.org/repository/osm/debian"
1014 WORKDIR_SUDO=sudo
1015 OSM_WORK_DIR="/etc/osm"
1016
1017 while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:H:S:s:w:" o; do
1018 case "${o}" in
1019 h)
1020 usage && exit 0
1021 ;;
1022 b)
1023 COMMIT_ID=${OPTARG}
1024 ;;
1025 r)
1026 REPOSITORY="${OPTARG}"
1027 REPO_ARGS+=(-r "$REPOSITORY")
1028 ;;
1029 R)
1030 RELEASE="${OPTARG}"
1031 REPO_ARGS+=(-R "$RELEASE")
1032 ;;
1033 k)
1034 REPOSITORY_KEY="${OPTARG}"
1035 REPO_ARGS+=(-k "$REPOSITORY_KEY")
1036 ;;
1037 u)
1038 REPOSITORY_BASE="${OPTARG}"
1039 REPO_ARGS+=(-u "$REPOSITORY_BASE")
1040 ;;
1041 l)
1042 LXD_REPOSITORY_BASE="${OPTARG}"
1043 ;;
1044 p)
1045 LXD_REPOSITORY_PATH="${OPTARG}"
1046 ;;
1047 D)
1048 OSM_DEVOPS="${OPTARG}"
1049 ;;
1050 s)
1051 OSM_STACK_NAME="${OPTARG}"
1052 ;;
1053 H)
1054 OSMLCM_VCA_HOST="${OPTARG}"
1055 ;;
1056 S)
1057 OSMLCM_VCA_SECRET="${OPTARG}"
1058 ;;
1059 w)
1060 # when specifying workdir, do not use sudo for access
1061 WORKDIR_SUDO=
1062 OSM_WORK_DIR="${OPTARG}"
1063 ;;
1064 o)
1065 INSTALL_ONLY="y"
1066 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
1067 [ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
1068 [ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
1069 ;;
1070 m)
1071 [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
1072 [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
1073 [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue
1074 [ "${OPTARG}" == "LW-UI" ] && TO_REBUILD="$TO_REBUILD LW-UI" && continue
1075 [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue
1076 [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue
1077 [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue
1078 [ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue
1079 ;;
1080 -)
1081 [ "${OPTARG}" == "help" ] && usage && exit 0
1082 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
1083 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
1084 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
1085 [ "${OPTARG}" == "nat" ] && NAT="y" && continue
1086 [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
1087 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
1088 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
1089 [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
1090 [ "${OPTARG}" == "nolxd" ] && INSTALL_NOLXD="y" && continue
1091 [ "${OPTARG}" == "nodocker" ] && INSTALL_NODOCKER="y" && continue
1092 [ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
1093 [ "${OPTARG}" == "lightweight" ] && INSTALL_LIGHTWEIGHT="y" && continue
1094 [ "${OPTARG}" == "soui" ] && INSTALL_LIGHTWEIGHT="" && RELEASE="-R ReleaseTHREE" && REPOSITORY="-r stable" && continue
1095 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
1096 [ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
1097 [ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
1098 [ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
1099 [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
1100 [ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
1101 [ "${OPTARG}" == "nohostports" ] && NO_HOST_PORTS="y" && continue
1102 [ "${OPTARG}" == "nojuju" ] && INSTALL_NOJUJU="y" && continue
1103 [ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
1104 [ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
1105 echo -e "Invalid option: '--$OPTARG'\n" >&2
1106 usage && exit 1
1107 ;;
1108 \?)
1109 echo -e "Invalid option: '-$OPTARG'\n" >&2
1110 usage && exit 1
1111 ;;
1112 y)
1113 ASSUME_YES="y"
1114 ;;
1115 *)
1116 usage && exit 1
1117 ;;
1118 esac
1119 done
1120
1121 [ -n "$INSTALL_FROM_LXDIMAGES" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --lxd can only be used with --soui"
1122 [ -n "$NAT" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --nat can only be used with --soui"
1123 [ -n "$NOCONFIGURE" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --noconfigure can only be used with --soui"
1124 [ -n "$RELEASE_DAILY" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --daily can only be used with --soui"
1125 [ -n "$INSTALL_NOLXD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nolxd cannot be used with --soui"
1126 [ -n "$INSTALL_NODOCKER" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nodocker cannot be used with --soui"
1127 [ -n "$TO_REBUILD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: -m cannot be used with --soui"
1128 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options"
1129
1130 if [ -n "$SHOWOPTS" ]; then
1131 dump_vars
1132 exit 0
1133 fi
1134
1135 [ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
1136
1137 # if develop, we force master
1138 [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
1139
1140 need_packages="git jq wget curl tar"
1141 echo -e "Checking required packages: $need_packages"
1142 dpkg -l $need_packages &>/dev/null \
1143 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
1144 || sudo apt-get update \
1145 || FATAL "failed to run apt-get update"
1146 dpkg -l $need_packages &>/dev/null \
1147 || ! echo -e "Installing $need_packages requires root privileges." \
1148 || sudo apt-get install -y $need_packages \
1149 || FATAL "failed to install $need_packages"
1150
1151 if [ -z "$OSM_DEVOPS" ]; then
1152 if [ -n "$TEST_INSTALLER" ]; then
1153 echo -e "\nUsing local devops repo for OSM installation"
1154 OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))"
1155 else
1156 echo -e "\nCreating temporary dir for OSM installation"
1157 OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
1158 trap 'rm -rf "$OSM_DEVOPS"' EXIT
1159
1160 git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
1161
1162 if [ -z "$COMMIT_ID" ]; then
1163 echo -e "\nGuessing the current stable release"
1164 LATEST_STABLE_DEVOPS=`git -C $OSM_DEVOPS tag -l v[0-9].* | sort -V | tail -n1`
1165 [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
1166
1167 echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
1168 COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
1169 else
1170 echo -e "\nDEVOPS Using commit $COMMIT_ID"
1171 fi
1172 git -C $OSM_DEVOPS checkout $COMMIT_ID
1173 fi
1174 fi
1175
1176 OSM_JENKINS="$OSM_DEVOPS/jenkins"
1177 . $OSM_JENKINS/common/all_funcs
1178
1179 [ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
1180 [ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0
1181 [ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0
1182 [ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0
1183 [ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0
1184 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
1185 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon
1186 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_VIMEMU" ] && install_vimemu
1187 [ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
1188
1189 #Installation starts here
1190 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
1191 track start
1192
1193 [ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
1194 echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
1195 if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
1196 ! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
1197 fi
1198
1199 echo -e "Checking required packages: lxd"
1200 lxd --version &>/dev/null || FATAL "lxd not present, exiting."
1201 [ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
1202
1203 # use local devops for containers
1204 export OSM_USE_LOCAL_DEVOPS=true
1205 if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
1206 echo -e "\nCreating the containers and building from source ..."
1207 $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
1208 ro_is_up && track RO
1209 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
1210 vca_is_up && track VCA
1211 $OSM_DEVOPS/jenkins/host/start_build MON || FATAL "MON install failed"
1212 mon_is_up && track MON
1213 $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
1214 $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
1215 #so_is_up && track SOUI
1216 track SOUI
1217 elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
1218 echo -e "\nInstalling from lxd images ..."
1219 install_from_lxdimages
1220 else #install from binaries
1221 echo -e "\nCreating the containers and installing from binaries ..."
1222 $OSM_DEVOPS/jenkins/host/install RO ${REPO_ARGS[@]} || FATAL "RO install failed"
1223 ro_is_up && track RO
1224 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
1225 vca_is_up && track VCA
1226 $OSM_DEVOPS/jenkins/host/install MON || FATAL "MON build failed"
1227 mon_is_up && track MON
1228 $OSM_DEVOPS/jenkins/host/install SO ${REPO_ARGS[@]} || FATAL "SO install failed"
1229 $OSM_DEVOPS/jenkins/host/install UI ${REPO_ARGS[@]} || FATAL "UI install failed"
1230 #so_is_up && track SOUI
1231 track SOUI
1232 fi
1233
1234 #Install iptables-persistent and configure NAT rules
1235 [ -z "$NOCONFIGURE" ] && nat
1236
1237 #Configure components
1238 [ -z "$NOCONFIGURE" ] && configure
1239
1240 #Install osmclient
1241 [ -z "$NOCONFIGURE" ] && install_osmclient
1242
1243 #Install vim-emu (optional)
1244 [ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
1245
1246 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
1247 track end
1248 echo -e "\nDONE"
1249