blob: f0bbbfaf479b03b19008f9882c66293e2fbdb195 [file] [log] [blame]
A R Karthick1fa66542017-08-10 14:15:29 -07001#!/usr/bin/env bash
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07002
3# Copyright 2017-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
A R Karthick63815d12017-02-08 11:14:40 -080017function usage {
18 echo "usage: ${0#*/} [-h |--help] [--cord] [--venv]"
19 exit 1
20}
21
A R Karthickd49ca4b2016-07-27 11:52:50 -070022on_cord=0
A R Karthick63815d12017-02-08 11:14:40 -080023venv=0
24optspec=":h-:"
25while getopts "$optspec" optchar; do
26 case "${optchar}" in
27 -)
28 case "${OPTARG}" in
29 cord)
30 on_cord=1
A R Karthick63815d12017-02-08 11:14:40 -080031 ;;
32 venv)
33 venv=1
A R Karthick63815d12017-02-08 11:14:40 -080034 ;;
35 help)
36 usage
37 ;;
38 *)
39 echo "Unknown option --${OPTARG}"
40 usage
41 ;;
42 esac
43 ;;
44 h)
45 usage
46 ;;
47 *)
48 usage
49 ;;
50 esac
51done
52
53shift $((OPTIND-1))
54if [ $# -gt 0 ]; then
55 usage
Chetan Gaonkercc19ac42016-05-04 17:21:50 -070056fi
A R Karthick63815d12017-02-08 11:14:40 -080057
58apt-get update
59release=$(lsb_release -cs)
A R Karthick66cf6f62017-02-28 14:04:34 -080060#install docker only if not installed already. On cord, its mostly installed.
61if $(which docker 2>&1 >/dev/null); then
62 on_cord=1
63else
64 on_cord=0
65fi
A R Karthickd49ca4b2016-07-27 11:52:50 -070066if [ $on_cord -eq 0 ]; then
67 apt-get -y install apt-transport-https ca-certificates
68 apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
69 if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
A R Karthickbd82f362016-11-10 15:08:52 -080070 echo deb https://apt.dockerproject.org/repo ubuntu-$release main | tee /etc/apt/sources.list.d/docker.list
A R Karthickd49ca4b2016-07-27 11:52:50 -070071 fi
72 apt-get update
73 apt-get purge lxc-docker || true
74 apt-get -y install linux-image-extra-$(uname -r)
75 apt-get -y install apparmor
76 echo "Installing Docker"
77 apt-get -y install docker-engine
A R Karthickc4108fe2016-11-17 15:15:28 -080078 service docker restart
A R Karthick973010f2017-02-06 16:41:51 -080079 sleep 5
A R Karthickd49ca4b2016-07-27 11:52:50 -070080 echo "Verifying Docker installation"
81 docker run --rm hello-world || exit 127
82 docker rmi hello-world
A R Karthickb05acab2016-11-10 15:12:43 -080083 echo "Pulling ONOS latest"
A R Karthickd49ca4b2016-07-27 11:52:50 -070084 docker pull onosproject/onos:latest || exit 127
A R Karthick63815d12017-02-08 11:14:40 -080085else
86 echo "Skipping installation of Docker and ONOS"
A R Karthickd49ca4b2016-07-27 11:52:50 -070087fi
A R Karthick05e85fa2016-12-02 09:20:54 -080088
A R Karthick63815d12017-02-08 11:14:40 -080089apt-get -y install openvswitch-common openvswitch-switch
90apt-get -y install wget git python python-dev python-pip python-setuptools python-scapy python-pexpect python-maas-client tcpdump arping libssl-dev libffi-dev realpath python-virtualenv
91
92setup_path=$(dirname $(realpath $0))
93if [ $venv -eq 1 ]; then
94 echo "Making a virtual cord-tester pip installation environment"
95 mkdir -p $setup_path/venv
A R Karthickd7f6ade2017-02-08 12:23:58 -080096 virtualenv $setup_path/venv
A R Karthick63815d12017-02-08 11:14:40 -080097 echo "Installing cord-tester pip packages on the virtual environment"
A R Karthick9020cd02017-08-10 13:59:27 -070098 $setup_path/venv/bin/pip install -U distribute
A R Karthickce659072017-08-10 14:20:39 -070099 $setup_path/venv/bin/pip install -U -r $setup_path/requirements.txt
A R Karthick63815d12017-02-08 11:14:40 -0800100else
101 echo "Installing cord-tester pip packages on the host"
A R Karthick9020cd02017-08-10 13:59:27 -0700102 pip install -U distribute
A R Karthickce659072017-08-10 14:20:39 -0700103 pip install -U -r $setup_path/requirements.txt
Chetan Gaonker66bff932016-05-09 10:06:37 -0700104fi
A R Karthick05e85fa2016-12-02 09:20:54 -0800105
A R Karthick63815d12017-02-08 11:14:40 -0800106( cd /tmp && git clone https://github.com/jpetazzo/pipework.git && cp -v pipework/pipework /usr/bin && rm -rf pipework )
107
A R Karthick05e85fa2016-12-02 09:20:54 -0800108install_ovs() {
109 mkdir -p /root/ovs
110 wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz -O /root/ovs/openvswitch-2.5.0.tar.gz && \
111 ( cd /root/ovs && tar zxpvf openvswitch-2.5.0.tar.gz && \
112 cd openvswitch-2.5.0 && \
113 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install
114 )
115}
116
117ovs_install=0
118
119if [ -f /usr/bin/ovs-vsctl ] || [ -f /usr/local/bin/ovs-vsctl ]; then
120 ##find the version. Install if ovs version less than 2.5
121 version=`sudo ovs-vsctl --version | head -1 | awk '/[1-9].[0-9].[0-9]/ {print $NF}'`
122 major=$(echo $version | cut -d "." -f1)
123 minor=$(echo $version | cut -d "." -f2)
124 if [ $major -le 2 ]; then
125 if [ $major -lt 2 ]; then
126 ovs_install=1
127 else
128 if [ $minor -lt 5 ]; then
129 ovs_install=1
130 fi
131 fi
132 fi
133else
134 ovs_install=1
135fi
136
137if [ $ovs_install -eq 1 ]; then
138 echo "Installing OVS 2.5.0"
139 service openvswitch-switch stop
140 install_ovs
141fi
A R Karthickf7a613b2017-02-24 09:36:44 -0800142
143test_images=(cordtest/radius:candidate cordtest/quagga:candidate cordtest/nose:candidate)
144for img in ${test_images[*]}; do
145 echo "Pulling cord-tester image $img"
146 docker pull $img 2>/dev/null
147done