2 # Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 echo -e "usage: $0 [OPTIONS]"
18 echo -e "Install OSM from binaries or source code (by default, from binaries)"
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)"
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 " -t <docker tag> specify osm docker tag (default is latest)"
40 echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
41 echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
42 echo -e " --nojuju: do not juju, assumes already installed"
43 echo -e " --nodockerbuild:do not build docker images (use existing locally cached images)"
44 echo -e " --nohostports: do not expose docker ports to host (useful for creating multiple instances of osm on the same host)"
45 echo -e " --nohostclient: do not install the osmclient"
46 echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
47 echo -e " --source: install OSM from source code using the latest stable tag"
48 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
49 echo -e " --soui: install classic build of OSM (Rel THREE v3.1, based on LXD containers, with SO and UI)"
50 echo -e " --lxdimages: (only for Rel THREE with --soui) download lxd images from OSM repository instead of creating them from scratch"
51 echo -e " --pullimages: pull/run osm images from docker.io/opensourcemano"
52 echo -e " -l <lxd_repo>: (only for Rel THREE with --soui) use specified repository url for lxd images"
53 echo -e " -p <path>: (only for Rel THREE with --soui) use specified repository path for lxd images"
54 # echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
55 echo -e " --nat: (only for Rel THREE with --soui) install only NAT rules"
56 echo -e " --noconfigure: (only for Rel THREE with --soui) DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
57 # echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
58 echo -e " --showopts: print chosen options and exit (only for debugging)"
59 echo -e " -y: do not prompt for confirmation, assumes yes"
60 echo -e " -h / --help: print this help"
63 #Uninstall OSM: remove containers
65 echo -e "\nUninstalling OSM"
66 if [ $RC_CLONE ] ||
[ -n "$TEST_INSTALLER" ]; then
67 $OSM_DEVOPS/jenkins
/host
/clean_container RO
68 $OSM_DEVOPS/jenkins
/host
/clean_container VCA
69 $OSM_DEVOPS/jenkins
/host
/clean_container MON
70 $OSM_DEVOPS/jenkins
/host
/clean_container SO
71 #$OSM_DEVOPS/jenkins/host/clean_container UI
73 lxc stop RO
&& lxc delete RO
74 lxc stop VCA
&& lxc delete VCA
75 lxc stop MON
&& lxc delete MON
76 lxc stop SO-ub
&& lxc delete SO-ub
78 echo -e "\nDeleting imported lxd images if they exist"
79 lxc image show osm-ro
&>/dev
/null
&& lxc image delete osm-ro
80 lxc image show osm-vca
&>/dev
/null
&& lxc image delete osm-vca
81 lxc image show osm-soui
&>/dev
/null
&& lxc image delete osm-soui
85 # takes a juju/accounts.yaml file and returns the password specific
86 # for a controller. I wrote this using only bash tools to minimize
87 # additions of other packages
88 function parse_juju_password
{
89 password_file
="${HOME}/.local/share/juju/accounts.yaml"
90 local controller_name
=$1
91 local s
='[[:space:]]*' w
='[a-zA-Z0-9_-]*' fs
=$
(echo @|
tr @
'\034')
92 sed -ne "s|^\($s\):|\1|" \
93 -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
94 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $password_file |
95 awk -F$fs -v controller
=$controller_name '{
96 indent = length($1)/2;
98 for (i in vname) {if (i > indent) {delete vname[i]}}
100 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
101 if (match(vn,controller) && match($2,"password")) {
108 function remove_volumes
() {
110 volumes
="mongo_db mon_db osm_packages ro_db"
111 for volume
in $volumes; do
112 sg docker
-c "docker volume rm ${stack}_${volume}"
116 function remove_network
() {
118 sg docker
-c "docker network rm net${stack}"
121 function remove_stack
() {
123 if sg docker
-c "docker stack ps ${stack}" ; then
124 echo -e "\nRemoving stack ${stack}" && sg docker
-c "docker stack rm ${stack}"
127 while [ ${COUNTER} -lt 30 ]; do
128 result
=$
(sg docker
-c "docker stack ps ${stack}" |
wc -l)
129 #echo "Dockers running: $result"
130 if [ "${result}" == "0" ]; then
133 let COUNTER
=COUNTER
+1
136 if [ "${result}" == "0" ]; then
137 echo "All dockers of the stack ${stack} were removed"
139 FATAL
"Some dockers of the stack ${stack} could not be removed. Could not clean it."
145 #Uninstall lightweight OSM: remove dockers
146 function uninstall_lightweight
() {
147 if [ -n "$INSTALL_ONLY" ]; then
148 if [ -n "$INSTALL_ELK" ]; then
149 echo -e "\nUninstalling OSM ELK stack"
151 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR/osm_elk
153 if [ -n "$INSTALL_PERFMON" ]; then
154 echo -e "\nUninstalling OSM Performance Monitoring stack"
155 remove_stack osm_metrics
156 sg docker
-c "docker image rm osm/kafka-exporter"
157 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR/osm_metrics
160 echo -e "\nUninstalling OSM"
161 remove_stack
$OSM_STACK_NAME
163 remove_stack osm_metrics
164 echo "Now osm docker images and volumes will be deleted"
165 newgrp docker
<< EONG
166 docker image rm ${DOCKERUSER}/ro
167 docker image rm ${DOCKERUSER}/lcm
168 docker image rm ${DOCKERUSER}/light-ui
169 docker image rm ${DOCKERUSER}/keystone
170 docker image rm ${DOCKERUSER}/nbi
171 docker image rm ${DOCKERUSER}/mon
172 docker image rm ${DOCKERUSER}/pm
173 docker image rm ${DOCKERUSER}/kafka-exporter
175 remove_volumes
$OSM_STACK_NAME
176 remove_network
$OSM_STACK_NAME
177 echo "Removing $OSM_DOCKER_WORK_DIR"
178 $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR
179 sg lxd
-c "juju destroy-controller --yes $OSM_STACK_NAME"
181 echo "Some docker images will be kept in case they are used by other docker stacks"
182 echo "To remove them, just run 'docker image prune' in a terminal"
186 #Configure NAT rules, based on the current IP addresses of containers
188 echo -e "\nChecking required packages: iptables-persistent"
189 dpkg
-l iptables-persistent
&>/dev
/null ||
! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
190 sudo DEBIAN_FRONTEND
=noninteractive apt-get
-yq install iptables-persistent
191 echo -e "\nConfiguring NAT rules"
192 echo -e " Required root privileges"
193 sudo
$OSM_DEVOPS/installers
/nat_osm
197 echo "FATAL error: Cannot install OSM due to \"$1\""
201 #Update RO, SO and UI:
203 echo -e "\nUpdating components"
205 echo -e " Updating RO"
208 INSTALL_FOLDER
="/opt/openmano"
209 echo -e " Fetching the repo"
210 lxc
exec $CONTAINER -- git
-C $INSTALL_FOLDER fetch
--all
212 BRANCH
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
213 [ -z "$BRANCH" ] && FATAL
"Could not find the current branch in use in the '$MDG'"
214 CURRENT
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
215 CURRENT_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
216 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
217 # COMMIT_ID either was previously set with -b option, or is an empty string
218 CHECKOUT_ID
=$COMMIT_ID
219 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID
="tags/$LATEST_STABLE_DEVOPS"
220 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID
="$BRANCH"
221 if [[ $CHECKOUT_ID == "tags/"* ]]; then
222 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
224 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
226 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
227 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
228 echo " Nothing to be done."
230 echo " Update required."
231 lxc
exec $CONTAINER -- service osm-ro stop
232 lxc
exec $CONTAINER -- git
-C /opt
/openmano stash
233 lxc
exec $CONTAINER -- git
-C /opt
/openmano pull
--rebase
234 lxc
exec $CONTAINER -- git
-C /opt
/openmano checkout
$CHECKOUT_ID
235 lxc
exec $CONTAINER -- git
-C /opt
/openmano stash pop
236 lxc
exec $CONTAINER -- /opt
/openmano
/database_utils
/migrate_mano_db.sh
237 lxc
exec $CONTAINER -- service osm-ro start
241 echo -e " Updating SO and UI"
244 INSTALL_FOLDER
="" # To be filled in
245 echo -e " Fetching the repo"
246 lxc
exec $CONTAINER -- git
-C $INSTALL_FOLDER fetch
--all
248 BRANCH
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
249 [ -z "$BRANCH" ] && FATAL
"Could not find the current branch in use in the '$MDG'"
250 CURRENT
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
251 CURRENT_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
252 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
253 # COMMIT_ID either was previously set with -b option, or is an empty string
254 CHECKOUT_ID
=$COMMIT_ID
255 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID
="tags/$LATEST_STABLE_DEVOPS"
256 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID
="$BRANCH"
257 if [[ $CHECKOUT_ID == "tags/"* ]]; then
258 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
260 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
262 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
263 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
264 echo " Nothing to be done."
266 echo " Update required."
267 # Instructions to be added
268 # lxc exec SO-ub -- ...
271 echo -e "Updating MON Container"
274 INSTALL_FOLDER
="/root/MON"
275 echo -e " Fetching the repo"
276 lxc
exec $CONTAINER -- git
-C $INSTALL_FOLDER fetch
--all
278 BRANCH
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
279 [ -z "$BRANCH" ] && FATAL
"Could not find the current branch in use in the '$MDG'"
280 CURRENT
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
281 CURRENT_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
282 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
283 # COMMIT_ID either was previously set with -b option, or is an empty string
284 CHECKOUT_ID
=$COMMIT_ID
285 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID
="tags/$LATEST_STABLE_DEVOPS"
286 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID
="$BRANCH"
287 if [[ $CHECKOUT_ID == "tags/"* ]]; then
288 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
290 REMOTE_COMMIT_ID
=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
292 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
293 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
294 echo " Nothing to be done."
296 echo " Update required."
301 function so_is_up
() {
305 SO_IP
=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
310 while [ $time -le $timelength ]
312 if [[ `curl -k -X GET https://$SO_IP:8008/api/operational/vcs/info \
313 -H 'accept: application/vnd.yang.data+json' \
314 -H 'authorization: Basic YWRtaW46YWRtaW4=' \
315 -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 ]]
317 echo "RW.Restconf running....SO is up"
326 FATAL
"OSM Failed to startup. SO failed to startup"
329 function vca_is_up
() {
330 if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
331 echo "VCA is up and running"
335 FATAL
"OSM Failed to startup. VCA failed to startup"
338 function mon_is_up
() {
339 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
340 echo "MON is up and running"
344 FATAL
"OSM Failed to startup. MON failed to startup"
347 function ro_is_up
() {
351 RO_IP
=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
356 while [ $time -le $timelength ]; do
357 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
358 echo "RO is up and running"
366 FATAL
"OSM Failed to startup. RO failed to startup"
370 function configure_RO
(){
371 .
$OSM_DEVOPS/installers
/export_ips
372 echo -e " Configuring RO"
373 lxc
exec RO
-- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc
/osm
/openmanod.cfg
374 lxc
exec RO
-- service osm-ro restart
378 lxc
exec RO
-- openmano tenant-delete
-f osm
>/dev
/null
379 lxc
exec RO
-- openmano tenant-create osm
> /dev
/null
380 lxc
exec RO
-- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
381 lxc
exec RO
-- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
382 lxc
exec RO
-- sh
-c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
385 function configure_VCA
(){
386 echo -e " Configuring VCA"
387 JUJU_PASSWD
=`date +%s | sha256sum | base64 | head -c 32`
388 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc
exec VCA
-- juju change-user-password
391 function configure_SOUI
(){
392 .
$OSM_DEVOPS/installers
/export_ips
393 JUJU_CONTROLLER_IP
=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
394 RO_TENANT_ID
=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
396 echo -e " Configuring MON"
397 #Information to be added about SO socket for logging
399 echo -e " Configuring SO"
400 sudo route add
-host $JUJU_CONTROLLER_IP gw
$VCA_CONTAINER_IP
401 sudo ip route add
10.44.127.0/24 via
$VCA_CONTAINER_IP
402 sudo
sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc
/rc.
local
403 sudo
sed -i "$ i ip route add 10.44.127.0/24 via $VCA_CONTAINER_IP" /etc
/rc.
local
404 # make journaling persistent
405 lxc
exec SO-ub
-- mkdir
-p /var
/log
/journal
406 lxc
exec SO-ub
-- systemd-tmpfiles
--create --prefix /var
/log
/journal
407 lxc
exec SO-ub
-- systemctl restart systemd-journald
409 echo RIFT_EXTERNAL_ADDRESS
=$DEFAULT_IP | lxc
exec SO-ub
-- tee -a /usr
/rift
/etc
/default
/launchpad
411 lxc
exec SO-ub
-- systemctl restart launchpad
413 so_is_up
$SO_CONTAINER_IP
415 #delete existing config agent (could be there on reconfigure)
416 curl
-k --request DELETE \
417 --url https
://$SO_CONTAINER_IP:8008/api
/config
/config-agent
/account
/osmjuju \
418 --header 'accept: application/vnd.yang.data+json' \
419 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
420 --header 'cache-control: no-cache' \
421 --header 'content-type: application/vnd.yang.data+json' &> /dev
/null
423 result
=$
(curl
-k --request POST \
424 --url https
://$SO_CONTAINER_IP:8008/api
/config
/config-agent \
425 --header 'accept: application/vnd.yang.data+json' \
426 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
427 --header 'cache-control: no-cache' \
428 --header 'content-type: application/vnd.yang.data+json' \
429 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}')
430 [[ $result =~ .
*success.
* ]] || FATAL
"Failed config-agent configuration: $result"
433 #result=$(curl -k --request PUT \
434 # --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \
435 # --header 'accept: application/vnd.yang.data+json' \
436 # --header 'authorization: Basic YWRtaW46YWRtaW4=' \
437 # --header 'cache-control: no-cache' \
438 # --header 'content-type: application/vnd.yang.data+json' \
439 # --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }')
441 result
=$
(curl
-k --request PUT \
442 --url https
://$SO_CONTAINER_IP:8008/api
/config
/project
/default
/ro-account
/account \
443 --header 'accept: application/vnd.yang.data+json' \
444 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
445 --header 'cache-control: no-cache' \
446 --header 'content-type: application/vnd.yang.data+json' \
447 --data '{"rw-ro-account:account": [ { "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'"}, "name": "osmopenmano", "ro-account-type": "openmano" }]}')
448 [[ $result =~ .
*success.
* ]] || FATAL
"Failed resource-orchestrator configuration: $result"
450 result
=$
(curl
-k --request PATCH \
451 --url https
://$SO_CONTAINER_IP:8008/v
2/api
/config
/openidc-provider-config
/rw-ui-client
/redirect-uri \
452 --header 'accept: application/vnd.yang.data+json' \
453 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
454 --header 'cache-control: no-cache' \
455 --header 'content-type: application/vnd.yang.data+json' \
456 --data '{"redirect-uri": "https://'$DEFAULT_IP':8443/callback" }')
457 [[ $result =~ .
*success.
* ]] || FATAL
"Failed redirect-uri configuration: $result"
459 result
=$
(curl
-k --request PATCH \
460 --url https
://$SO_CONTAINER_IP:8008/v
2/api
/config
/openidc-provider-config
/rw-ui-client
/post-logout-redirect-uri \
461 --header 'accept: application/vnd.yang.data+json' \
462 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
463 --header 'cache-control: no-cache' \
464 --header 'content-type: application/vnd.yang.data+json' \
465 --data '{"post-logout-redirect-uri": "https://'$DEFAULT_IP':8443/?api_server=https://'$DEFAULT_IP'" }')
466 [[ $result =~ .
*success.
* ]] || FATAL
"Failed post-logout-redirect-uri configuration: $result"
468 lxc
exec SO-ub
-- tee /etc
/network
/interfaces.d
/60-rift.cfg
<<EOF
470 iface lo:1 inet static
472 netmask 255.255.255.255
474 lxc
exec SO-ub ifup lo
:1
477 #Configure RO, VCA, and SO with the initial configuration:
478 # RO -> tenant:osm, logs to be sent to SO
479 # VCA -> juju-password
480 # SO -> route to Juju Controller, add RO account, add VCA account
481 function configure
(){
482 #Configure components
483 echo -e "\nConfiguring components"
489 function install_lxd
() {
491 sudo apt-get
install -y lxd
495 lxc network create lxdbr0 ipv4.address
=auto ipv4.nat
=true ipv6.address
=none ipv6.nat
=false
496 DEFAULT_INTERFACE
=$
(route
-n |
awk '$1~/^0.0.0.0/ {print $8}')
497 DEFAULT_MTU
=$
(ip addr show
$DEFAULT_INTERFACE | perl
-ne 'if (/mtu\s(\d+)/) {print $1;}')
498 lxc profile device
set default eth0 mtu
$DEFAULT_MTU
499 #sudo systemctl stop lxd-bridge
500 #sudo systemctl --system daemon-reload
501 #sudo systemctl enable lxd-bridge
502 #sudo systemctl start lxd-bridge
506 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
507 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
508 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
509 read -e -p "$1" USER_CONFIRMATION
511 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
512 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
513 [ "${USER_CONFIRMATION,,}" == "yes" ] ||
[ "${USER_CONFIRMATION,,}" == "y" ] && return 0
514 [ "${USER_CONFIRMATION,,}" == "no" ] ||
[ "${USER_CONFIRMATION,,}" == "n" ] && return 1
515 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
519 function launch_container_from_lxd
(){
522 export OSM_BASE_IMAGE
=$2
523 if ! container_exists
$OSM_BUILD_CONTAINER; then
525 [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS
="$CONTAINER_OPTS -c security.privileged=true"
526 [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS
="$CONTAINER_OPTS -c security.nesting=true"
527 create_container
$OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
528 wait_container_up
$OSM_BUILD_CONTAINER
532 function install_osmclient
(){
533 CLIENT_RELEASE
=${RELEASE#"-R "}
534 CLIENT_REPOSITORY_KEY
="OSM%20ETSI%20Release%20Key.gpg"
535 CLIENT_REPOSITORY
=${REPOSITORY#"-r "}
536 CLIENT_REPOSITORY_BASE
=${REPOSITORY_BASE#"-u "}
537 key_location
=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
538 curl
$key_location | sudo apt-key add
-
539 sudo add-apt-repository
-y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
541 sudo apt-get
install -y python-pip
542 sudo
-H pip
install pip
==9.0.3
543 sudo
-H pip
install python-magic
544 sudo apt-get
install -y python-osmclient
545 #sed 's,OSM_SOL005=[^$]*,OSM_SOL005=True,' -i ${HOME}/.bashrc
546 #echo 'export OSM_HOSTNAME=localhost' >> ${HOME}/.bashrc
547 #echo 'export OSM_SOL005=True' >> ${HOME}/.bashrc
548 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME
=`lxc list | awk '($2=="SO-ub"){print $6}'`
549 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME
=`lxc list | awk '($2=="RO"){print $6}'`
550 [ -n "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME
=127.0.0.1
551 echo -e "\nOSM client installed"
552 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
553 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
554 [ -n "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_SOL005=True"
555 [ -z "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
559 function install_from_lxdimages
(){
560 LXD_RELEASE
=${RELEASE#"-R "}
561 if [ -n "$LXD_REPOSITORY_PATH" ]; then
562 LXD_IMAGE_DIR
="$LXD_REPOSITORY_PATH"
564 LXD_IMAGE_DIR
="$(mktemp -d -q --tmpdir "osmimages.XXXXXX
")"
565 trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
567 echo -e "\nDeleting previous lxd images if they exist"
568 lxc image show osm-ro
&>/dev
/null
&& lxc image delete osm-ro
569 lxc image show osm-vca
&>/dev
/null
&& lxc image delete osm-vca
570 lxc image show osm-soui
&>/dev
/null
&& lxc image delete osm-soui
571 echo -e "\nImporting osm-ro"
572 [ -z "$LXD_REPOSITORY_PATH" ] && wget
-O $LXD_IMAGE_DIR/osm-ro.
tar.gz
$LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.
tar.gz
573 lxc image import
$LXD_IMAGE_DIR/osm-ro.
tar.gz
--alias osm-ro
574 rm -f $LXD_IMAGE_DIR/osm-ro.
tar.gz
575 echo -e "\nImporting osm-vca"
576 [ -z "$LXD_REPOSITORY_PATH" ] && wget
-O $LXD_IMAGE_DIR/osm-vca.
tar.gz
$LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.
tar.gz
577 lxc image import
$LXD_IMAGE_DIR/osm-vca.
tar.gz
--alias osm-vca
578 rm -f $LXD_IMAGE_DIR/osm-vca.
tar.gz
579 echo -e "\nImporting osm-soui"
580 [ -z "$LXD_REPOSITORY_PATH" ] && wget
-O $LXD_IMAGE_DIR/osm-soui.
tar.gz
$LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.
tar.gz
581 lxc image import
$LXD_IMAGE_DIR/osm-soui.
tar.gz
--alias osm-soui
582 rm -f $LXD_IMAGE_DIR/osm-soui.
tar.gz
583 launch_container_from_lxd RO osm-ro
585 launch_container_from_lxd VCA osm-vca
586 vca_is_up
&& track VCA
587 launch_container_from_lxd MON osm-mon
588 mon_is_up
&& track MON
589 launch_container_from_lxd SO osm-soui
590 #so_is_up && track SOUI
594 function install_docker_ce
() {
595 # installs and configures Docker CE
596 echo "Installing Docker CE ..."
597 sudo apt-get
-qq update
598 sudo apt-get
install -y apt-transport-https ca-certificates software-properties-common
599 curl
-fsSL https
://download.docker.com
/linux
/ubuntu
/gpg | sudo apt-key add
-
600 sudo add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
601 sudo apt-get
-qq update
602 sudo apt-get
install -y docker-ce
603 echo "Adding user to group 'docker'"
604 sudo groupadd
-f docker
605 sudo usermod
-aG docker
$USER
607 sudo service docker restart
608 echo "... restarted Docker service"
609 sg docker
-c "docker version" || FATAL
"Docker installation failed"
610 echo "... Docker CE installation done"
614 function install_docker_compose
() {
615 # installs and configures docker-compose
616 echo "Installing Docker Compose ..."
617 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
618 sudo
chmod +x
/usr
/local
/bin
/docker-compose
619 echo "... Docker Compose installation done"
622 function install_juju
() {
623 echo "Installing juju"
624 sudo snap
install juju
--classic
625 [ -z "$INSTALL_NOLXD" ] && sudo dpkg-reconfigure
-p medium lxd
626 echo "Finished installation of juju"
630 function juju_createcontroller
() {
631 if ! sg lxd
-c "juju show-controller $OSM_STACK_NAME &> /dev/null"; then
632 # Not found created, create the controller
633 sg lxd
-c "juju bootstrap --bootstrap-series=xenial localhost $OSM_STACK_NAME"
635 [ $
(sg lxd
-c "juju controllers" |
awk "/^${OSM_STACK_NAME}[\*| ]/{print $1}"|
wc -l) -eq 1 ] || FATAL
"Juju installation failed"
638 function generate_docker_images
() {
639 echo "Pulling and generating docker images"
640 _build_from
=$COMMIT_ID
641 [ -z "$_build_from" ] && _build_from
="master"
643 echo "OSM Docker images generated from $_build_from"
645 BUILD_ARGS
+=(--build-arg REPOSITORY
="$REPOSITORY")
646 BUILD_ARGS
+=(--build-arg RELEASE
="$RELEASE")
647 BUILD_ARGS
+=(--build-arg REPOSITORY_KEY
="$REPOSITORY_KEY")
648 BUILD_ARGS
+=(--build-arg REPOSITORY_BASE
="$REPOSITORY_BASE")
650 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q KAFKA
; then
651 sg docker
-c "docker pull wurstmeister/zookeeper" || FATAL
"cannot get zookeeper docker image"
652 sg docker
-c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL
"cannot get kafka docker image"
655 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q MONGO
; then
656 sg docker
-c "docker pull mongo" || FATAL
"cannot get mongo docker image"
659 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q PROMETHEUS
; then
660 sg docker
-c "docker pull prom/prometheus:${PROMETHEUS_TAG}" || FATAL
"cannot get prometheus docker image"
663 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q KEYSTONE-DB
; then
664 sg docker
-c "docker pull mariadb:${KEYSTONEDB_TAG}" || FATAL
"cannot get keystone-db docker image"
667 if [ -n "$PULL_IMAGES" ]; then
668 sg docker
-c "docker pull ${DOCKER_USER}/mon:${OSM_DOCKER_TAG}" || FATAL
"cannot pull MON docker image"
669 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q MON
; then
670 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/MON
671 git
-C ${LWTEMPDIR}/MON checkout
${COMMIT_ID}
672 sg docker
-c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL
"cannot build MON docker image"
675 if [ -n "$PULL_IMAGES" ]; then
676 sg docker
-c "docker pull ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}" || FATAL
"cannot pull POL docker image"
677 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q MON
; then
678 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/POL
679 git
-C ${LWTEMPDIR}/POL checkout
${COMMIT_ID}
680 sg docker
-c "docker build ${LWTEMPDIR}/POL -f ${LWTEMPDIR}/POL/docker/Dockerfile -t osm/pol --no-cache" || FATAL
"cannot build PM docker image"
683 if [ -n "$PULL_IMAGES" ]; then
684 sg docker
-c "docker pull ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG}" || FATAL
"cannot pull NBI docker image"
685 sg docker
-c "docker pull ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG}" || FATAL
"cannot pull KEYSTONE docker image"
686 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q NBI
; then
687 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/NBI
688 git
-C ${LWTEMPDIR}/NBI checkout
${COMMIT_ID}
689 sg docker
-c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL
"cannot build NBI docker image"
690 sg docker
-c "docker build ${LWTEMPDIR}/NBI/keystone -f ${LWTEMPDIR}/NBI/keystone/Dockerfile -t osm/keystone --no-cache" || FATAL
"cannot build KEYSTONE docker image"
693 if [ -n "$PULL_IMAGES" ]; then
694 sg docker
-c "docker pull ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}" || FATAL
"cannot pull RO docker image"
695 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q RO
; then
696 sg docker
-c "docker pull mysql:5" || FATAL
"cannot get mysql docker image"
697 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/RO
698 git
-C ${LWTEMPDIR}/RO checkout
${COMMIT_ID}
699 sg docker
-c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL
"cannot build RO docker image"
702 if [ -n "$PULL_IMAGES" ]; then
703 sg docker
-c "docker pull ${DOCKER_USER}/lcm:${OSM_DOCKER_TAG}" || FATAL
"cannot pull LCM RO docker image"
704 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q LCM
; then
705 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/LCM
706 git
-C ${LWTEMPDIR}/LCM checkout
${COMMIT_ID}
707 sg docker
-c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL
"cannot build LCM docker image"
710 if [ -n "$PULL_IMAGES" ]; then
711 sg docker
-c "docker pull ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}" || FATAL
"cannot pull light-ui docker image"
712 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q LW-UI
; then
713 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/LW-UI
714 git
-C ${LWTEMPDIR}/LW-UI checkout
${COMMIT_ID}
715 sg docker
-c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/docker/Dockerfile --no-cache" || FATAL
"cannot build LW-UI docker image"
718 if [ -n "$PULL_IMAGES" ]; then
719 sg docker
-c "docker pull ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" || FATAL
"cannot pull osmclient docker image"
720 elif [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q LW-osmclient
; then
721 sg docker
-c "docker build -t osm/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
723 echo "Finished generation of docker images"
726 function cmp_overwrite
() {
729 if ! $
(cmp "${file1}" "${file2}" >/dev
/null
2>&1); then
730 if [ -f "${file2}" ]; then
731 ask_user
"The file ${file2} already exists. Overwrite (y/N)? " n && cp -b ${file1} ${file2}
733 cp -b ${file1} ${file2}
738 function generate_config_log_folders() {
739 echo "Generating config and log folders
"
740 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml
741 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus.yml
742 echo "Finished generation of config and log folders
"
745 function generate_docker_env_files() {
746 echo "Generating docker env files
"
747 echo "OSMLCM_VCA_HOST
=${OSM_VCA_HOST}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/lcm.env
748 echo "OSMLCM_VCA_SECRET
=${OSM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env
750 MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
751 if [ ! -f $OSM_DOCKER_WORK_DIR/ro-db.env ]; then
752 echo "MYSQL_ROOT_PASSWORD
=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro-db.env
754 if [ ! -f $OSM_DOCKER_WORK_DIR/ro.env ]; then
755 echo "RO_DB_ROOT_PASSWORD
=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/ro.env
758 MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
759 KEYSTONE_DB_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
760 #ADMIN_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` && sleep 1
761 NBI_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
762 if [ ! -f $OSM_DOCKER_WORK_DIR/keystone-db.env ]; then
763 echo "MYSQL_ROOT_PASSWORD
=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone-db.env
765 if [ ! -f $OSM_DOCKER_WORK_DIR/keystone.env ]; then
766 echo "ROOT_DB_PASSWORD
=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env
767 echo "KEYSTONE_DB_PASSWORD
=${KEYSTONE_DB_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
768 #echo "ADMIN_PASSWORD
=${ADMIN_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
769 echo "NBI_PASSWORD
=${NBI_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env
772 if [ ! -f $OSM_DOCKER_WORK_DIR/nbi.env ]; then
773 echo "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD
=${NBI_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/nbi.env
776 echo "OS_NOTIFIER_URI
=http
://${DEFAULT_IP}:8662" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/mon.env
777 echo "OSMMON_VCA_HOST
=${OSM_VCA_HOST}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
778 echo "OSMMON_VCA_SECRET
=${OSM_VCA_SECRET}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
780 echo "Finished generation of docker env files
"
783 function generate_osmclient_script () {
784 echo "docker run
-ti --network net
${OSM_STACK_NAME} ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm
785 $WORKDIR_SUDO chmod +x "$OSM_DOCKER_WORK_DIR/osm
"
786 echo "osmclient sidecar container can be found
at: $OSM_DOCKER_WORK_DIR/osm
"
789 function init_docker_swarm() {
790 if [ "${DEFAULT_MTU}" != "1500" ]; then
791 DOCKER_NETS=`sg docker -c "docker network list
" | awk '{print $2}' | egrep -v "^ID$
" | paste -d " " -s`
792 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";}'`
793 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
"
795 sg docker -c "docker swarm init
--advertise-addr ${DEFAULT_IP}"
799 function create_docker_network() {
800 echo "creating network
"
801 sg docker -c "docker network create
--driver=overlay
--attachable --opt com.docker.network.driver.mtu
=${DEFAULT_MTU} net
${OSM_STACK_NAME}"
802 echo "creating network DONE
"
805 function deploy_lightweight() {
807 echo "Deploying lightweight build
"
810 OSM_KEYSTONE_PORT=5000
814 OSM_PROM_HOSTPORT=9091
815 [ -n "$INSTALL_ELK" ] && OSM_ELK_PORT=5601
816 [ -n "$INSTALL_PERFMON" ] && OSM_PM_PORT=3000
818 if [ -n "$NO_HOST_PORTS" ]; then
819 OSM_PORTS+=(OSM_NBI_PORTS=$OSM_NBI_PORT)
820 OSM_PORTS+=(OSM_RO_PORTS=$OSM_RO_PORT)
821 OSM_PORTS+=(OSM_KEYSTONE_PORTS=$OSM_KEYSTONE_PORT)
822 OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT)
823 OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT)
824 OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_PORT)
825 [ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT)
826 [ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT)
828 OSM_PORTS+=(OSM_NBI_PORTS=$OSM_NBI_PORT:$OSM_NBI_PORT)
829 OSM_PORTS+=(OSM_RO_PORTS=$OSM_RO_PORT:$OSM_RO_PORT)
830 OSM_PORTS+=(OSM_KEYSTONE_PORTS=$OSM_KEYSTONE_PORT:$OSM_KEYSTONE_PORT)
831 OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT:$OSM_UI_PORT)
832 OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT:$OSM_MON_PORT)
833 OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_HOSTPORT:$OSM_PROM_PORT)
834 [ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT:$OSM_PM_PORT)
835 [ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT:$OSM_ELK_PORT)
837 echo "export ${OSM_PORTS[@]}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm_ports.sh
838 echo "export OSM_NETWORK
=net
${OSM_STACK_NAME}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
839 echo "export TAG
=${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
840 echo "export DOCKER_USER
=${DOCKER_USER}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
841 echo "export KAFKA_TAG
=${KAFKA_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
842 echo "export PROMETHEUS_TAG
=${PROMETHEUS_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
843 echo "export KEYSTONEDB_TAG
=${KEYSTONEDB_TAG}" | $WORKDIR_SUDO tee --append $OSM_DOCKER_WORK_DIR/osm_ports.sh
847 pushd $OSM_DOCKER_WORK_DIR
848 sg docker -c "source .
/osm_ports.sh
; docker stack deploy
-c $OSM_DOCKER_WORK_DIR/docker-compose.yaml
$OSM_STACK_NAME"
851 echo "Finished deployment of lightweight build
"
854 function deploy_elk() {
855 echo "Pulling docker images
for ELK
"
856 sg docker -c "docker pull docker.elastic.co
/elasticsearch
/elasticsearch-oss
:6.2.3" || FATAL "cannot get elasticsearch docker image
"
857 sg docker -c "docker pull docker.elastic.co
/logstash
/logstash-oss
:6.2.3" || FATAL "cannot get logstash docker image
"
858 sg docker -c "docker pull docker.elastic.co
/kibana
/kibana-oss
:6.2.3" || FATAL "cannot get kibana docker image
"
859 echo "Finished pulling elk docker images
"
860 $WORKDIR_SUDO mkdir -p "$OSM_DOCKER_WORK_DIR/osm_elk
"
861 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_elk/* $OSM_DOCKER_WORK_DIR/osm_elk
863 echo "Deploying ELK stack
"
864 sg docker -c "OSM_NETWORK
=net
${OSM_STACK_NAME} docker stack deploy
-c $OSM_DOCKER_WORK_DIR/osm_elk
/docker-compose.yml osm_elk
"
865 echo "Waiting
for ELK stack to be up and running
"
870 while [ $time -le $timelength ]; do
871 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
878 if [ $elk_is_up -eq 0 ]; then
879 echo "ELK is up and running. Trying to create index pattern...
"
880 #Create index pattern
881 curl -f -XPOST -H "Content-Type
: application
/json
" -H "kbn-xsrf
: anything
" \
882 "http
://127.0.0.1:5601/api
/saved_objects
/index-pattern
/logstash-
*" \
883 -d"{\"attributes
\":{\"title
\":\"logstash-
*\",\"timeFieldName
\":\"@timestamp
\"}}" 2>/dev/null
884 #Make it the default index
885 curl -f -XPOST -H "Content-Type
: application
/json
" -H "kbn-xsrf
: anything
" \
886 "http
://127.0.0.1:5601/api
/kibana
/settings
/defaultIndex
" \
887 -d"{\"value
\":\"logstash-
*\"}" 2>/dev/null
889 echo "Cannot connect to Kibana to create index pattern.
"
890 echo "Once Kibana is running
, you can use the following instructions to create index pattern
:"
891 echo 'curl -f -XPOST -H "Content-Type
: application
/json
" -H "kbn-xsrf
: anything
" \
892 "http
://127.0.0.1:5601/api
/saved_objects
/index-pattern
/logstash-
*" \
893 -d"{\"attributes
\":{\"title
\":\"logstash-
*\",\"timeFieldName
\":\"@timestamp
\"}}"'
894 echo 'curl -XPOST -H "Content-Type
: application
/json
" -H "kbn-xsrf
: anything
" \
895 "http
://127.0.0.1:5601/api
/kibana
/settings
/defaultIndex
" \
896 -d"{\"value
\":\"logstash-
*\"}"'
898 echo "Finished deployment of ELK stack
"
902 function deploy_perfmon() {
903 echo "Pulling docker images
for PM
(Grafana
)"
904 sg docker -c "docker pull grafana
/grafana
" || FATAL "cannot get grafana docker image
"
905 echo "Finished pulling PM docker images
"
906 $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/osm_metrics
907 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.yml $OSM_DOCKER_WORK_DIR/osm_metrics
908 $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.json $OSM_DOCKER_WORK_DIR/osm_metrics
909 remove_stack osm_metrics
910 echo "Deploying PM stack
(Grafana
)"
911 sg docker -c "OSM_NETWORK
=net
${OSM_STACK_NAME} docker stack deploy
-c $OSM_DOCKER_WORK_DIR/osm_metrics
/docker-compose.yml osm_metrics
"
912 echo "Finished deployment of PM stack
"
916 function install_lightweight() {
917 OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack
/$OSM_STACK_NAME"
918 [ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
920 [ "$USER" == "root
" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges.
"
921 [ -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
923 echo "Installing lightweight build of OSM
"
924 LWTEMPDIR="$
(mktemp
-d -q --tmpdir "installosmlight.XXXXXX")"
925 trap 'rm -rf "${LWTEMPDIR}"' EXIT
926 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
927 [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route
0.0.0.0"
928 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
929 [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route
"
930 DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
932 # if no host is passed in, we need to install lxd/juju, unless explicilty asked not to
933 if [ -z "$OSM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ]; then
934 need_packages_lw="lxd snapd
"
935 echo -e "Checking required packages
: $need_packages_lw"
936 dpkg -l $need_packages_lw &>/dev/null \
937 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges.
" \
938 || sudo apt-get update \
939 || FATAL "failed to run apt-get update
"
940 dpkg -l $need_packages_lw &>/dev/null \
941 || ! echo -e "Installing
$need_packages_lw requires root privileges.
" \
942 || sudo apt-get install -y $need_packages_lw \
943 || FATAL "failed to
install $need_packages_lw"
946 [ -z "$INSTALL_NOJUJU" ] && install_juju
948 if [ -z "$OSM_VCA_HOST" ]; then
949 juju_createcontroller
950 OSM_VCA_HOST=`sg lxd -c "juju show-controller
$OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
951 [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address
"
953 if [ -z "$OSM_VCA_SECRET" ]; then
954 OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
955 [ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret
"
959 [ -n "$INSTALL_NODOCKER" ] || install_docker_ce
961 #install_docker_compose
962 [ -z "$DOCKER_NOBUILD" ] && generate_docker_images
964 generate_docker_env_files
965 generate_config_log_folders
967 [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
969 remove_stack $OSM_STACK_NAME
970 create_docker_network
972 generate_osmclient_script
974 [ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
975 [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
976 [ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
977 [ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
979 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
984 function install_vimemu() {
985 echo "\nInstalling vim-emu
"
986 EMUTEMPDIR="$
(mktemp
-d -q --tmpdir "installosmvimemu.XXXXXX")"
987 trap 'rm -rf "${EMUTEMPDIR}"' EXIT
988 # clone vim-emu repository (attention: branch is currently master only)
989 echo "Cloning vim-emu repository ...
"
990 git clone https://osm.etsi.org/gerrit/osm/vim-emu.git $EMUTEMPDIR
991 # build vim-emu docker
992 echo "Building vim-emu Docker container...
"
994 sg docker -c "docker build
-t vim-emu-img
-f $EMUTEMPDIR/Dockerfile
--no-cache $EMUTEMPDIR/" || FATAL "cannot build vim-emu-img docker image
"
995 # start vim-emu container as daemon
996 echo "Starting vim-emu Docker container
'vim-emu' ...
"
997 if [ -n "$INSTALL_LIGHTWEIGHT" ]; then
998 # in lightweight mode, the emulator needs to be attached to netOSM
999 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
"
1001 # classic build mode
1002 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
"
1004 echo "Waiting
for 'vim-emu' container to start ...
"
1006 export VIMEMU_HOSTNAME=$(sg docker -c "docker inspect
-f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu
")
1007 echo "vim-emu running
at ${VIMEMU_HOSTNAME} ...
"
1008 # print vim-emu connection info
1009 echo -e "\nYou might be interested
in adding the following vim-emu env variables to your .bashrc
file:"
1010 echo " export VIMEMU_HOSTNAME
=${VIMEMU_HOSTNAME}"
1011 echo -e "To add the emulated VIM to OSM you should
do:"
1012 echo " osm vim-create
--name emu-vim1
--user username
--password password
--auth_url http
://${VIMEMU_HOSTNAME}:6001/v2.0
--tenant tenantName
--account_type openstack
"
1015 function dump_vars(){
1016 echo "DEVELOP
=$DEVELOP"
1017 echo "INSTALL_FROM_SOURCE
=$INSTALL_FROM_SOURCE"
1018 echo "UNINSTALL
=$UNINSTALL"
1020 echo "UPDATE
=$UPDATE"
1021 echo "RECONFIGURE
=$RECONFIGURE"
1022 echo "TEST_INSTALLER
=$TEST_INSTALLER"
1023 echo "INSTALL_VIMEMU
=$INSTALL_VIMEMU"
1024 echo "INSTALL_LXD
=$INSTALL_LXD"
1025 echo "INSTALL_FROM_LXDIMAGES
=$INSTALL_FROM_LXDIMAGES"
1026 echo "LXD_REPOSITORY_BASE
=$LXD_REPOSITORY_BASE"
1027 echo "LXD_REPOSITORY_PATH
=$LXD_REPOSITORY_PATH"
1028 echo "INSTALL_LIGHTWEIGHT
=$INSTALL_LIGHTWEIGHT"
1029 echo "INSTALL_ONLY
=$INSTALL_ONLY"
1030 echo "INSTALL_ELK
=$INSTALL_ELK"
1031 echo "INSTALL_PERFMON
=$INSTALL_PERFMON"
1032 echo "TO_REBUILD
=$TO_REBUILD"
1033 echo "INSTALL_NOLXD
=$INSTALL_NOLXD"
1034 echo "INSTALL_NODOCKER
=$INSTALL_NODOCKER"
1035 echo "RELEASE
=$RELEASE"
1036 echo "REPOSITORY
=$REPOSITORY"
1037 echo "REPOSITORY_BASE
=$REPOSITORY_BASE"
1038 echo "REPOSITORY_KEY
=$REPOSITORY_KEY"
1039 echo "NOCONFIGURE
=$NOCONFIGURE"
1040 echo "SHOWOPTS
=$SHOWOPTS"
1041 echo "Install from specific refspec
(-b): $COMMIT_ID"
1046 duration=$((ctime - SESSION_ID))
1047 url="http
://www.woopra.com
/track
/ce?project
=osm.etsi.org
&cookie
=${SESSION_ID}"
1048 #url="${url}&ce_campaign_name
=${CAMPAIGN_NAME}"
1050 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_SOURCE" ] && event_name="binsrc
"
1051 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd
"
1052 [ -n "$INSTALL_LIGHTWEIGHT" ] && event_name="lw
"
1053 event_name="${event_name}_
$1"
1054 url="${url}&event=${event_name}&ce_duration=${duration}"
1055 wget -q -O /dev/null $url
1068 INSTALL_FROM_SOURCE=""
1069 RELEASE="ReleaseFOUR
"
1072 INSTALL_FROM_LXDIMAGES=""
1073 LXD_REPOSITORY_BASE="https
://osm-download.etsi.org
/repository
/osm
/lxd
"
1074 LXD_REPOSITORY_PATH=""
1075 INSTALL_LIGHTWEIGHT="y
"
1085 SESSION_ID=`date +%s`
1092 REPOSITORY_KEY="OSM
%20ETSI
%20Release
%20Key.gpg
"
1093 REPOSITORY_BASE="http
://osm-download.etsi.org
/repository
/osm
/debian
"
1095 OSM_WORK_DIR="/etc
/osm
"
1096 OSM_DOCKER_TAG=latest
1098 KAFKA_TAG=2.11-1.0.2
1099 PROMETHEUS_TAG=v2.4.3
1102 while getopts ":hy-
:b
:r
:k
:u
:R
:l
:p
:D
:o
:m
:H
:S
:s
:w
:t
:" o; do
1111 REPOSITORY="${OPTARG}"
1112 REPO_ARGS+=(-r "$REPOSITORY")
1116 REPO_ARGS+=(-R "$RELEASE")
1119 REPOSITORY_KEY="${OPTARG}"
1120 REPO_ARGS+=(-k "$REPOSITORY_KEY")
1123 REPOSITORY_BASE="${OPTARG}"
1124 REPO_ARGS+=(-u "$REPOSITORY_BASE")
1127 LXD_REPOSITORY_BASE="${OPTARG}"
1130 LXD_REPOSITORY_PATH="${OPTARG}"
1133 OSM_DEVOPS="${OPTARG}"
1136 OSM_STACK_NAME="${OPTARG}"
1139 OSM_VCA_HOST="${OPTARG}"
1142 OSM_VCA_SECRET="${OPTARG}"
1145 # when specifying workdir, do not use sudo for access
1147 OSM_WORK_DIR="${OPTARG}"
1150 OSM_DOCKER_TAG="${OPTARG}"
1154 [ "${OPTARG}" == "vimemu
" ] && INSTALL_VIMEMU="y
" && continue
1155 [ "${OPTARG}" == "elk_stack
" ] && INSTALL_ELK="y
" && continue
1156 [ "${OPTARG}" == "pm_stack
" ] && INSTALL_PERFMON="y
" && continue
1159 [ "${OPTARG}" == "RO
" ] && TO_REBUILD="$TO_REBUILD RO
" && continue
1160 [ "${OPTARG}" == "LCM
" ] && TO_REBUILD="$TO_REBUILD LCM
" && continue
1161 [ "${OPTARG}" == "NBI
" ] && TO_REBUILD="$TO_REBUILD NBI
" && continue
1162 [ "${OPTARG}" == "LW-UI
" ] && TO_REBUILD="$TO_REBUILD LW-UI
" && continue
1163 [ "${OPTARG}" == "MON
" ] && TO_REBUILD="$TO_REBUILD MON
" && continue
1164 [ "${OPTARG}" == "KAFKA
" ] && TO_REBUILD="$TO_REBUILD KAFKA
" && continue
1165 [ "${OPTARG}" == "MONGO
" ] && TO_REBUILD="$TO_REBUILD MONGO
" && continue
1166 [ "${OPTARG}" == "NONE
" ] && TO_REBUILD="$TO_REBUILD NONE
" && continue
1169 [ "${OPTARG}" == "help" ] && usage && exit 0
1170 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y
" && continue
1171 [ "${OPTARG}" == "develop
" ] && DEVELOP="y
" && continue
1172 [ "${OPTARG}" == "uninstall
" ] && UNINSTALL="y
" && continue
1173 [ "${OPTARG}" == "nat
" ] && NAT="y
" && continue
1174 [ "${OPTARG}" == "update
" ] && UPDATE="y
" && continue
1175 [ "${OPTARG}" == "reconfigure
" ] && RECONFIGURE="y
" && continue
1176 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y
" && continue
1177 [ "${OPTARG}" == "lxdinstall
" ] && INSTALL_LXD="y
" && continue
1178 [ "${OPTARG}" == "nolxd
" ] && INSTALL_NOLXD="y
" && continue
1179 [ "${OPTARG}" == "nodocker
" ] && INSTALL_NODOCKER="y
" && continue
1180 [ "${OPTARG}" == "lxdimages
" ] && INSTALL_FROM_LXDIMAGES="y
" && continue
1181 [ "${OPTARG}" == "lightweight
" ] && INSTALL_LIGHTWEIGHT="y
" && continue
1182 [ "${OPTARG}" == "soui
" ] && INSTALL_LIGHTWEIGHT="" && RELEASE="-R ReleaseTHREE
" && REPOSITORY="-r stable
" && continue
1183 [ "${OPTARG}" == "vimemu
" ] && INSTALL_VIMEMU="y
" && continue
1184 [ "${OPTARG}" == "elk_stack
" ] && INSTALL_ELK="y
" && continue
1185 [ "${OPTARG}" == "pm_stack
" ] && INSTALL_PERFMON="y
" && continue
1186 [ "${OPTARG}" == "noconfigure
" ] && NOCONFIGURE="y
" && continue
1187 [ "${OPTARG}" == "showopts
" ] && SHOWOPTS="y
" && continue
1188 [ "${OPTARG}" == "daily
" ] && RELEASE_DAILY="y
" && continue
1189 [ "${OPTARG}" == "nohostports
" ] && NO_HOST_PORTS="y
" && continue
1190 [ "${OPTARG}" == "nojuju
" ] && INSTALL_NOJUJU="y
" && continue
1191 [ "${OPTARG}" == "nodockerbuild
" ] && DOCKER_NOBUILD="y
" && continue
1192 [ "${OPTARG}" == "nohostclient
" ] && INSTALL_NOHOSTCLIENT="y
" && continue
1193 [ "${OPTARG}" == "pullimages
" ] && DOCKER_USER="opensourcemano
" && PULL_IMAGES=true && continue
1194 echo -e "Invalid option
: '--$OPTARG'\n" >&2
1198 echo -e "Invalid option
: '-$OPTARG'\n" >&2
1210 [ -n "$INSTALL_FROM_LXDIMAGES" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options
: --lxd can only be used with
--soui"
1211 [ -n "$NAT" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options
: --nat can only be used with
--soui"
1212 [ -n "$NOCONFIGURE" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options
: --noconfigure can only be used with
--soui"
1213 [ -n "$RELEASE_DAILY" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options
: --daily can only be used with
--soui"
1214 [ -n "$INSTALL_NOLXD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option
: --nolxd cannot be used with
--soui"
1215 [ -n "$INSTALL_NODOCKER" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option
: --nodocker cannot be used with
--soui"
1216 [ -n "$TO_REBUILD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option
: -m cannot be used with
--soui"
1217 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE
" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option
: -m NONE cannot be used with other
-m options
"
1219 if [ -n "$SHOWOPTS" ]; then
1224 [ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo
" && RELEASE="-R ReleaseTHREE-daily
" && REPOSITORY="-r testing
" && COMMIT_ID="master
"
1226 # if develop, we force master
1227 [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master
"
1229 need_packages="git jq wget curl
tar"
1230 echo -e "Checking required packages
: $need_packages"
1231 dpkg -l $need_packages &>/dev/null \
1232 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges.
" \
1233 || sudo apt-get update \
1234 || FATAL "failed to run apt-get update
"
1235 dpkg -l $need_packages &>/dev/null \
1236 || ! echo -e "Installing
$need_packages requires root privileges.
" \
1237 || sudo apt-get install -y $need_packages \
1238 || FATAL "failed to
install $need_packages"
1240 if [ -z "$OSM_DEVOPS" ]; then
1241 if [ -n "$TEST_INSTALLER" ]; then
1242 echo -e "\nUsing
local devops repo
for OSM installation
"
1243 OSM_DEVOPS="$
(dirname $
(realpath $
(dirname $0)))"
1245 echo -e "\nCreating temporary dir
for OSM installation
"
1246 OSM_DEVOPS="$
(mktemp
-d -q --tmpdir "installosm.XXXXXX")"
1247 trap 'rm -rf "$OSM_DEVOPS"' EXIT
1249 git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
1251 if [ -z "$COMMIT_ID" ]; then
1252 echo -e "\nGuessing the current stable release
"
1253 LATEST_STABLE_DEVOPS=`git -C $OSM_DEVOPS tag -l v[0-9].* | sort -V | tail -n1`
1254 [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not
find the current latest stable release
" && exit 0
1256 echo "Latest tag
in devops repo
: $LATEST_STABLE_DEVOPS"
1257 COMMIT_ID="tags
/$LATEST_STABLE_DEVOPS"
1259 echo -e "\nDEVOPS Using commit
$COMMIT_ID"
1261 git -C $OSM_DEVOPS checkout $COMMIT_ID
1265 OSM_JENKINS="$OSM_DEVOPS/jenkins
"
1266 . $OSM_JENKINS/common/all_funcs
1268 [ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE
" && exit 0
1269 [ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE
" && exit 0
1270 [ -n "$NAT" ] && nat && echo -e "\nDONE
" && exit 0
1271 [ -n "$UPDATE" ] && update && echo -e "\nDONE
" && exit 0
1272 [ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE
" && exit 0
1273 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
1274 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon
1275 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_VIMEMU" ] && install_vimemu
1276 [ -n "$INSTALL_ONLY" ] && echo -e "\nDONE
" && exit 0
1278 #Installation starts here
1279 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
1282 [ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE
" && exit 0
1283 echo -e "\nInstalling OSM from refspec
: $COMMIT_ID"
1284 if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
1285 ! ask_user "The installation will take about
75-90 minutes. Continue
(Y
/n
)?
" y && echo "Cancelled
!" && exit 1
1288 echo -e "Checking required packages
: lxd
"
1289 lxd --version &>/dev/null || FATAL "lxd not present
, exiting.
"
1290 [ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd
" && install_lxd
1292 # use local devops for containers
1293 export OSM_USE_LOCAL_DEVOPS=true
1294 if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
1295 echo -e "\nCreating the containers and building from
source ...
"
1296 $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed
(refspec
: '$COMMIT_ID')"
1297 ro_is_up && track RO
1298 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed
"
1299 vca_is_up && track VCA
1300 $OSM_DEVOPS/jenkins/host/start_build MON || FATAL "MON
install failed
"
1301 mon_is_up && track MON
1302 $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed
(refspec
: '$COMMIT_ID')"
1303 $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed
(refspec
: '$COMMIT_ID')"
1304 #so_is_up && track SOUI
1306 elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
1307 echo -e "\nInstalling from lxd images ...
"
1308 install_from_lxdimages
1309 else #install from binaries
1310 echo -e "\nCreating the containers and installing from binaries ...
"
1311 $OSM_DEVOPS/jenkins/host/install RO ${REPO_ARGS[@]} || FATAL "RO
install failed
"
1312 ro_is_up && track RO
1313 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA
install failed
"
1314 vca_is_up && track VCA
1315 $OSM_DEVOPS/jenkins/host/install MON || FATAL "MON build failed
"
1316 mon_is_up && track MON
1317 $OSM_DEVOPS/jenkins/host/install SO ${REPO_ARGS[@]} || FATAL "SO
install failed
"
1318 $OSM_DEVOPS/jenkins/host/install UI ${REPO_ARGS[@]} || FATAL "UI
install failed
"
1319 #so_is_up && track SOUI
1323 #Install iptables-persistent and configure NAT rules
1324 [ -z "$NOCONFIGURE" ] && nat
1326 #Configure components
1327 [ -z "$NOCONFIGURE" ] && configure
1330 [ -z "$NOCONFIGURE" ] && install_osmclient
1332 #Install vim-emu (optional)
1333 [ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
1335 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null