blob: 054b2c2678334c73fd971b83f9d81cc27b764f82 [file] [log] [blame]
garciadeblas93c61312016-09-28 15:12:48 +02001#!/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
16function usage(){
17 echo -e "usage: $0 [OPTIONS]"
garciadeblasa1fc4572017-04-24 19:08:21 +020018 echo -e "Install OSM from binaries or source code (by default, from binaries)"
garciadeblas93c61312016-09-28 15:12:48 +020019 echo -e " OPTIONS"
garciadeblas0d934c12017-11-17 15:39:17 +010020 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"
Mike Marchetti425f8ce2017-06-15 13:02:16 -040022 echo -e " -r <repo>: use specified repository name for osm packages"
garciadeblas0d934c12017-11-17 15:39:17 +010023 echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
Mike Marchetti425f8ce2017-06-15 13:02:16 -040024 echo -e " -u <repo base>: use specified repository url for osm packages"
25 echo -e " -k <repo key>: use specified repository public key url"
garciadeblas0d934c12017-11-17 15:39:17 +010026 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"
garciadeblasfc8f0292018-04-02 16:55:29 +020033 echo -e " -p <path>: use specified repository path for lxd images"
peustermd74dc842018-01-24 15:32:17 +010034 echo -e " --vimemu: additionally fetch, build, and deploy the VIM emulator as a docker container"
garciadeblas0d934c12017-11-17 15:39:17 +010035 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
36# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
37 echo -e " --nat: install only NAT rules"
38 echo -e " --noconfigure: DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
39# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
40 echo -e " --showopts: print chosen options and exit (only for debugging)"
41 echo -e " -y: do not prompt for confirmation, assumes yes"
42 echo -e " -h / --help: print this help"
garciadeblas93c61312016-09-28 15:12:48 +020043}
44
garciadeblas55490d42016-10-29 14:22:03 +020045#Uninstall OSM: remove containers
46function uninstall(){
garciadeblasa1fc4572017-04-24 19:08:21 +020047 echo -e "\nUninstalling OSM"
garciadeblas55490d42016-10-29 14:22:03 +020048 if [ $RC_CLONE ] || [ -n "$TEST_INSTALLER" ]; then
49 $OSM_DEVOPS/jenkins/host/clean_container RO
50 $OSM_DEVOPS/jenkins/host/clean_container VCA
51 $OSM_DEVOPS/jenkins/host/clean_container SO
52 #$OSM_DEVOPS/jenkins/host/clean_container UI
53 else
54 lxc stop RO && lxc delete RO
55 lxc stop VCA && lxc delete VCA
56 lxc stop SO-ub && lxc delete SO-ub
57 fi
garciadeblas54e7eed2018-03-19 17:38:04 +010058 echo -e "\nDeleting imported lxd images if they exist"
59 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
60 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
61 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
garciadeblas429b9f82018-03-20 02:09:44 +010062 return 0
garciadeblas55490d42016-10-29 14:22:03 +020063}
64
65#Configure NAT rules, based on the current IP addresses of containers
66function nat(){
67 echo -e "\nChecking required packages: iptables-persistent"
68 dpkg -l iptables-persistent &>/dev/null || ! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
69 sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install iptables-persistent
70 echo -e "\nConfiguring NAT rules"
71 echo -e " Required root privileges"
72 sudo $OSM_DEVOPS/installers/nat_osm
73}
74
Mike Marchettid8577f52017-10-19 15:27:48 -040075function FATAL(){
76 echo "FATAL error: Cannot install OSM due to \"$1\""
77 exit 1
78}
79
garciadeblas2a382732017-01-12 12:11:14 +010080#Update RO, SO and UI:
81function update(){
82 echo -e "\nUpdating components"
83
84 echo -e " Updating RO"
85 CONTAINER="RO"
86 MDG="RO"
87 INSTALL_FOLDER="/opt/openmano"
88 echo -e " Fetching the repo"
89 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
90 BRANCH=""
91 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
Jokin Garayc17db012017-03-08 17:45:39 +010092 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
garciadeblas2a382732017-01-12 12:11:14 +010093 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
94 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
95 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
96 # COMMIT_ID either was previously set with -b option, or is an empty string
97 CHECKOUT_ID=$COMMIT_ID
98 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
99 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
100 if [[ $CHECKOUT_ID == "tags/"* ]]; then
101 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
102 else
103 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
104 fi
105 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
106 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
107 echo " Nothing to be done."
108 else
109 echo " Update required."
garciadeblasa1fc4572017-04-24 19:08:21 +0200110 lxc exec $CONTAINER -- service osm-ro stop
garciadeblas2a382732017-01-12 12:11:14 +0100111 lxc exec $CONTAINER -- git -C /opt/openmano stash
112 lxc exec $CONTAINER -- git -C /opt/openmano pull --rebase
113 lxc exec $CONTAINER -- git -C /opt/openmano checkout $CHECKOUT_ID
114 lxc exec $CONTAINER -- git -C /opt/openmano stash pop
115 lxc exec $CONTAINER -- /opt/openmano/database_utils/migrate_mano_db.sh
garciadeblasa1fc4572017-04-24 19:08:21 +0200116 lxc exec $CONTAINER -- service osm-ro start
garciadeblas2a382732017-01-12 12:11:14 +0100117 fi
118 echo
119
120 echo -e " Updating SO and UI"
121 CONTAINER="SO-ub"
122 MDG="SO"
123 INSTALL_FOLDER="" # To be filled in
124 echo -e " Fetching the repo"
125 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
126 BRANCH=""
127 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
Jokin Garayc17db012017-03-08 17:45:39 +0100128 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
garciadeblas2a382732017-01-12 12:11:14 +0100129 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
130 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
131 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
132 # COMMIT_ID either was previously set with -b option, or is an empty string
133 CHECKOUT_ID=$COMMIT_ID
134 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
135 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
136 if [[ $CHECKOUT_ID == "tags/"* ]]; then
137 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
138 else
139 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
140 fi
141 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
142 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
143 echo " Nothing to be done."
144 else
145 echo " Update required."
146 # Instructions to be added
147 # lxc exec SO-ub -- ...
148 fi
149 echo
150}
151
Mike Marchetti2b951282017-10-10 15:43:15 -0400152function so_is_up() {
garciadeblas0d934c12017-11-17 15:39:17 +0100153 if [ -n "$1" ]; then
154 SO_IP=$1
155 else
156 SO_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
157 fi
Mike Marchetti6930bc02017-05-31 16:33:02 -0400158 time=0
159 step=5
160 timelength=300
161 while [ $time -le $timelength ]
162 do
Mike Marchetti2b951282017-10-10 15:43:15 -0400163 if [[ `curl -k -X GET https://$SO_IP:8008/api/operational/vcs/info \
164 -H 'accept: application/vnd.yang.data+json' \
165 -H 'authorization: Basic YWRtaW46YWRtaW4=' \
166 -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 ]]
167 then
168 echo "RW.Restconf running....SO is up"
169 return 0
Mike Marchetti6930bc02017-05-31 16:33:02 -0400170 fi
Mike Marchetti2b951282017-10-10 15:43:15 -0400171
Mike Marchetti6930bc02017-05-31 16:33:02 -0400172 sleep $step
173 echo -n "."
174 time=$((time+step))
175 done
Mike Marchetti2b951282017-10-10 15:43:15 -0400176
garciadeblas0d934c12017-11-17 15:39:17 +0100177 FATAL "OSM Failed to startup. SO failed to startup"
Mike Marchetti6930bc02017-05-31 16:33:02 -0400178}
179
garciadeblas0d934c12017-11-17 15:39:17 +0100180function vca_is_up() {
181 if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
182 echo "VCA is up and running"
183 return 0
184 fi
garciadeblas55490d42016-10-29 14:22:03 +0200185
garciadeblas0d934c12017-11-17 15:39:17 +0100186 FATAL "OSM Failed to startup. VCA failed to startup"
187}
188
189function ro_is_up() {
190 if [ -n "$1" ]; then
191 RO_IP=$1
192 else
193 RO_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
194 fi
195 time=0
196 step=2
197 timelength=20
198 while [ $time -le $timelength ]; do
199 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
200 echo "RO is up and running"
201 return 0
202 fi
203 sleep $step
204 echo -n "."
205 time=$((time+step))
206 done
207
208 FATAL "OSM Failed to startup. RO failed to startup"
209}
210
211
212function configure_RO(){
213 . $OSM_DEVOPS/installers/export_ips
garciadeblas55490d42016-10-29 14:22:03 +0200214 echo -e " Configuring RO"
garciadeblasa1fc4572017-04-24 19:08:21 +0200215 lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc/osm/openmanod.cfg
216 lxc exec RO -- service osm-ro restart
Mike Marchetti6930bc02017-05-31 16:33:02 -0400217
garciadeblas0d934c12017-11-17 15:39:17 +0100218 ro_is_up
Mike Marchetti6930bc02017-05-31 16:33:02 -0400219
garciadeblasd8718f12016-10-30 19:39:01 +0100220 lxc exec RO -- openmano tenant-delete -f osm >/dev/null
garciadeblas1b7107e2017-12-21 15:32:02 +0100221 lxc exec RO -- openmano tenant-create osm > /dev/null
tierno15f4f222017-06-14 13:23:01 +0200222 lxc exec RO -- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
223 lxc exec RO -- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
garciadeblas1b7107e2017-12-21 15:32:02 +0100224 lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
garciadeblas0d934c12017-11-17 15:39:17 +0100225}
garciadeblas55490d42016-10-29 14:22:03 +0200226
garciadeblas0d934c12017-11-17 15:39:17 +0100227function configure_VCA(){
garciadeblas55490d42016-10-29 14:22:03 +0200228 echo -e " Configuring VCA"
229 JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
230 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
garciadeblas0d934c12017-11-17 15:39:17 +0100231}
232
233function configure_SOUI(){
234 . $OSM_DEVOPS/installers/export_ips
garciadeblas55490d42016-10-29 14:22:03 +0200235 JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
garciadeblas1b7107e2017-12-21 15:32:02 +0100236 RO_TENANT_ID=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
garciadeblas55490d42016-10-29 14:22:03 +0200237
238 echo -e " Configuring SO"
239 sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP
garciadeblas2f4c93b2017-04-10 18:12:12 +0200240 sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local
Jeremy Mordkoff5cc6ccc2017-10-05 15:21:07 -0400241 # make journaling persistent
242 lxc exec SO-ub -- mkdir -p /var/log/journal
243 lxc exec SO-ub -- systemd-tmpfiles --create --prefix /var/log/journal
244 lxc exec SO-ub -- systemctl restart systemd-journald
245
Jeremy Mordkoff3b3edea2017-10-03 16:21:56 -0400246 echo RIFT_EXTERNAL_ADDRESS=$DEFAULT_IP | lxc exec SO-ub -- tee -a /usr/rift/etc/default/launchpad
247
Mike Marchetti6930bc02017-05-31 16:33:02 -0400248 lxc exec SO-ub -- systemctl restart launchpad
garciadeblas55490d42016-10-29 14:22:03 +0200249
Mike Marchetti6930bc02017-05-31 16:33:02 -0400250 so_is_up $SO_CONTAINER_IP
251
252 #delete existing config agent (could be there on reconfigure)
253 curl -k --request DELETE \
254 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent/account/osmjuju \
255 --header 'accept: application/vnd.yang.data+json' \
256 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
257 --header 'cache-control: no-cache' \
258 --header 'content-type: application/vnd.yang.data+json' &> /dev/null
259
260 result=$(curl -k --request POST \
garciadeblas55490d42016-10-29 14:22:03 +0200261 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent \
262 --header 'accept: application/vnd.yang.data+json' \
263 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
264 --header 'cache-control: no-cache' \
265 --header 'content-type: application/vnd.yang.data+json' \
Mike Marchetti6930bc02017-05-31 16:33:02 -0400266 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}')
267 [[ $result =~ .*success.* ]] || FATAL "Failed config-agent configuration: $result"
garciadeblas55490d42016-10-29 14:22:03 +0200268
Mike Marchetti397a65d2017-10-02 22:36:16 -0400269 #R1/R2 config line
270 #result=$(curl -k --request PUT \
271 # --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \
272 # --header 'accept: application/vnd.yang.data+json' \
273 # --header 'authorization: Basic YWRtaW46YWRtaW4=' \
274 # --header 'cache-control: no-cache' \
275 # --header 'content-type: application/vnd.yang.data+json' \
276 # --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }')
277
Mike Marchetti6930bc02017-05-31 16:33:02 -0400278 result=$(curl -k --request PUT \
Mike Marchetti397a65d2017-10-02 22:36:16 -0400279 --url https://$SO_CONTAINER_IP:8008/api/config/project/default/ro-account/account \
garciadeblas55490d42016-10-29 14:22:03 +0200280 --header 'accept: application/vnd.yang.data+json' \
281 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
Mike Marchetti397a65d2017-10-02 22:36:16 -0400282 --header 'cache-control: no-cache' \
garciadeblas55490d42016-10-29 14:22:03 +0200283 --header 'content-type: application/vnd.yang.data+json' \
Mike Marchetti397a65d2017-10-02 22:36:16 -0400284 --data '{"rw-ro-account:account": [ { "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'"}, "name": "osmopenmano", "ro-account-type": "openmano" }]}')
Mike Marchetti6930bc02017-05-31 16:33:02 -0400285 [[ $result =~ .*success.* ]] || FATAL "Failed resource-orchestrator configuration: $result"
Jeremy Mordkoff2059b392017-10-03 17:34:10 -0400286
Jeremy Mordkoff34151f22017-10-04 19:45:37 -0400287 result=$(curl -k --request PATCH \
288 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/redirect-uri \
289 --header 'accept: application/vnd.yang.data+json' \
290 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
291 --header 'cache-control: no-cache' \
292 --header 'content-type: application/vnd.yang.data+json' \
293 --data '{"redirect-uri": "https://'$DEFAULT_IP':8443/callback" }')
294 [[ $result =~ .*success.* ]] || FATAL "Failed redirect-uri configuration: $result"
295
296 result=$(curl -k --request PATCH \
297 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/post-logout-redirect-uri \
298 --header 'accept: application/vnd.yang.data+json' \
299 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
300 --header 'cache-control: no-cache' \
301 --header 'content-type: application/vnd.yang.data+json' \
302 --data '{"post-logout-redirect-uri": "https://'$DEFAULT_IP':8443/?api_server=https://'$DEFAULT_IP'" }')
303 [[ $result =~ .*success.* ]] || FATAL "Failed post-logout-redirect-uri configuration: $result"
304
Jeremy Mordkofff4b6e622017-10-04 12:05:41 -0400305 lxc exec SO-ub -- tee /etc/network/interfaces.d/60-rift.cfg <<EOF
306auto lo:1
307iface lo:1 inet static
308 address $DEFAULT_IP
309 netmask 255.255.255.255
310EOF
311 lxc exec SO-ub ifup lo:1
garciadeblas0d934c12017-11-17 15:39:17 +0100312}
Jeremy Mordkoff2059b392017-10-03 17:34:10 -0400313
garciadeblas0d934c12017-11-17 15:39:17 +0100314#Configure RO, VCA, and SO with the initial configuration:
315# RO -> tenant:osm, logs to be sent to SO
316# VCA -> juju-password
317# SO -> route to Juju Controller, add RO account, add VCA account
318function configure(){
319 #Configure components
320 echo -e "\nConfiguring components"
321 configure_RO
322 configure_VCA
323 configure_SOUI
garciadeblas55490d42016-10-29 14:22:03 +0200324}
325
garciadeblas2a5a6512016-12-19 10:19:52 +0100326function install_lxd() {
garciadeblas0d934c12017-11-17 15:39:17 +0100327 sudo apt-get update
328 sudo apt-get install -y lxd
329 newgrp lxd
garciadeblas2a5a6512016-12-19 10:19:52 +0100330 lxd init --auto
331 lxd waitready
garciadeblas0d934c12017-11-17 15:39:17 +0100332 lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
333 DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
334 DEFAULT_MTU=$( ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
335 lxc profile device set default eth0 mtu $DEFAULT_MTU
336 #sudo systemctl stop lxd-bridge
337 #sudo systemctl --system daemon-reload
338 #sudo systemctl enable lxd-bridge
339 #sudo systemctl start lxd-bridge
garciadeblas2a5a6512016-12-19 10:19:52 +0100340}
341
tierno53881d72017-04-25 11:58:57 +0200342function ask_user(){
343 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
344 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
345 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
346 read -e -p "$1" USER_CONFIRMATION
347 while true ; do
348 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
349 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
350 [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
351 [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
352 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
353 done
354}
garciadeblas2a5a6512016-12-19 10:19:52 +0100355
garciadeblas0d934c12017-11-17 15:39:17 +0100356function launch_container_from_lxd(){
357 export OSM_MDG=$1
358 OSM_load_config
359 export OSM_BASE_IMAGE=$2
360 if ! container_exists $OSM_BUILD_CONTAINER; then
361 CONTAINER_OPTS=""
362 [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true"
363 [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true"
364 create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
365 wait_container_up $OSM_BUILD_CONTAINER
366 fi
367}
368
369function install_osmclient(){
370 CLIENT_RELEASE=${RELEASE#"-R "}
371 CLIENT_REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
372 CLIENT_REPOSITORY="stable"
373 [ -z "$REPOSITORY_BASE" ] && REPOSITORY_BASE="-u https://osm-download.etsi.org/repository/osm/debian"
374 CLIENT_REPOSITORY_BASE=${REPOSITORY_BASE#"-u "}
375 key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
376 curl $key_location | sudo apt-key add -
377 sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
378 sudo apt-get update
379 sudo apt-get install -y python-osmclient
380 export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
381 export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
382 echo -e "\nOSM client installed"
383 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
384 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
385 echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
386}
387
388function install_from_lxdimages(){
389 LXD_RELEASE=${RELEASE#"-R "}
garciadeblasfc8f0292018-04-02 16:55:29 +0200390 if [ -n "$LXD_REPOSITORY_PATH" ]; then
391 LXD_IMAGE_DIR="$LXD_REPOSITORY_PATH"
392 else
393 LXD_IMAGE_DIR="$(mktemp -d -q --tmpdir "osmimages.XXXXXX")"
394 trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
395 fi
garciadeblas54e7eed2018-03-19 17:38:04 +0100396 echo -e "\nDeleting previous lxd images if they exist"
397 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
398 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
399 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
400 echo -e "\nImporting osm-ro"
garciadeblasfc8f0292018-04-02 16:55:29 +0200401 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-ro.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.tar.gz
garciadeblas0d934c12017-11-17 15:39:17 +0100402 lxc image import $LXD_IMAGE_DIR/osm-ro.tar.gz --alias osm-ro
403 rm -f $LXD_IMAGE_DIR/osm-ro.tar.gz
garciadeblas54e7eed2018-03-19 17:38:04 +0100404 echo -e "\nImporting osm-vca"
garciadeblasfc8f0292018-04-02 16:55:29 +0200405 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-vca.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.tar.gz
garciadeblas0d934c12017-11-17 15:39:17 +0100406 lxc image import $LXD_IMAGE_DIR/osm-vca.tar.gz --alias osm-vca
407 rm -f $LXD_IMAGE_DIR/osm-vca.tar.gz
garciadeblas54e7eed2018-03-19 17:38:04 +0100408 echo -e "\nImporting osm-soui"
garciadeblasfc8f0292018-04-02 16:55:29 +0200409 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-soui.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.tar.gz
garciadeblas0d934c12017-11-17 15:39:17 +0100410 lxc image import $LXD_IMAGE_DIR/osm-soui.tar.gz --alias osm-soui
411 rm -f $LXD_IMAGE_DIR/osm-soui.tar.gz
412 launch_container_from_lxd RO osm-ro
413 ro_is_up && track RO
414 launch_container_from_lxd VCA osm-vca
415 vca_is_up && track VCA
416 launch_container_from_lxd SO osm-soui
417 #so_is_up && track SOUI
418 track SOUI
419}
420
peusterm3a3e7a52017-12-22 13:10:54 +0100421function install_docker_ce() {
422 # installs and configures Docker CE
423 echo "Installing Docker CE ..."
peusterme2c017e2018-02-07 11:51:11 +0100424 sudo apt-get -qq update
425 sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
peusterm3a3e7a52017-12-22 13:10:54 +0100426 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
427 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
428 sudo apt-get -qq update
peusterme2c017e2018-02-07 11:51:11 +0100429 sudo apt-get install -y docker-ce
peusterm3a3e7a52017-12-22 13:10:54 +0100430 echo "Adding user to group 'docker'"
peusterme2c017e2018-02-07 11:51:11 +0100431 sudo groupadd -f docker
peusterm3a3e7a52017-12-22 13:10:54 +0100432 sudo usermod -aG docker $USER
433 echo "... Docker CE installation done"
peusterme2c017e2018-02-07 11:51:11 +0100434 sleep 2
435 sudo service docker restart
436 echo "... restarted Docker service"
peusterm3a3e7a52017-12-22 13:10:54 +0100437}
438
439function install_vimemu() {
440 # install Docker
441 install_docker_ce
442 # clone vim-emu repository (attention: branch is currently master only)
443 echo "Cloning vim-emu repository ..."
444 git clone https://osm.etsi.org/gerrit/osm/vim-emu.git
445 # build vim-emu docker
446 echo "Building vim-emu Docker container..."
peusterme2c017e2018-02-07 11:51:11 +0100447 sudo docker build -t vim-emu-img -f vim-emu/Dockerfile vim-emu/
peusterm3a3e7a52017-12-22 13:10:54 +0100448 # start vim-emu container as daemon
449 echo "Starting vim-emu Docker container 'vim-emu' ..."
peusterme2c017e2018-02-07 11:51:11 +0100450 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
peusterm3a3e7a52017-12-22 13:10:54 +0100451 echo "Waiting for 'vim-emu' container to start ..."
452 sleep 5
peusterme2c017e2018-02-07 11:51:11 +0100453 export VIMEMU_HOSTNAME=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
peusterm3a3e7a52017-12-22 13:10:54 +0100454 echo "vim-emu running at $VIMEMU_HOSTNAME ..."
peustermd74dc842018-01-24 15:32:17 +0100455 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
456 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
457 echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
458 echo -e "You might be interested in adding the following vim-emu env variables to your .bashrc file:"
peusterm3a3e7a52017-12-22 13:10:54 +0100459 echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
460 echo -e "\nTo add the emulated VIM to OSM you should do:"
peustermd74dc842018-01-24 15:32:17 +0100461 echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack"
peusterm3a3e7a52017-12-22 13:10:54 +0100462}
463
garciadeblas0d934c12017-11-17 15:39:17 +0100464function dump_vars(){
465 echo "DEVELOP=$DEVELOP"
466 echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
467 echo "UNINSTALL=$UNINSTALL"
468 echo "NAT=$NAT"
469 echo "UPDATE=$UPDATE"
470 echo "RECONFIGURE=$RECONFIGURE"
471 echo "TEST_INSTALLER=$TEST_INSTALLER"
peusterm3a3e7a52017-12-22 13:10:54 +0100472 echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
garciadeblas0d934c12017-11-17 15:39:17 +0100473 echo "INSTALL_LXD=$INSTALL_LXD"
474 echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
475 echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
garciadeblasfc8f0292018-04-02 16:55:29 +0200476 echo "LXD_REPOSITORY_PATH=$LXD_REPOSITORY_PATH"
garciadeblas0d934c12017-11-17 15:39:17 +0100477 echo "RELEASE=$RELEASE"
478 echo "REPOSITORY=$REPOSITORY"
479 echo "REPOSITORY_BASE=$REPOSITORY_BASE"
480 echo "REPOSITORY_KEY=$REPOSITORY_KEY"
481 echo "NOCONFIGURE=$NOCONFIGURE"
482 echo "SHOWOPTS=$SHOWOPTS"
483 echo "Install from specific refspec (-b): $COMMIT_ID"
484}
485
486function track(){
487 ctime=`date +%s`
488 duration=$((ctime - SESSION_ID))
489 url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
490 #url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
491 event_name="bin"
492 [ -n "$INSTALL_FROM_SOURCE" ] && event_name="src"
493 [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
494 event_name="${event_name}_$1"
495 url="${url}&event=${event_name}&ce_duration=${duration}"
496 wget -q -O /dev/null $url
497}
498
garciadeblas93c61312016-09-28 15:12:48 +0200499UNINSTALL=""
500DEVELOP=""
501NAT=""
garciadeblas2a382732017-01-12 12:11:14 +0100502UPDATE=""
garciadeblas55490d42016-10-29 14:22:03 +0200503RECONFIGURE=""
504TEST_INSTALLER=""
garciadeblas0d934c12017-11-17 15:39:17 +0100505INSTALL_LXD=""
garciadeblas2a5a6512016-12-19 10:19:52 +0100506SHOWOPTS=""
507COMMIT_ID=""
tierno2cc8e252017-03-08 17:12:05 +0100508ASSUME_YES=""
garciadeblasa1fc4572017-04-24 19:08:21 +0200509INSTALL_FROM_SOURCE=""
garciadeblas82442292017-11-16 14:48:12 +0100510RELEASE="-R ReleaseTHREE"
peusterm3a3e7a52017-12-22 13:10:54 +0100511INSTALL_VIMEMU=""
garciadeblas0d934c12017-11-17 15:39:17 +0100512INSTALL_FROM_LXDIMAGES=""
513LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
garciadeblasfc8f0292018-04-02 16:55:29 +0200514LXD_REPOSITORY_PATH=""
garciadeblas0d934c12017-11-17 15:39:17 +0100515NOCONFIGURE=""
Mike Marchettica56c642017-12-16 16:04:52 -0500516RELEASE_DAILY=""
garciadeblas0d934c12017-11-17 15:39:17 +0100517SESSION_ID=`date +%s`
518
garciadeblasfc8f0292018-04-02 16:55:29 +0200519while getopts ":hy-:b:r:k:u:R:l:p:" o; do
garciadeblas93c61312016-09-28 15:12:48 +0200520 case "${o}" in
521 h)
522 usage && exit 0
523 ;;
garciadeblas2a5a6512016-12-19 10:19:52 +0100524 b)
525 COMMIT_ID=${OPTARG}
526 ;;
Mike Marchetti425f8ce2017-06-15 13:02:16 -0400527 r)
528 REPOSITORY="-r ${OPTARG}"
529 ;;
530 R)
531 RELEASE="-R ${OPTARG}"
532 ;;
533 k)
534 REPOSITORY_KEY="-k ${OPTARG}"
535 ;;
536 u)
537 REPOSITORY_BASE="-u ${OPTARG}"
538 ;;
garciadeblas0d934c12017-11-17 15:39:17 +0100539 l)
540 LXD_REPOSITORY_BASE="${OPTARG}"
541 ;;
garciadeblasfc8f0292018-04-02 16:55:29 +0200542 p)
543 LXD_REPOSITORY_PATH="${OPTARG}"
544 ;;
garciadeblas93c61312016-09-28 15:12:48 +0200545 -)
546 [ "${OPTARG}" == "help" ] && usage && exit 0
garciadeblasa1fc4572017-04-24 19:08:21 +0200547 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
garciadeblas93c61312016-09-28 15:12:48 +0200548 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
549 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
550 [ "${OPTARG}" == "nat" ] && NAT="y" && continue
garciadeblas2a382732017-01-12 12:11:14 +0100551 [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
garciadeblas55490d42016-10-29 14:22:03 +0200552 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
553 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
garciadeblas0d934c12017-11-17 15:39:17 +0100554 [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
555 [ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
peusterm3a3e7a52017-12-22 13:10:54 +0100556 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
garciadeblas0d934c12017-11-17 15:39:17 +0100557 [ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
garciadeblas2a5a6512016-12-19 10:19:52 +0100558 [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
Mike Marchettica56c642017-12-16 16:04:52 -0500559 [ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
garciadeblas93c61312016-09-28 15:12:48 +0200560 echo -e "Invalid option: '--$OPTARG'\n" >&2
561 usage && exit 1
562 ;;
563 \?)
564 echo -e "Invalid option: '-$OPTARG'\n" >&2
565 usage && exit 1
566 ;;
tierno2cc8e252017-03-08 17:12:05 +0100567 y)
568 ASSUME_YES="y"
569 ;;
garciadeblas93c61312016-09-28 15:12:48 +0200570 *)
571 usage && exit 1
572 ;;
573 esac
574done
575
garciadeblasa6ff9862017-04-07 02:00:29 +0200576if [ -n "$SHOWOPTS" ]; then
garciadeblas0d934c12017-11-17 15:39:17 +0100577 dump_vars
garciadeblasa6ff9862017-04-07 02:00:29 +0200578 exit 0
579fi
580
Mike Marchettica56c642017-12-16 16:04:52 -0500581[ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
582
Mike Marchetti6930bc02017-05-31 16:33:02 -0400583# if develop, we force master
garciadeblas2a5a6512016-12-19 10:19:52 +0100584[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
Mike Marchetti6930bc02017-05-31 16:33:02 -0400585
Mike Marchetti0d567602017-09-29 14:30:28 -0400586# forcing source from master removed. Now only install from source when explicit
587# [ -n "$COMMIT_ID" ] && [ "$COMMIT_ID" == "master" ] && INSTALL_FROM_SOURCE="y"
garciadeblas2a5a6512016-12-19 10:19:52 +0100588
garciadeblas55490d42016-10-29 14:22:03 +0200589if [ -n "$TEST_INSTALLER" ]; then
590 echo -e "\nUsing local devops repo for OSM installation"
591 TEMPDIR="$(dirname $(realpath $(dirname $0)))"
592else
593 echo -e "\nCreating temporary dir for OSM installation"
594 TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
595 trap 'rm -rf "$TEMPDIR"' EXIT
596fi
garciadeblas93c61312016-09-28 15:12:48 +0200597
Mike Marchetti2b951282017-10-10 15:43:15 -0400598need_packages="git jq"
599for package in $need_packages; do
600 echo -e "Checking required packages: $package"
Mike Marchettid8577f52017-10-19 15:27:48 -0400601 dpkg -l $package &>/dev/null \
602 || ! echo -e " $package not installed.\nInstalling $package requires root privileges" \
603 || sudo apt-get install -y $package \
604 || FATAL "failed to install $package"
Mike Marchetti2b951282017-10-10 15:43:15 -0400605done
606
garciadeblas55490d42016-10-29 14:22:03 +0200607if [ -z "$TEST_INSTALLER" ]; then
608 echo -e "\nCloning devops repo temporarily"
609 git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
610 RC_CLONE=$?
garciadeblas55490d42016-10-29 14:22:03 +0200611fi
garciadeblas2a382732017-01-12 12:11:14 +0100612
613echo -e "\nGuessing the current stable release"
Mike Marchetti91df8352017-10-17 13:47:48 -0400614LATEST_STABLE_DEVOPS=`git -C $TEMPDIR tag -l v[0-9].* | sort -V | tail -n1`
garciadeblas2a382732017-01-12 12:11:14 +0100615[ -z "$COMMIT_ID" ] && [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
garciadeblasa6ff9862017-04-07 02:00:29 +0200616echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
617[ -z "$COMMIT_ID" ] && [ -n "$LATEST_STABLE_DEVOPS" ] && COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
Mike Marchettica56c642017-12-16 16:04:52 -0500618
619if [ -n "$RELEASE_DAILY" ]; then
620 echo "Using master/HEAD devops"
621 git -C $TEMPDIR checkout master
622elif [ -z "$TEST_INSTALLER" ]; then
623 git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS
624fi
garciadeblas2a382732017-01-12 12:11:14 +0100625
garciadeblas93c61312016-09-28 15:12:48 +0200626OSM_DEVOPS=$TEMPDIR
garciadeblas0fe45dd2016-10-04 07:54:17 +0200627OSM_JENKINS="$TEMPDIR/jenkins"
628. $OSM_JENKINS/common/all_funcs
garciadeblas93c61312016-09-28 15:12:48 +0200629
garciadeblasd8718f12016-10-30 19:39:01 +0100630[ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0
631[ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0
garciadeblas2a382732017-01-12 12:11:14 +0100632[ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0
garciadeblasd8718f12016-10-30 19:39:01 +0100633[ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0
garciadeblas93c61312016-09-28 15:12:48 +0200634
635#Installation starts here
garciadeblasa1fc4572017-04-24 19:08:21 +0200636echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
637if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
tierno53881d72017-04-25 11:58:57 +0200638 ! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
tierno2cc8e252017-03-08 17:12:05 +0100639fi
640
garciadeblasa1fc4572017-04-24 19:08:21 +0200641echo -e "\nChecking required packages: wget, curl, tar"
642dpkg -l wget curl tar &>/dev/null || ! echo -e " One or several packages are not installed.\nInstalling required packages\n Root privileges are required" || sudo apt-get install -y wget curl tar
643
Jokin Garayc0a65962017-03-09 14:51:48 +0100644echo -e "Checking required packages: lxd"
garciadeblasd880f722017-04-07 20:14:57 +0200645lxd --version &>/dev/null || FATAL "lxd not present, exiting."
garciadeblas0d934c12017-11-17 15:39:17 +0100646[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
garciadeblas2a5a6512016-12-19 10:19:52 +0100647
Mike Marchettib884a462017-10-05 13:28:33 -0400648wget -q -O- https://osm-download.etsi.org/ftp/osm-3.0-three/README.txt &> /dev/null
garciadeblas0d934c12017-11-17 15:39:17 +0100649track start
garciadeblas93c61312016-09-28 15:12:48 +0200650
Mike Marchettid1e08b92017-09-29 16:14:11 -0400651# use local devops for containers
652export OSM_USE_LOCAL_DEVOPS=true
garciadeblas0d934c12017-11-17 15:39:17 +0100653if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
garciadeblasa1fc4572017-04-24 19:08:21 +0200654 echo -e "\nCreating the containers and building from source ..."
655 $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
garciadeblas0d934c12017-11-17 15:39:17 +0100656 ro_is_up && track RO
garciadeblasa1fc4572017-04-24 19:08:21 +0200657 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
garciadeblas0d934c12017-11-17 15:39:17 +0100658 vca_is_up && track VCA
garciadeblasa1fc4572017-04-24 19:08:21 +0200659 $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
660 $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
garciadeblas0d934c12017-11-17 15:39:17 +0100661 #so_is_up && track SOUI
662 track SOUI
663elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
664 echo -e "\nInstalling from lxd images ..."
665 install_from_lxdimages
666else #install from binaries
667 echo -e "\nCreating the containers and installing from binaries ..."
668 $OSM_DEVOPS/jenkins/host/install RO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "RO install failed"
669 ro_is_up && track RO
670 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
671 vca_is_up && track VCA
672 $OSM_DEVOPS/jenkins/host/install SO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "SO install failed"
673 $OSM_DEVOPS/jenkins/host/install UI $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "UI install failed"
674 #so_is_up && track SOUI
675 track SOUI
garciadeblasa1fc4572017-04-24 19:08:21 +0200676fi
garciadeblas93c61312016-09-28 15:12:48 +0200677
garciadeblas55490d42016-10-29 14:22:03 +0200678#Install iptables-persistent and configure NAT rules
garciadeblas0d934c12017-11-17 15:39:17 +0100679[ -z "$NOCONFIGURE" ] && nat
garciadeblas93c61312016-09-28 15:12:48 +0200680
681#Configure components
garciadeblas0d934c12017-11-17 15:39:17 +0100682[ -z "$NOCONFIGURE" ] && configure
683
684#Install osmclient
685[ -z "$NOCONFIGURE" ] && install_osmclient
garciadeblas93c61312016-09-28 15:12:48 +0200686
peusterm3a3e7a52017-12-22 13:10:54 +0100687#Install vim-emu (optional)
688if [ -n "$INSTALL_VIMEMU" ]; then
689 echo -e "\nInstalling vim-emu ..."
690 install_vimemu
691fi
692
Mike Marchettib884a462017-10-05 13:28:33 -0400693wget -q -O- https://osm-download.etsi.org/ftp/osm-3.0-three/README2.txt &> /dev/null
garciadeblas0d934c12017-11-17 15:39:17 +0100694track end
Jokin Garay3eb9ce72017-03-09 14:48:11 +0100695echo -e "\nDONE"
garciadeblas0d934c12017-11-17 15:39:17 +0100696