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 " --develop: install OSM from source code using the master branch"
22 echo -e " --nat: install only NAT rules"
23 echo -e " -h / --help: print this help"
26 #Uninstall OSM: remove containers
28 if [ $RC_CLONE ] ||
[ -n "$TEST_INSTALLER" ]; then
29 $OSM_DEVOPS/jenkins
/host
/clean_container RO
30 $OSM_DEVOPS/jenkins
/host
/clean_container VCA
31 $OSM_DEVOPS/jenkins
/host
/clean_container SO
32 #$OSM_DEVOPS/jenkins/host/clean_container UI
34 lxc stop RO
&& lxc delete RO
35 lxc stop VCA
&& lxc delete VCA
36 lxc stop SO-ub
&& lxc delete SO-ub
40 #Configure NAT rules, based on the current IP addresses of containers
42 echo -e "\nChecking required packages: iptables-persistent"
43 dpkg
-l iptables-persistent
&>/dev
/null ||
! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
44 sudo DEBIAN_FRONTEND
=noninteractive apt-get
-yq install iptables-persistent
45 echo -e "\nConfiguring NAT rules"
46 echo -e " Required root privileges"
47 sudo
$OSM_DEVOPS/installers
/nat_osm
50 #Configure VCA, SO and RO with the initial configuration:
51 # RO -> tenant:osm, logs to be sent to SO
52 # VCA -> juju-password
53 # SO -> route to Juju Controller, add RO account, add VCA account
56 echo -e "\nConfiguring components"
57 .
$OSM_DEVOPS/installers
/export_ips
59 echo -e " Configuring RO"
60 lxc
exec RO
-- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /opt
/openmano
/openmanod.cfg
61 lxc
exec RO
-- service openmano restart
62 time=0; step
=2; timelength
=20; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$
((time+step
)); done; echo
63 lxc
exec RO
-- openmano tenant-delete
-f osm
>/dev
/null
64 RO_TENANT_ID
=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'`
66 echo -e " Configuring VCA"
67 JUJU_PASSWD
=`date +%s | sha256sum | base64 | head -c 32`
68 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc
exec VCA
-- juju change-user-password
69 JUJU_CONTROLLER_IP
=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
71 echo -e " Configuring SO"
72 sudo route add
-host $JUJU_CONTROLLER_IP gw
$VCA_CONTAINER_IP
73 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
74 time=0; step
=30; timelength
=300; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$
((time+step
)); done; echo
76 curl
-k --request POST \
77 --url https
://$SO_CONTAINER_IP:8008/api
/config
/config-agent \
78 --header 'accept: application/vnd.yang.data+json' \
79 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
80 --header 'cache-control: no-cache' \
81 --header 'content-type: application/vnd.yang.data+json' \
82 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}'
84 curl
-k --request PUT \
85 --url https
://$SO_CONTAINER_IP:8008/api
/config
/resource-orchestrator \
86 --header 'accept: application/vnd.yang.data+json' \
87 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
88 --header 'cache-control: no-cache' \
89 --header 'content-type: application/vnd.yang.data+json' \
90 --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }'
99 while getopts ":h-:" o
; do
105 [ "${OPTARG}" == "help" ] && usage
&& exit 0
106 [ "${OPTARG}" == "develop" ] && DEVELOP
="y" && continue
107 [ "${OPTARG}" == "uninstall" ] && UNINSTALL
="y" && continue
108 [ "${OPTARG}" == "nat" ] && NAT
="y" && continue
109 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE
="y" && continue
110 [ "${OPTARG}" == "test" ] && TEST_INSTALLER
="y" && continue
111 echo -e "Invalid option: '--$OPTARG'\n" >&2
115 echo -e "Invalid option: '-$OPTARG'\n" >&2
124 if [ -n "$TEST_INSTALLER" ]; then
125 echo -e "\nUsing local devops repo for OSM installation"
126 TEMPDIR
="$(dirname $(realpath $(dirname $0)))"
128 echo -e "\nCreating temporary dir for OSM installation"
129 TEMPDIR
="$(mktemp -d -q --tmpdir "installosm.XXXXXX
")"
130 trap 'rm -rf "$TEMPDIR"' EXIT
133 echo -e "Checking required packages: git"
134 dpkg
-l git
&>/dev
/null ||
! echo -e " git not installed.\nInstalling git requires root privileges" || sudo apt
install -y git
135 if [ -z "$TEST_INSTALLER" ]; then
136 echo -e "\nCloning devops repo temporarily"
137 git clone https
://osm.etsi.org
/gerrit
/osm
/devops.git
$TEMPDIR
139 DEVOPS_COMMITID
="tags/v1.0.1"
140 git
-C $TEMPDIR checkout
$DEVOPS_COMMITID
143 OSM_JENKINS
="$TEMPDIR/jenkins"
144 .
$OSM_JENKINS/common
/all_funcs
146 [ -n "$UNINSTALL" ] && uninstall
&& echo -e "\nDONE" && exit 0
147 [ -n "$NAT" ] && nat
&& echo -e "\nDONE" && exit 0
148 [ -n "$RECONFIGURE" ] && configure
&& echo -e "\nDONE" && exit 0
150 #Installation starts here
151 wget
-q -O- https
://osm-download.etsi.org
/ftp
/osm-1.0
-one/README.txt
&> /dev
/null
153 echo -e "\nChecking required packages: wget, curl, tar"
154 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
156 echo -e "\nCreating the containers and building ..."
157 COMMIT_ID
="tags/v1.0.1"
158 [ -n "$DEVELOP" ] && COMMIT_ID
="master"
159 $OSM_DEVOPS/jenkins
/host
/start_build RO checkout
$COMMIT_ID
160 $OSM_DEVOPS/jenkins
/host
/start_build VCA
161 $OSM_DEVOPS/jenkins
/host
/start_build SO checkout
$COMMIT_ID
162 $OSM_DEVOPS/jenkins
/host
/start_build UI checkout
$COMMIT_ID
164 #Install iptables-persistent and configure NAT rules
167 #Configure components