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 source code"
20 echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
21 echo -e " -b <branch>: install OSM from source code using a specific branch (master, v1.0, ...)"
22 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
23 echo -e " --nat: install only NAT rules"
24 echo -e " -h / --help: print this help"
27 #Uninstall OSM: remove containers
29 if [ $RC_CLONE ] ||
[ -n "$TEST_INSTALLER" ]; then
30 $OSM_DEVOPS/jenkins
/host
/clean_container RO
31 $OSM_DEVOPS/jenkins
/host
/clean_container VCA
32 $OSM_DEVOPS/jenkins
/host
/clean_container SO
33 #$OSM_DEVOPS/jenkins/host/clean_container UI
35 lxc stop RO
&& lxc delete RO
36 lxc stop VCA
&& lxc delete VCA
37 lxc stop SO-ub
&& lxc delete SO-ub
41 #Configure NAT rules, based on the current IP addresses of containers
43 echo -e "\nChecking required packages: iptables-persistent"
44 dpkg
-l iptables-persistent
&>/dev
/null ||
! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
45 sudo DEBIAN_FRONTEND
=noninteractive apt-get
-yq install iptables-persistent
46 echo -e "\nConfiguring NAT rules"
47 echo -e " Required root privileges"
48 sudo
$OSM_DEVOPS/installers
/nat_osm
51 #Configure VCA, SO and RO with the initial configuration:
52 # RO -> tenant:osm, logs to be sent to SO
53 # VCA -> juju-password
54 # SO -> route to Juju Controller, add RO account, add VCA account
57 echo -e "\nConfiguring components"
58 .
$OSM_DEVOPS/installers
/export_ips
60 echo -e " Configuring RO"
61 lxc
exec RO
-- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /opt
/openmano
/openmanod.cfg
62 lxc
exec RO
-- service openmano restart
63 time=0; step
=2; timelength
=20; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$
((time+step
)); done; echo
64 lxc
exec RO
-- openmano tenant-delete
-f osm
>/dev
/null
65 RO_TENANT_ID
=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'`
67 echo -e " Configuring VCA"
68 JUJU_PASSWD
=`date +%s | sha256sum | base64 | head -c 32`
69 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc
exec VCA
-- juju change-user-password
70 JUJU_CONTROLLER_IP
=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
72 echo -e " Configuring SO"
73 sudo route add
-host $JUJU_CONTROLLER_IP gw
$VCA_CONTAINER_IP
74 lxc
exec SO-ub
-- nohup sudo
-b -H /usr
/rift
/rift-shell
-r -i /usr
/rift
-a /usr
/rift
/.artifacts
-- .
/demos
/launchpad.py
--use-xml-mode &
75 time=0; step
=30; timelength
=300; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$
((time+step
)); done; echo
77 curl
-k --request POST \
78 --url https
://$SO_CONTAINER_IP:8008/api
/config
/config-agent \
79 --header 'accept: application/vnd.yang.data+json' \
80 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
81 --header 'cache-control: no-cache' \
82 --header 'content-type: application/vnd.yang.data+json' \
83 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}'
85 curl
-k --request PUT \
86 --url https
://$SO_CONTAINER_IP:8008/api
/config
/resource-orchestrator \
87 --header 'accept: application/vnd.yang.data+json' \
88 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
89 --header 'cache-control: no-cache' \
90 --header 'content-type: application/vnd.yang.data+json' \
91 --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }'
95 function install_lxd
() {
98 systemctl stop lxd-bridge
99 systemctl
--system daemon-reload
100 systemctl
enable lxd-bridge
101 systemctl start lxd-bridge
113 while getopts ":h-:b:" o
; do
122 [ "${OPTARG}" == "help" ] && usage
&& exit 0
123 [ "${OPTARG}" == "develop" ] && DEVELOP
="y" && continue
124 [ "${OPTARG}" == "uninstall" ] && UNINSTALL
="y" && continue
125 [ "${OPTARG}" == "nat" ] && NAT
="y" && continue
126 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE
="y" && continue
127 [ "${OPTARG}" == "test" ] && TEST_INSTALLER
="y" && continue
128 [ "${OPTARG}" == "lxd" ] && LXD
="y" && continue
129 [ "${OPTARG}" == "showopts" ] && SHOWOPTS
="y" && continue
130 echo -e "Invalid option: '--$OPTARG'\n" >&2
134 echo -e "Invalid option: '-$OPTARG'\n" >&2
143 [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID
="master"
144 [ -z "$COMMIT_ID" ] && COMMIT_ID
="tags/v1.0.2"
146 if [ -n "$SHOWOPTS" ]; then
147 echo "UNINSTALL=$UNINSTALL"
148 echo "DEVELOP=$DEVELOP"
150 echo "RECONFIGURE=$RECONFIGURE"
151 echo "TEST_INSTALLER=$TEST_INSTALLER"
153 echo "Commit: $COMMIT_ID"
157 if [ -n "$TEST_INSTALLER" ]; then
158 echo -e "\nUsing local devops repo for OSM installation"
159 TEMPDIR
="$(dirname $(realpath $(dirname $0)))"
161 echo -e "\nCreating temporary dir for OSM installation"
162 TEMPDIR
="$(mktemp -d -q --tmpdir "installosm.XXXXXX
")"
163 trap 'rm -rf "$TEMPDIR"' EXIT
166 echo -e "Checking required packages: git"
167 dpkg
-l git
&>/dev
/null ||
! echo -e " git not installed.\nInstalling git requires root privileges" || sudo apt
install -y git
168 if [ -z "$TEST_INSTALLER" ]; then
169 echo -e "\nCloning devops repo temporarily"
170 git clone https
://osm.etsi.org
/gerrit
/osm
/devops.git
$TEMPDIR
172 DEVOPS_COMMITID
="tags/v1.0.2"
173 git
-C $TEMPDIR checkout
$DEVOPS_COMMITID
176 OSM_JENKINS
="$TEMPDIR/jenkins"
177 .
$OSM_JENKINS/common
/all_funcs
179 [ -n "$UNINSTALL" ] && uninstall
&& echo -e "\nDONE" && exit 0
180 [ -n "$NAT" ] && nat
&& echo -e "\nDONE" && exit 0
181 [ -n "$RECONFIGURE" ] && configure
&& echo -e "\nDONE" && exit 0
183 #Installation starts here
184 wget
-q -O- https
://osm-download.etsi.org
/ftp
/osm-1.0
-one/README.txt
&> /dev
/null
186 [ -n "$LXD" ] && echo -e "\nConfiguring lxd" && install_lxd
188 echo -e "\nChecking required packages: wget, curl, tar"
189 dpkg
-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
install -y wget curl
tar
191 echo -e "\nCreating the containers and building ..."
192 $OSM_DEVOPS/jenkins
/host
/start_build RO checkout
$COMMIT_ID
193 $OSM_DEVOPS/jenkins
/host
/start_build VCA
194 $OSM_DEVOPS/jenkins
/host
/start_build SO checkout
$COMMIT_ID
195 $OSM_DEVOPS/jenkins
/host
/start_build UI checkout
$COMMIT_ID
197 #Install iptables-persistent and configure NAT rules
200 #Configure components