aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/resources/scripts/install/ovs_deploy.bash
blob: d94f30db1d0c01ac3d394bac865b010e2f15dbcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
#
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

INSTALL_OVS_BIN="/usr/src"
cd $INSTALL_OVS_BIN

if [[ $EUID -ne 0 ]]; then
  echo "Must be root to run $0"
  exit 1;
fi

prerequisite()
{
  echo "Install required libraries to run collectd..."
  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)
  for i in "${pkg[@]}"; do
  dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
  if [  "$?" -eq "1" ]; then
    apt-get update
    apt-get -y install "${i}";
  fi
  done
  echo "Done"
}

download_zip()
{
  url=$1
  download_type=$2
  if [ -n "${download_type}" ]; then
    echo "Download ${download_type} zip"
  fi
  # rm goes into calling code
  echo "${url}"
  if [ ! -e "${url##*/}" ]; then
    wget "${url}"
  fi
  tar xvf "${url##*/}"
}

dpdk_build()
{
  pushd .
  if [[ $DPDK_VERSION != "" ]]; then
    export DPDK_DIR=$INSTALL_OVS_BIN/dpdk-stable-$DPDK_VERSION
    export RTE_TARGET=x86_64-native-linuxapp-gcc
    export DPDK_BUILD=$DPDK_DIR/$RTE_TARGET
    rm -rf "$DPDK_DIR"
    DPDK_DOWNLOAD="http://fast.dpdk.org/rel/dpdk-$DPDK_VERSION.tar.xz"
    download_zip "${DPDK_DOWNLOAD}" "DPDK"
    cd dpdk-stable-"$DPDK_VERSION"
    make install -j T=$RTE_TARGET
  fi
  popd
}

ovs()
{
  pushd .
  if [[ $OVS_VERSION != "" ]]; then
    rm -rf openswitch-"$OVS_VERSION"
    OVS_DOWNLOAD="http://openvswitch.org/releases/openvswitch-$OVS_VERSION.tar.gz"
    download_zip "${OVS_DOWNLOAD}" "OVS"
    cd openvswitch-"$OVS_VERSION"
    export OVS_DIR=/usr/src/openvswitch-$OVS_VERSION
    ./boot.sh
    if [[ $DPDK_VERSION != "" ]]; then
      ./configure --with-dpdk="$DPDK_BUILD"
    else
      ./configure
    fi
    make install -j
  fi
  popd
}

main()
{
  dpdk_build
  ovs
}

for i in "$@"
do
  case $i in
    -o=*|--ovs=*)
      OVS_VERSION="${i#*=}"
    ;;
    -d=*|--dpdk=*)
      DPDK_VERSION="${i#*=}"
    ;;
    -p=*|--proxy=*)
      export http_proxy="${i#*=}"
      export https_proxy="${i#*=}"
    ;;
    -h|--help)
      echo "CommandLine options:"
      echo "===================="
      echo "1. ovs_dpdk install mode:"
      echo "./ovs_install.sh --ovs=<2.7.0> --dpdk=<supported dpdk versoin for given ovs> -p=<proxy>"
      echo
      exit
    ;;
    *)
    ;;
  esac
done

main