nfvbenchvm: add option to use local nfvbench code
[nfvbench.git] / nfvbenchvm / dib / elements / nfvbenchvm / post-install.d / 52-nfvbench-script
1 #!/bin/bash
2
3 if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
4     set -x
5 fi
6
7 # Make sure the disk image build fails if nfvbench installation fails
8 set -euo pipefail
9
10 if [ $DIB_DEV_IMAGE != "generator" ]; then
11     exit 0
12 fi
13
14 # TRex installation
15 mkdir -p /opt/trex
16 mkdir /var/log/nfvbench
17
18 wget --no-cache --no-check-certificate https://trex-tgn.cisco.com/trex/release/$TREX_VER.tar.gz
19 tar xzf $TREX_VER.tar.gz -C /opt/trex
20 rm -f /$TREX_VER.tar.gz
21 rm -f /opt/trex/$TREX_VER/trex_client_$TREX_VER.tar.gz
22 cp -a /opt/trex/$TREX_VER/automation/trex_control_plane/interactive/trex /usr/local/lib/python3.6/site-packages/
23 rm -rf /opt/trex/$TREX_VER/automation/trex_control_plane/interactive/trex
24
25 # NFVbench installation
26 cd /opt
27 if [[ "${DIB_NFVBENCH_CODE_ORIGIN}" == "static" ]]; then
28     # nfvbench code has been copied by the install-static element to
29     # /opt/nfvbench without the .git/ directory.  But pip will need that .git/
30     # directory to compute nfvbench version, so will now finish the incomplete
31     # job of install-static:
32     STATIC_NFVBENCH_CODE="$(dirname $0)/../static/opt/nfvbench"
33     [ -d "${STATIC_NFVBENCH_CODE}" ] || {
34         echo "Error: directory ${STATIC_NFVBENCH_CODE} missing."
35         echo "    You requested a build from local nfvbench code with"
36         echo "    DIB_NFVBENCH_CODE_ORIGIN=static, but you likely forgot"
37         echo "    to clone nfvbench code in elements/nfvbenchvm/static/opt/nfvbench"
38         exit 1
39     }
40     rsync -lr "${STATIC_NFVBENCH_CODE}"/ /opt/nfvbench/
41 else
42     git clone https://gerrit.opnfv.org/gerrit/nfvbench
43 fi
44 cd nfvbench/
45 python3 -m pip install . --use-deprecated=legacy-resolver
46 cp xtesting/testcases.yaml /usr/local/lib/python3.6/site-packages/xtesting/ci/testcases.yaml
47 python3 ./docker/cleanup_generators.py
48 rm -rf /opt/nfvbench/.git
49 rm -rf /opt/nfvbench/nfvbench
50 # symlink to NFVbench sources
51 ln -s /usr/local/lib/python3.6/site-packages/nfvbench /opt/nfvbench/nfvbench
52 # persist env variables
53 echo "export TREX_VER=\"$TREX_VER\"" >> /etc/profile.d/nfvbench.sh
54 echo "export TREX_EXT_LIBS=\"/opt/trex/$TREX_VER/external_libs\"" >> /etc/profile.d/nfvbench.sh