Update of topo_installation file
[csit.git] / bootstrap-hw-tb2.sh
1 #!/bin/bash
2 # Copyright (c) 2016 Cisco and/or its affiliates.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 set -x
16
17 # space separated list of available testbeds, described by topology files
18 TOPOLOGIES="topologies/available/lf_testbed2-710-520.yaml"
19
20 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21 WORKING_TOPOLOGY=""
22 export PYTHONPATH=${CUR_DIR}
23
24 sudo apt-get -y update
25 sudo apt-get -y install libpython2.7-dev python-virtualenv
26
27 virtualenv env
28 . env/bin/activate
29
30 echo pip install
31 pip install -r requirements.txt
32
33 #we iterate over available topologies and wait until we reserve topology
34 while :; do
35     for TOPOLOGY in ${TOPOLOGIES};
36     do
37         python ${CUR_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
38         if [ $? -eq 0 ]; then
39             WORKING_TOPOLOGY=${TOPOLOGY}
40             echo "Reserved: ${WORKING_TOPOLOGY}"
41             break
42         fi
43     done
44
45     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
46         #exit the infinite while loop if we made a reservation
47         break
48     fi
49
50     #wait 10 - 30 sec. before next try
51     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 10 ]s
52     echo "Sleeping ${SLEEP_TIME}"
53     sleep ${SLEEP_TIME}
54 done
55
56 function cancel_reservation {
57     python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
58 }
59
60 #on script exit we cancel the reservation
61 trap "cancel_reservation ${WORKING_TOPOLOGY}" EXIT
62
63 #run performance test suite
64 pybot -L TRACE \
65     -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
66     -s performance tests/