b4a31e64e2447bf0f52d9b5bb147663c6a83c651
[releng/builder.git] / packer / provision / mininet.sh
1 #!/bin/bash
2
3 # vim: sw=4 ts=4 sts=4 et tw=72 :
4
5 # force any errors to cause the script and job to end in failure
6 set -xeu -o pipefail
7
8 # Ensure that necessary variables are set to enable noninteractive mode in
9 # commands.
10 export DEBIAN_FRONTEND=noninteractive
11
12 # To handle the prompt style that is expected all over the environment
13 # with how use use robotframework we need to make sure that it is
14 # consistent for any of the users that are created during dynamic spin
15 # ups
16 echo 'PS1="[\u@\h \W]> "' >> /etc/skel/.bashrc
17
18 echo '---> Install mininet with OF13 patch'
19 cd /tmp
20 cat > newOptions.patch <<EOF
21 --- mininet/node.py     2014-09-12 13:48:03.165628683 +0100
22 +++ mininet/node.py     2014-09-12 13:50:39.021630236 +0100
23 @@ -952,6 +952,10 @@
24             datapath: userspace or kernel mode (kernel|user)"""
25          Switch.__init__( self, name, **params )
26          self.failMode = failMode
27 +        protKey = 'protocols'
28 +        if self.params and protKey in self.params:
29 +               print 'have protcol params!'
30 +               self.opts += protKey + '=' + self.params[protKey]
31          self.datapath = datapath
32
33      @classmethod
34 @@ -1027,8 +1031,9 @@
35          if self.datapath == 'user':
36              self.cmd( 'ovs-vsctl set bridge', self,'datapath_type=netdev' )
37          int( self.dpid, 16 ) # DPID must be a hex string
38 +        print 'OVSswitch opts: ',self.opts
39          self.cmd( 'ovs-vsctl -- set Bridge', self,
40 -                  'other_config:datapath-id=' + self.dpid )
41 +                  self.opts+' other_config:datapath-id=' + self.dpid )
42          self.cmd( 'ovs-vsctl set-fail-mode', self, self.failMode )
43          for intf in self.intfList():
44              if not intf.IP():
45 EOF
46
47 git clone git://github.com/mininet/mininet
48 cd mininet/
49 git checkout -b 2.1.0 2.1.0
50 git apply -p0 < ../newOptions.patch
51 cd ./util
52 ./install.sh -nfv
53
54 echo '---> Installing cbench installation for running openflow performance tests'
55 OF_DIR="$HOME/openflow"  # Directory that contains OpenFlow code
56 OFLOPS_DIR="$HOME/oflops"  # Directory that contains oflops repo
57
58 apt-get install -y --force-yes libsnmp-dev libpcap-dev libconfig-dev
59
60 git clone git://gitosis.stanford.edu/openflow.git "$OF_DIR"
61 git clone https://github.com/andi-bigswitch/oflops.git "$OFLOPS_DIR"
62
63 cd "$OFLOPS_DIR"
64 ./boot.sh
65 ./configure --with-openflow-src-dir="$OF_DIR"
66 make
67 make install
68
69 echo '---> Installing vlan for vlan based tests in VTN suites'
70 apt-get install -y --force-yes vlan
71
72 # Install netaddr package which is needed by some custom mininet topologies
73 apt-get install -y --force-yes -qq python-netaddr