Fix bug in full_install_osm when dealing with soui option
[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 " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
21 echo -e " --source: install OSM from source code using the latest stable tag"
22 echo -e " -r <repo>: use specified repository name for osm packages"
23 echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
24 echo -e " -u <repo base>: use specified repository url for osm packages"
25 echo -e " -k <repo key>: use specified repository public key url"
26 echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
27 echo -e " -b master (main dev branch)"
28 echo -e " -b v2.0 (v2.0 branch)"
29 echo -e " -b tags/v1.1.0 (a specific tag)"
30 echo -e " ..."
31 echo -e " --lxdimages: download lxd images from OSM repository instead of creating them from scratch"
32 echo -e " -l <lxd_repo>: use specified repository url for lxd images"
33 echo -e " -p <path>: use specified repository path for lxd images"
34 echo -e " --lightweight: install lightweight build of OSM (default installation)"
35 echo -e " --soui: install classic build of OSM (based on LXD containers, with SO and UI)"
36 echo -e " --vimemu: additionally fetch, build, and deploy the VIM emulator as a docker container"
37 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
38 # echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
39 echo -e " --nat: install only NAT rules"
40 echo -e " --noconfigure: DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
41 # echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
42 echo -e " --showopts: print chosen options and exit (only for debugging)"
43 echo -e " -y: do not prompt for confirmation, assumes yes"
44 echo -e " -D <devops path> use local devops installation path"
45 echo -e " -h / --help: print this help"
46 }
47
48 #Uninstall OSM: remove containers
49 function uninstall(){
50 echo -e "\nUninstalling OSM"
51 if [ $RC_CLONE ] || [ -n "$TEST_INSTALLER" ]; then
52 $OSM_DEVOPS/jenkins/host/clean_container RO
53 $OSM_DEVOPS/jenkins/host/clean_container VCA
54 $OSM_DEVOPS/jenkins/host/clean_container MON
55 $OSM_DEVOPS/jenkins/host/clean_container SO
56 #$OSM_DEVOPS/jenkins/host/clean_container UI
57 else
58 lxc stop RO && lxc delete RO
59 lxc stop VCA && lxc delete VCA
60 lxc stop MON && lxc delete MON
61 lxc stop SO-ub && lxc delete SO-ub
62 fi
63 echo -e "\nDeleting imported lxd images if they exist"
64 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
65 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
66 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
67 return 0
68 }
69
70 #Uninstall lightweight OSM: remove dockers
71 function uninstall_lightweight(){
72 echo -e "\nUninstalling lightweight OSM"
73 docker stack rm osm
74 COUNTER=0
75 result=11
76 while [ ${COUNTER} -lt 30 ]; do
77 sleep 1
78 result=$(docker stack ps osm | wc -l)
79 #echo "Dockers running: $result"
80 if [ "${result}" == "0" ]; then
81 break
82 fi
83 let COUNTER=COUNTER+1
84 done
85 if [ "${result}" == "0" ]; then
86 echo "All dockers of the stack osm were removed"
87 else
88 FATAL "Some dockers of the stack osm could not be removed. Could not uninstall OSM in single shot. Try to uninstall again"
89 fi
90 sleep 5
91 docker image rm osm/ro
92 docker image rm osm/lcm
93 docker image rm osm/light-ui
94 docker image rm osm/nbi
95 docker image rm osm/mon
96 docker image rm osm/pm
97 return 0
98 }
99
100 #Configure NAT rules, based on the current IP addresses of containers
101 function nat(){
102 echo -e "\nChecking required packages: iptables-persistent"
103 dpkg -l iptables-persistent &>/dev/null || ! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
104 sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install iptables-persistent
105 echo -e "\nConfiguring NAT rules"
106 echo -e " Required root privileges"
107 sudo $OSM_DEVOPS/installers/nat_osm
108 }
109
110 function FATAL(){
111 echo "FATAL error: Cannot install OSM due to \"$1\""
112 exit 1
113 }
114
115 #Update RO, SO and UI:
116 function update(){
117 echo -e "\nUpdating components"
118
119 echo -e " Updating RO"
120 CONTAINER="RO"
121 MDG="RO"
122 INSTALL_FOLDER="/opt/openmano"
123 echo -e " Fetching the repo"
124 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
125 BRANCH=""
126 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
127 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
128 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
129 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
130 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
131 # COMMIT_ID either was previously set with -b option, or is an empty string
132 CHECKOUT_ID=$COMMIT_ID
133 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
134 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
135 if [[ $CHECKOUT_ID == "tags/"* ]]; then
136 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
137 else
138 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
139 fi
140 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
141 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
142 echo " Nothing to be done."
143 else
144 echo " Update required."
145 lxc exec $CONTAINER -- service osm-ro stop
146 lxc exec $CONTAINER -- git -C /opt/openmano stash
147 lxc exec $CONTAINER -- git -C /opt/openmano pull --rebase
148 lxc exec $CONTAINER -- git -C /opt/openmano checkout $CHECKOUT_ID
149 lxc exec $CONTAINER -- git -C /opt/openmano stash pop
150 lxc exec $CONTAINER -- /opt/openmano/database_utils/migrate_mano_db.sh
151 lxc exec $CONTAINER -- service osm-ro start
152 fi
153 echo
154
155 echo -e " Updating SO and UI"
156 CONTAINER="SO-ub"
157 MDG="SO"
158 INSTALL_FOLDER="" # To be filled in
159 echo -e " Fetching the repo"
160 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
161 BRANCH=""
162 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
163 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
164 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
165 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
166 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
167 # COMMIT_ID either was previously set with -b option, or is an empty string
168 CHECKOUT_ID=$COMMIT_ID
169 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
170 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
171 if [[ $CHECKOUT_ID == "tags/"* ]]; then
172 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
173 else
174 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
175 fi
176 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
177 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
178 echo " Nothing to be done."
179 else
180 echo " Update required."
181 # Instructions to be added
182 # lxc exec SO-ub -- ...
183 fi
184 echo
185 echo -e "Updating MON Container"
186 CONTAINER="MON"
187 MDG="MON"
188 INSTALL_FOLDER="/root/MON"
189 echo -e " Fetching the repo"
190 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
191 BRANCH=""
192 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
193 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
194 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
195 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
196 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
197 # COMMIT_ID either was previously set with -b option, or is an empty string
198 CHECKOUT_ID=$COMMIT_ID
199 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
200 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
201 if [[ $CHECKOUT_ID == "tags/"* ]]; then
202 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
203 else
204 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
205 fi
206 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
207 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
208 echo " Nothing to be done."
209 else
210 echo " Update required."
211 fi
212 echo
213 }
214
215 function so_is_up() {
216 if [ -n "$1" ]; then
217 SO_IP=$1
218 else
219 SO_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
220 fi
221 time=0
222 step=5
223 timelength=300
224 while [ $time -le $timelength ]
225 do
226 if [[ `curl -k -X GET https://$SO_IP:8008/api/operational/vcs/info \
227 -H 'accept: application/vnd.yang.data+json' \
228 -H 'authorization: Basic YWRtaW46YWRtaW4=' \
229 -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 ]]
230 then
231 echo "RW.Restconf running....SO is up"
232 return 0
233 fi
234
235 sleep $step
236 echo -n "."
237 time=$((time+step))
238 done
239
240 FATAL "OSM Failed to startup. SO failed to startup"
241 }
242
243 function vca_is_up() {
244 if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
245 echo "VCA is up and running"
246 return 0
247 fi
248
249 FATAL "OSM Failed to startup. VCA failed to startup"
250 }
251
252 function mon_is_up() {
253 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
254 echo "MON is up and running"
255 return 0
256 fi
257
258 FATAL "OSM Failed to startup. MON failed to startup"
259 }
260
261 function ro_is_up() {
262 if [ -n "$1" ]; then
263 RO_IP=$1
264 else
265 RO_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
266 fi
267 time=0
268 step=2
269 timelength=20
270 while [ $time -le $timelength ]; do
271 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
272 echo "RO is up and running"
273 return 0
274 fi
275 sleep $step
276 echo -n "."
277 time=$((time+step))
278 done
279
280 FATAL "OSM Failed to startup. RO failed to startup"
281 }
282
283
284 function configure_RO(){
285 . $OSM_DEVOPS/installers/export_ips
286 echo -e " Configuring RO"
287 lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc/osm/openmanod.cfg
288 lxc exec RO -- service osm-ro restart
289
290 ro_is_up
291
292 lxc exec RO -- openmano tenant-delete -f osm >/dev/null
293 lxc exec RO -- openmano tenant-create osm > /dev/null
294 lxc exec RO -- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
295 lxc exec RO -- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
296 lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
297 }
298
299 function configure_VCA(){
300 echo -e " Configuring VCA"
301 JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
302 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
303 }
304
305 function configure_SOUI(){
306 . $OSM_DEVOPS/installers/export_ips
307 JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
308 RO_TENANT_ID=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
309
310 echo -e " Configuring MON"
311 #Information to be added about SO socket for logging
312
313 echo -e " Configuring SO"
314 sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP
315 sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local
316 # make journaling persistent
317 lxc exec SO-ub -- mkdir -p /var/log/journal
318 lxc exec SO-ub -- systemd-tmpfiles --create --prefix /var/log/journal
319 lxc exec SO-ub -- systemctl restart systemd-journald
320
321 echo RIFT_EXTERNAL_ADDRESS=$DEFAULT_IP | lxc exec SO-ub -- tee -a /usr/rift/etc/default/launchpad
322
323 lxc exec SO-ub -- systemctl restart launchpad
324
325 so_is_up $SO_CONTAINER_IP
326
327 #delete existing config agent (could be there on reconfigure)
328 curl -k --request DELETE \
329 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent/account/osmjuju \
330 --header 'accept: application/vnd.yang.data+json' \
331 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
332 --header 'cache-control: no-cache' \
333 --header 'content-type: application/vnd.yang.data+json' &> /dev/null
334
335 result=$(curl -k --request POST \
336 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent \
337 --header 'accept: application/vnd.yang.data+json' \
338 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
339 --header 'cache-control: no-cache' \
340 --header 'content-type: application/vnd.yang.data+json' \
341 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}')
342 [[ $result =~ .*success.* ]] || FATAL "Failed config-agent configuration: $result"
343
344 #R1/R2 config line
345 #result=$(curl -k --request PUT \
346 # --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \
347 # --header 'accept: application/vnd.yang.data+json' \
348 # --header 'authorization: Basic YWRtaW46YWRtaW4=' \
349 # --header 'cache-control: no-cache' \
350 # --header 'content-type: application/vnd.yang.data+json' \
351 # --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }')
352
353 result=$(curl -k --request PUT \
354 --url https://$SO_CONTAINER_IP:8008/api/config/project/default/ro-account/account \
355 --header 'accept: application/vnd.yang.data+json' \
356 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
357 --header 'cache-control: no-cache' \
358 --header 'content-type: application/vnd.yang.data+json' \
359 --data '{"rw-ro-account:account": [ { "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'"}, "name": "osmopenmano", "ro-account-type": "openmano" }]}')
360 [[ $result =~ .*success.* ]] || FATAL "Failed resource-orchestrator configuration: $result"
361
362 result=$(curl -k --request PATCH \
363 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/redirect-uri \
364 --header 'accept: application/vnd.yang.data+json' \
365 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
366 --header 'cache-control: no-cache' \
367 --header 'content-type: application/vnd.yang.data+json' \
368 --data '{"redirect-uri": "https://'$DEFAULT_IP':8443/callback" }')
369 [[ $result =~ .*success.* ]] || FATAL "Failed redirect-uri configuration: $result"
370
371 result=$(curl -k --request PATCH \
372 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/post-logout-redirect-uri \
373 --header 'accept: application/vnd.yang.data+json' \
374 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
375 --header 'cache-control: no-cache' \
376 --header 'content-type: application/vnd.yang.data+json' \
377 --data '{"post-logout-redirect-uri": "https://'$DEFAULT_IP':8443/?api_server=https://'$DEFAULT_IP'" }')
378 [[ $result =~ .*success.* ]] || FATAL "Failed post-logout-redirect-uri configuration: $result"
379
380 lxc exec SO-ub -- tee /etc/network/interfaces.d/60-rift.cfg <<EOF
381 auto lo:1
382 iface lo:1 inet static
383 address $DEFAULT_IP
384 netmask 255.255.255.255
385 EOF
386 lxc exec SO-ub ifup lo:1
387 }
388
389 #Configure RO, VCA, and SO with the initial configuration:
390 # RO -> tenant:osm, logs to be sent to SO
391 # VCA -> juju-password
392 # SO -> route to Juju Controller, add RO account, add VCA account
393 function configure(){
394 #Configure components
395 echo -e "\nConfiguring components"
396 configure_RO
397 configure_VCA
398 configure_SOUI
399 }
400
401 function install_lxd() {
402 sudo apt-get update
403 sudo apt-get install -y lxd
404 newgrp lxd
405 lxd init --auto
406 lxd waitready
407 lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
408 DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
409 DEFAULT_MTU=$(ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
410 lxc profile device set default eth0 mtu $DEFAULT_MTU
411 #sudo systemctl stop lxd-bridge
412 #sudo systemctl --system daemon-reload
413 #sudo systemctl enable lxd-bridge
414 #sudo systemctl start lxd-bridge
415 }
416
417 function ask_user(){
418 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
419 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
420 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
421 read -e -p "$1" USER_CONFIRMATION
422 while true ; do
423 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
424 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
425 [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
426 [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
427 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
428 done
429 }
430
431 function launch_container_from_lxd(){
432 export OSM_MDG=$1
433 OSM_load_config
434 export OSM_BASE_IMAGE=$2
435 if ! container_exists $OSM_BUILD_CONTAINER; then
436 CONTAINER_OPTS=""
437 [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true"
438 [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true"
439 create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
440 wait_container_up $OSM_BUILD_CONTAINER
441 fi
442 }
443
444 function install_osmclient(){
445 CLIENT_RELEASE=${RELEASE#"-R "}
446 CLIENT_REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
447 CLIENT_REPOSITORY=${REPOSITORY#"-r "}
448 [ -z "$REPOSITORY_BASE" ] && REPOSITORY_BASE="-u https://osm-download.etsi.org/repository/osm/debian"
449 CLIENT_REPOSITORY_BASE=${REPOSITORY_BASE#"-u "}
450 key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
451 curl $key_location | sudo apt-key add -
452 sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
453 sudo apt-get update
454 sudo apt-get install -y python-pip
455 sudo -H pip install pip==9.0.3
456 sudo -H pip install python-magic
457 sudo apt-get install -y python-osmclient
458 #sed 's,OSM_SOL005=[^$]*,OSM_SOL005=True,' -i ${HOME}/.bashrc
459 #echo 'export OSM_HOSTNAME=localhost' >> ${HOME}/.bashrc
460 #echo 'export OSM_SOL005=True' >> ${HOME}/.bashrc
461 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
462 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
463 [ -n "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=localhost
464 echo -e "\nOSM client installed"
465 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
466 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
467 [ -n "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_SOL005=True"
468 [ -z "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
469 return 0
470 }
471
472 function install_from_lxdimages(){
473 LXD_RELEASE=${RELEASE#"-R "}
474 if [ -n "$LXD_REPOSITORY_PATH" ]; then
475 LXD_IMAGE_DIR="$LXD_REPOSITORY_PATH"
476 else
477 LXD_IMAGE_DIR="$(mktemp -d -q --tmpdir "osmimages.XXXXXX")"
478 trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
479 fi
480 echo -e "\nDeleting previous lxd images if they exist"
481 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
482 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
483 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
484 echo -e "\nImporting osm-ro"
485 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-ro.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.tar.gz
486 lxc image import $LXD_IMAGE_DIR/osm-ro.tar.gz --alias osm-ro
487 rm -f $LXD_IMAGE_DIR/osm-ro.tar.gz
488 echo -e "\nImporting osm-vca"
489 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-vca.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.tar.gz
490 lxc image import $LXD_IMAGE_DIR/osm-vca.tar.gz --alias osm-vca
491 rm -f $LXD_IMAGE_DIR/osm-vca.tar.gz
492 echo -e "\nImporting osm-soui"
493 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-soui.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.tar.gz
494 lxc image import $LXD_IMAGE_DIR/osm-soui.tar.gz --alias osm-soui
495 rm -f $LXD_IMAGE_DIR/osm-soui.tar.gz
496 launch_container_from_lxd RO osm-ro
497 ro_is_up && track RO
498 launch_container_from_lxd VCA osm-vca
499 vca_is_up && track VCA
500 launch_container_from_lxd MON osm-mon
501 mon_is_up && track MON
502 launch_container_from_lxd SO osm-soui
503 #so_is_up && track SOUI
504 track SOUI
505 }
506
507 function install_docker_ce() {
508 # installs and configures Docker CE
509 echo "Installing Docker CE ..."
510 sudo apt-get -qq update
511 sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
512 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
513 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
514 sudo apt-get -qq update
515 sudo apt-get install -y docker-ce
516 echo "Adding user to group 'docker'"
517 sudo groupadd -f docker
518 sudo usermod -aG docker $USER
519 echo "... Docker CE installation done"
520 sleep 2
521 sudo service docker restart
522 echo "... restarted Docker service"
523 }
524
525 function install_docker_compose() {
526 # installs and configures docker-compose
527 echo "Installing Docker Compose ..."
528 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
529 sudo chmod +x /usr/local/bin/docker-compose
530 echo "... Docker Compose installation done"
531 }
532
533 function install_juju() {
534 echo "Installing juju"
535 sudo snap install juju --classic
536 sudo dpkg-reconfigure -p medium lxd
537 sg lxd -c "juju bootstrap localhost osm"
538 echo "Finished installation of juju"
539 }
540
541 function generate_docker_images() {
542 echo "Pulling and generating docker images"
543 newgrp docker << EONG
544 docker pull wurstmeister/kafka
545 docker pull wurstmeister/zookeeper
546 docker pull mongo
547 docker pull mysql:5
548 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON
549 docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon || ! echo "cannot build MON docker image" >&2
550 docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm || ! echo "cannot build PM docker image" >&2
551 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI
552 docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi || ! echo "cannot build NBI docker image" >&2
553 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO
554 docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro || ! echo "cannot build RO docker image" >&2
555 docker build ${LWTEMPDIR}/RO/lcm -t osm/lcm || ! echo "cannot build LCM docker image" >&2
556 git -C ${LWTEMPDIR} clone https://github.com/superfluidity/osm-light-ui.git
557 docker build ${LWTEMPDIR}/osm-light-ui -t osm/light-ui -f ${LWTEMPDIR}/osm-light-ui/code/docker/Dockerfile
558 # git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI
559 # docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile
560 EONG
561 echo "Finished generation of docker images"
562 }
563
564 function generate_docker_env_files() {
565 echo "Generating docker env files"
566 OSMLCM_VCA_HOST=`juju show-controller|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
567 OSMLCM_VCA_SECRET=`grep password ${HOME}/.local/share/juju/accounts.yaml |awk '{print $2}'`
568 MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
569 echo "OSMLCM_VCA_HOST=${OSMLCM_VCA_HOST}" |sudo tee ${OSM_DEVOPS}/installers/docker/lcm.env
570 echo "OSMLCM_VCA_SECRET=${OSMLCM_VCA_SECRET}" |sudo tee -a ${OSM_DEVOPS}/installers/docker/lcm.env
571 echo "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |sudo tee ${OSM_DEVOPS}/installers/docker/ro-db.env
572 echo "RO_DB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |sudo tee ${OSM_DEVOPS}/installers/docker/ro.env
573 echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |sudo tee ${OSM_DEVOPS}/installers/docker/mon.env
574 echo "Finished generation of docker env files"
575 }
576
577 function deploy_lightweight() {
578 echo "Deploying lightweight build"
579 if [ "${DEFAULT_MTU}" != "1500" ]; then
580 DOCKER_NETS=`sg docker -c "docker network list" | awk '{print $2}' | egrep -v "^ID$" | paste -d " " -s`
581 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";}'`
582 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"
583 fi
584 newgrp docker << EONG
585 docker swarm init --advertise-addr ${DEFAULT_IP}
586 docker network create --driver=overlay --attachable --opt com.docker.network.driver.mtu=${DEFAULT_MTU} netOSM
587 docker stack deploy -c ${OSM_DEVOPS}/installers/docker/docker-compose.yaml osm
588 #docker-compose -f /usr/share/osm-devops/installers/docker/docker-compose.yaml up -d
589 EONG
590 echo "Finished deployment of lightweight build"
591 }
592
593 function install_lightweight() {
594 echo "Installing lightweight build of OSM"
595 LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
596 trap 'rm -rf "${LWTEMPDIR}"' EXIT
597 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
598 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
599 DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
600 need_packages_lw="lxd"
601 echo -e "Checking required packages: $need_packages_lw"
602 dpkg -l $need_packages_lw &>/dev/null \
603 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
604 || sudo apt-get update \
605 || FATAL "failed to run apt-get update"
606 dpkg -l $need_packages_lw &>/dev/null \
607 || ! echo -e "Installing $need_packages_lw requires root privileges." \
608 || sudo apt-get install -y $need_packages_lw \
609 || FATAL "failed to install $need_packages_lw"
610 install_juju
611 install_docker_ce
612 #install_docker_compose
613 generate_docker_images
614 generate_docker_env_files
615 deploy_lightweight
616 install_osmclient
617 return 0
618 }
619
620 function install_vimemu() {
621 # install Docker
622 install_docker_ce
623 # clone vim-emu repository (attention: branch is currently master only)
624 echo "Cloning vim-emu repository ..."
625 git clone https://osm.etsi.org/gerrit/osm/vim-emu.git
626 # build vim-emu docker
627 echo "Building vim-emu Docker container..."
628 sudo docker build -t vim-emu-img -f vim-emu/Dockerfile vim-emu/
629 # start vim-emu container as daemon
630 echo "Starting vim-emu Docker container 'vim-emu' ..."
631 sudo docker run --name vim-emu -t -d --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py
632 echo "Waiting for 'vim-emu' container to start ..."
633 sleep 5
634 export VIMEMU_HOSTNAME=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
635 echo "vim-emu running at ${VIMEMU_HOSTNAME} ..."
636 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
637 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
638 echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
639 echo -e "You might be interested in adding the following vim-emu env variables to your .bashrc file:"
640 echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
641 echo -e "\nTo add the emulated VIM to OSM you should do:"
642 echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
643 }
644
645 function dump_vars(){
646 echo "DEVELOP=$DEVELOP"
647 echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
648 echo "UNINSTALL=$UNINSTALL"
649 echo "NAT=$NAT"
650 echo "UPDATE=$UPDATE"
651 echo "RECONFIGURE=$RECONFIGURE"
652 echo "TEST_INSTALLER=$TEST_INSTALLER"
653 echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
654 echo "INSTALL_LXD=$INSTALL_LXD"
655 echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
656 echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
657 echo "LXD_REPOSITORY_PATH=$LXD_REPOSITORY_PATH"
658 echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
659 echo "RELEASE=$RELEASE"
660 echo "REPOSITORY=$REPOSITORY"
661 echo "REPOSITORY_BASE=$REPOSITORY_BASE"
662 echo "REPOSITORY_KEY=$REPOSITORY_KEY"
663 echo "NOCONFIGURE=$NOCONFIGURE"
664 echo "SHOWOPTS=$SHOWOPTS"
665 echo "Install from specific refspec (-b): $COMMIT_ID"
666 }
667
668 function track(){
669 ctime=`date +%s`
670 duration=$((ctime - SESSION_ID))
671 url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
672 #url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
673 event_name="bin"
674 [ -n "$INSTALL_FROM_SOURCE" ] && event_name="src"
675 [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
676 event_name="${event_name}_$1"
677 url="${url}&event=${event_name}&ce_duration=${duration}"
678 wget -q -O /dev/null $url
679 }
680
681 UNINSTALL=""
682 DEVELOP=""
683 NAT=""
684 UPDATE=""
685 RECONFIGURE=""
686 TEST_INSTALLER=""
687 INSTALL_LXD=""
688 SHOWOPTS=""
689 COMMIT_ID=""
690 ASSUME_YES=""
691 INSTALL_FROM_SOURCE=""
692 RELEASE="-R ReleaseTHREE"
693 REPOSITORY="-r stable"
694 INSTALL_VIMEMU=""
695 INSTALL_FROM_LXDIMAGES=""
696 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
697 LXD_REPOSITORY_PATH=""
698 INSTALL_LIGHTWEIGHT="y"
699 NOCONFIGURE=""
700 RELEASE_DAILY=""
701 SESSION_ID=`date +%s`
702 OSM_DEVOPS=
703
704 while getopts ":hy-:b:r:k:u:R:l:p:D:" o; do
705 case "${o}" in
706 h)
707 usage && exit 0
708 ;;
709 b)
710 COMMIT_ID=${OPTARG}
711 ;;
712 r)
713 REPOSITORY="-r ${OPTARG}"
714 ;;
715 R)
716 RELEASE="-R ${OPTARG}"
717 ;;
718 k)
719 REPOSITORY_KEY="-k ${OPTARG}"
720 ;;
721 u)
722 REPOSITORY_BASE="-u ${OPTARG}"
723 ;;
724 l)
725 LXD_REPOSITORY_BASE="${OPTARG}"
726 ;;
727 p)
728 LXD_REPOSITORY_PATH="${OPTARG}"
729 ;;
730 D)
731 OSM_DEVOPS="${OPTARG}"
732 ;;
733 -)
734 [ "${OPTARG}" == "help" ] && usage && exit 0
735 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
736 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
737 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
738 [ "${OPTARG}" == "nat" ] && NAT="y" && continue
739 [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
740 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
741 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
742 [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
743 [ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
744 [ "${OPTARG}" == "lightweight" ] && INSTALL_LIGHTWEIGHT="y" && continue
745 [ "${OPTARG}" == "soui" ] && INSTALL_LIGHTWEIGHT="" && continue
746 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
747 [ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
748 [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
749 [ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
750 echo -e "Invalid option: '--$OPTARG'\n" >&2
751 usage && exit 1
752 ;;
753 \?)
754 echo -e "Invalid option: '-$OPTARG'\n" >&2
755 usage && exit 1
756 ;;
757 y)
758 ASSUME_YES="y"
759 ;;
760 *)
761 usage && exit 1
762 ;;
763 esac
764 done
765
766 if [ -n "$SHOWOPTS" ]; then
767 dump_vars
768 exit 0
769 fi
770
771 [ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
772
773 # if develop, we force master
774 [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
775
776 # forcing source from master removed. Now only install from source when explicit
777 # [ -n "$COMMIT_ID" ] && [ "$COMMIT_ID" == "master" ] && INSTALL_FROM_SOURCE="y"
778
779 if [ -z "$OSM_DEVOPS" ]; then
780 if [ -n "$TEST_INSTALLER" ]; then
781 echo -e "\nUsing local devops repo for OSM installation"
782 TEMPDIR="$(dirname $(realpath $(dirname $0)))"
783 else
784 echo -e "\nCreating temporary dir for OSM installation"
785 TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
786 trap 'rm -rf "$TEMPDIR"' EXIT
787 fi
788 fi
789
790 need_packages="git jq wget curl tar"
791 echo -e "Checking required packages: $need_packages"
792 dpkg -l $need_packages &>/dev/null \
793 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
794 || sudo apt-get update \
795 || FATAL "failed to run apt-get update"
796 dpkg -l $need_packages &>/dev/null \
797 || ! echo -e "Installing $need_packages requires root privileges." \
798 || sudo apt-get install -y $need_packages \
799 || FATAL "failed to install $need_packages"
800
801 if [ -z "$OSM_DEVOPS" ]; then
802 if [ -z "$TEST_INSTALLER" ]; then
803 echo -e "\nCloning devops repo temporarily"
804 git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
805 RC_CLONE=$?
806 fi
807
808 echo -e "\nGuessing the current stable release"
809 LATEST_STABLE_DEVOPS=`git -C $TEMPDIR tag -l v[0-9].* | sort -V | tail -n1`
810 [ -z "$COMMIT_ID" ] && [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
811 echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
812 [ -z "$COMMIT_ID" ] && [ -n "$LATEST_STABLE_DEVOPS" ] && COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
813
814 if [ -n "$RELEASE_DAILY" ]; then
815 echo "Using master/HEAD devops"
816 git -C $TEMPDIR checkout master
817 elif [ -z "$TEST_INSTALLER" ]; then
818 git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS
819 fi
820 OSM_DEVOPS=$TEMPDIR
821 fi
822
823 OSM_JENKINS="$OSM_DEVOPS/jenkins"
824 . $OSM_JENKINS/common/all_funcs
825
826 [ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
827 [ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0
828 [ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0
829 [ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0
830 [ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0
831
832 #Installation starts here
833 [ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
834 echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
835 if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
836 ! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
837 fi
838
839 echo -e "Checking required packages: lxd"
840 lxd --version &>/dev/null || FATAL "lxd not present, exiting."
841 [ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
842
843 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
844 track start
845
846 # use local devops for containers
847 export OSM_USE_LOCAL_DEVOPS=true
848 if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
849 echo -e "\nCreating the containers and building from source ..."
850 $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
851 ro_is_up && track RO
852 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
853 vca_is_up && track VCA
854 $OSM_DEVOPS/jenkins/host/start_build MON || FATAL "MON install failed"
855 mon_is_up && track MON
856 $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
857 $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
858 #so_is_up && track SOUI
859 track SOUI
860 elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
861 echo -e "\nInstalling from lxd images ..."
862 install_from_lxdimages
863 else #install from binaries
864 echo -e "\nCreating the containers and installing from binaries ..."
865 $OSM_DEVOPS/jenkins/host/install RO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "RO install failed"
866 ro_is_up && track RO
867 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
868 vca_is_up && track VCA
869 $OSM_DEVOPS/jenkins/host/install MON || FATAL "MON build failed"
870 mon_is_up && track MON
871 $OSM_DEVOPS/jenkins/host/install SO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "SO install failed"
872 $OSM_DEVOPS/jenkins/host/install UI $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "UI install failed"
873 #so_is_up && track SOUI
874 track SOUI
875 fi
876
877 #Install iptables-persistent and configure NAT rules
878 [ -z "$NOCONFIGURE" ] && nat
879
880 #Configure components
881 [ -z "$NOCONFIGURE" ] && configure
882
883 #Install osmclient
884 [ -z "$NOCONFIGURE" ] && install_osmclient
885
886 #Install vim-emu (optional)
887 if [ -n "$INSTALL_VIMEMU" ]; then
888 echo -e "\nInstalling vim-emu ..."
889 install_vimemu
890 fi
891
892 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
893 track end
894 echo -e "\nDONE"
895