blob: c4443e4a9ffc178a0de374c600379c6c75eea2b4 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
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
16
Chetan Gaonkercc19ac42016-05-04 17:21:50 -070017#!/usr/bin/env bash
A R Karthick63815d12017-02-08 11:14:40 -080018
19function usage {
20 echo "usage: ${0#*/} [-h |--help] [--cord] [--venv]"
21 exit 1
22}
23
A R Karthickd49ca4b2016-07-27 11:52:50 -070024on_cord=0
A R Karthick63815d12017-02-08 11:14:40 -080025venv=0
26optspec=":h-:"
27while getopts "$optspec" optchar; do
28 case "${optchar}" in
29 -)
30 case "${OPTARG}" in
31 cord)
32 on_cord=1
A R Karthick63815d12017-02-08 11:14:40 -080033 ;;
34 venv)
35 venv=1
A R Karthick63815d12017-02-08 11:14:40 -080036 ;;
37 help)
38 usage
39 ;;
40 *)
41 echo "Unknown option --${OPTARG}"
42 usage
43 ;;
44 esac
45 ;;
46 h)
47 usage
48 ;;
49 *)
50 usage
51 ;;
52 esac
53done
54
55shift $((OPTIND-1))
56if [ $# -gt 0 ]; then
57 usage
Chetan Gaonkercc19ac42016-05-04 17:21:50 -070058fi
A R Karthick63815d12017-02-08 11:14:40 -080059
60apt-get update
61release=$(lsb_release -cs)
A R Karthick66cf6f62017-02-28 14:04:34 -080062#install docker only if not installed already. On cord, its mostly installed.
63if $(which docker 2>&1 >/dev/null); then
64 on_cord=1
65else
66 on_cord=0
67fi
A R Karthickd49ca4b2016-07-27 11:52:50 -070068if [ $on_cord -eq 0 ]; then
69 apt-get -y install apt-transport-https ca-certificates
70 apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
71 if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
A R Karthickbd82f362016-11-10 15:08:52 -080072 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 -070073 fi
74 apt-get update
75 apt-get purge lxc-docker || true
76 apt-get -y install linux-image-extra-$(uname -r)
77 apt-get -y install apparmor
78 echo "Installing Docker"
79 apt-get -y install docker-engine
A R Karthickc4108fe2016-11-17 15:15:28 -080080 service docker restart
A R Karthick973010f2017-02-06 16:41:51 -080081 sleep 5
A R Karthickd49ca4b2016-07-27 11:52:50 -070082 echo "Verifying Docker installation"
83 docker run --rm hello-world || exit 127
84 docker rmi hello-world
A R Karthickb05acab2016-11-10 15:12:43 -080085 echo "Pulling ONOS latest"
A R Karthickd49ca4b2016-07-27 11:52:50 -070086 docker pull onosproject/onos:latest || exit 127
A R Karthick63815d12017-02-08 11:14:40 -080087else
88 echo "Skipping installation of Docker and ONOS"
A R Karthickd49ca4b2016-07-27 11:52:50 -070089fi
A R Karthick05e85fa2016-12-02 09:20:54 -080090
A R Karthick63815d12017-02-08 11:14:40 -080091apt-get -y install openvswitch-common openvswitch-switch
92apt-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
93
94setup_path=$(dirname $(realpath $0))
95if [ $venv -eq 1 ]; then
96 echo "Making a virtual cord-tester pip installation environment"
97 mkdir -p $setup_path/venv
A R Karthickd7f6ade2017-02-08 12:23:58 -080098 virtualenv $setup_path/venv
A R Karthick63815d12017-02-08 11:14:40 -080099 echo "Installing cord-tester pip packages on the virtual environment"
100 $setup_path/venv/bin/pip install -r $setup_path/requirements.txt
101else
102 echo "Installing cord-tester pip packages on the host"
103 pip install -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