Remove references to "dpdk_nic_bind" utility
[yardstick.git] / yardstick / resources / scripts / install / ovs_deploy.bash
1 #!/bin/bash
2 #
3 # Copyright (c) 2016-2017 Intel Corporation
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
17 INSTALL_OVS_BIN="/usr/src"
18 cd $INSTALL_OVS_BIN
19
20 if [[ $EUID -ne 0 ]]; then
21   echo "Must be root to run $0"
22   exit 1;
23 fi
24
25 prerequisite()
26 {
27   echo "Install required libraries to run collectd..."
28   pkg=(git flex bison build-essential pkg-config automake autotools-dev libltdl-dev cmake qemu-kvm libvirt-bin bridge-utils numactl libnuma-dev libpcap-dev)
29   for i in "${pkg[@]}"; do
30   dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
31   if [  "$?" -eq "1" ]; then
32     apt-get update
33     apt-get -y install "${i}";
34   fi
35   done
36   echo "Done"
37 }
38
39 download_zip()
40 {
41   url=$1
42   download_type=$2
43   if [ -n "${download_type}" ]; then
44     echo "Download ${download_type} zip"
45   fi
46   # rm goes into calling code
47   echo "${url}"
48   if [ ! -e "${url##*/}" ]; then
49     wget "${url}"
50   fi
51   tar xvf "${url##*/}"
52 }
53
54 dpdk_build()
55 {
56   pushd .
57   if [[ $DPDK_VERSION != "" ]]; then
58     export DPDK_DIR=$INSTALL_OVS_BIN/dpdk-stable-$DPDK_VERSION
59     export RTE_TARGET=x86_64-native-linuxapp-gcc
60     export DPDK_BUILD=$DPDK_DIR/$RTE_TARGET
61     rm -rf "$DPDK_DIR"
62     DPDK_DOWNLOAD="http://fast.dpdk.org/rel/dpdk-$DPDK_VERSION.tar.xz"
63     download_zip "${DPDK_DOWNLOAD}" "DPDK"
64     cd dpdk-stable-"$DPDK_VERSION"
65     make install -j T=$RTE_TARGET
66   fi
67   popd
68 }
69
70 ovs()
71 {
72   pushd .
73   if [[ $OVS_VERSION != "" ]]; then
74     rm -rf openswitch-"$OVS_VERSION"
75     OVS_DOWNLOAD="http://openvswitch.org/releases/openvswitch-$OVS_VERSION.tar.gz"
76     download_zip "${OVS_DOWNLOAD}" "OVS"
77     cd openvswitch-"$OVS_VERSION"
78     export OVS_DIR=/usr/src/openvswitch-$OVS_VERSION
79     ./boot.sh
80     if [[ $DPDK_VERSION != "" ]]; then
81       ./configure --with-dpdk="$DPDK_BUILD"
82     else
83       ./configure
84     fi
85     make install -j
86   fi
87   popd
88 }
89
90 main()
91 {
92   dpdk_build
93   ovs
94 }
95
96 for i in "$@"
97 do
98   case $i in
99     -o=*|--ovs=*)
100       OVS_VERSION="${i#*=}"
101     ;;
102     -d=*|--dpdk=*)
103       DPDK_VERSION="${i#*=}"
104     ;;
105     -p=*|--proxy=*)
106       export http_proxy="${i#*=}"
107       export https_proxy="${i#*=}"
108     ;;
109     -h|--help)
110       echo "CommandLine options:"
111       echo "===================="
112       echo "1. ovs_dpdk install mode:"
113       echo "./ovs_install.sh --ovs=<2.7.0> --dpdk=<supported dpdk versoin for given ovs> -p=<proxy>"
114       echo
115       exit
116     ;;
117     *)
118     ;;
119   esac
120 done
121
122 main