blob: ef910900741e9a8e18432d2849153fad203d4510 [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]"
18 echo -e "Install OSM from source code"
19 echo -e " OPTIONS"
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"
24}
25
26UNINSTALL=""
27DEVELOP=""
28NAT=""
29while getopts ":h-:" o; do
30 case "${o}" in
31 h)
32 usage && exit 0
33 ;;
34 -)
35 [ "${OPTARG}" == "help" ] && usage && exit 0
36 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
37 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
38 [ "${OPTARG}" == "nat" ] && NAT="y" && continue
39 echo -e "Invalid option: '--$OPTARG'\n" >&2
40 usage && exit 1
41 ;;
42 \?)
43 echo -e "Invalid option: '-$OPTARG'\n" >&2
44 usage && exit 1
45 ;;
46 *)
47 usage && exit 1
48 ;;
49 esac
50done
51
52echo -e "\nCreating temporary dir for OSM installation"
53TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
54trap 'rm -rf "$TEMPDIR"' EXIT
55
56echo -e "\nCloning devops repo temporarily"
57git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
58RC_CLONE=$?
59
60OSM_DEVOPS=$TEMPDIR
61
62if [ -n "$UNINSTALL" ]; then
63 if $RC_CLONE; then
64 $OSM_DEVOPS/jenkins/host/clean_container RO
65 $OSM_DEVOPS/jenkins/host/clean_container VCA
66 $OSM_DEVOPS/jenkins/host/clean_container SO
67 #$OSM_DEVOPS/jenkins/host/clean_container UI
68 else
69 lxc stop RO && lxc delete RO
70 lxc stop VCA && lxc delete VCA
71 lxc stop SO-ub && lxc delete SO-ub
72 fi
73 exit 0
74fi
75
76if [ -n "$NAT" ]; then
77 $OSM_DEVOPS/installers/nat-osm || FATAL "Failed to run nat-osm"
78fi
79
80#Installation starts here
81echo -e "\nInstalling required packages: git, wget, curl, tar"
82echo -e "\n Required root privileges"
83sudo apt install -y git wget curl tar
84
85echo -e "\nCreating the containers and building ..."
86. $OSM_DEVOPS/jenkins/common/all_funcs
87$OSM_DEVOPS/jenkins/host/start_build RO
88$OSM_DEVOPS/jenkins/host/start_build VCA
89$OSM_DEVOPS/jenkins/host/start_build SO
90$OSM_DEVOPS/jenkins/host/start_build UI
91
92#Configure NAT rules
93echo -e "\nConfiguring NAT rules"
94echo -e "\n Required root privileges"
95sudo $OSM_DEVOPS/installers/nat-osm
96
97#Configure components
98# TO BE DONE
99echo -e "\nConfiguring components"
100. $OSM_DEVOPS/installers/export_ips
101
102echo -e "\n Configuring RO"
103#RO_TENANT_ID=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'`
104
105echo -e "\n Configuring VCA"
106#JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
107#lxc exec VCA -- juju change-user-password $JUJUPASSWD
108#JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
109
110echo -e "\n Configuring SO"
111#sudo route add -net $JUJU_CONTROLLER_IP/32 gw $VCA_CONTAINER_IP
112#lxc exec SO-ub -- sudo -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --test-name "launchpad"
113#sleep 2
114#lxc exec SO-ub -- resource-orchestrator name openmano account-type openmano openmano host $RO_CONTAINER_IP tenant-id $RO_TENANT_ID port 9090
115#lxc exec SO-ub -- config-agent account juju account-type juju juju ip-address $JUJU_CONTROLLER_IP port 17070 user admin secret $JUJU_PASSWD
116
117echo "\nDONE"
118
119