3 ## Copyright (c) 2010-2019 Intel Corporation
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
9 ## http://www.apache.org/licenses/LICENSE-2.0
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.
18 BUILD_DIR="/opt/rapid"
19 WORK_DIR="/home/centos" # Directory where the packer tool has copied some files (e.g. check_prox_system_setup.sh)
20 # Runtime scripts are assuming ${WORK_DIR} as the directory for PROX. Check the rundir variable in runrapid.py. Should be the same!
21 # This variable is defined in 4 different places and should have the same value: centos.json, deploycentos.sh, check_prox_system_setup.sh and runrapid.py
23 PROX_COMMIT="f456ab65"
24 ##PROX_CHECKOUT="git checkout ${PROX_COMMIT}"
25 ## Next line is overruling the PROX_COMMIT and will replace the version with a very specific patch. Should be commented out
26 ## if you want to use a committed version of PROX
27 PROX_CHECKOUT="git fetch \"https://gerrit.opnfv.org/gerrit/samplevnf\" refs/changes/75/69475/2 && git checkout FETCH_HEAD"
28 MULTI_BUFFER_LIB_VER="0.52"
29 export RTE_SDK="${BUILD_DIR}/dpdk-${DPDK_VERSION}"
30 export RTE_TARGET="x86_64-native-linuxapp-gcc"
32 function os_pkgs_install()
34 sudo yum install -y deltarpm yum-utils
35 # NASM repository for AESNI MB library
36 sudo yum-config-manager --add-repo http://www.nasm.us/nasm.repo
39 sudo yum install -y git wget gcc unzip libpcap-devel ncurses-devel \
40 libedit-devel lua-devel kernel-devel iperf3 pciutils \
41 numactl-devel vim tuna openssl-devel nasm wireshark
46 # huge pages to be used by DPDK
47 sudo sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'
49 # Enabling tuned with the realtime-virtual-guest profile
50 pushd ${BUILD_DIR} > /dev/null 2>&1
51 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm
52 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm
53 # Install with --nodeps. The latest CentOS cloud images come with a tuned version higher than 2.8. These 2 packages however
54 # do not depend on v2.8 and also work with tuned 2.9. Need to be careful in the future
55 sudo rpm -ivh ${BUILD_DIR}/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm --nodeps
56 sudo rpm -ivh ${BUILD_DIR}/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm --nodeps
57 # Although we do no know how many cores the VM will have when begin deployed for real testing, we already put a number for the
58 # isolated CPUs so we can start the realtime-virtual-guest profile. If we don't, that command will fail.
59 # When the VM will be instantiated, the check_kernel_params service will check for the real number of cores available to this VM
60 # and update the realtime-virtual-guest-variables.conf accordingly.
61 echo "isolated_cores=1" | sudo tee -a /etc/tuned/realtime-virtual-guest-variables.conf
62 sudo tuned-adm profile realtime-virtual-guest
64 # Install the check_tuned_params service to make sure that the grub cmd line has the right cpus in isolcpu. The actual number of cpu's
65 # assigned to this VM depends on the flavor used. We don't know at this time what that will be.
66 sudo chmod +x ${WORK_DIR}/check_prox_system_setup.sh
67 sudo cp -r ${WORK_DIR}/check_prox_system_setup.sh /usr/local/libexec/
68 sudo cp -r ${WORK_DIR}/check-prox-system-setup.service /etc/systemd/system/
69 sudo systemctl daemon-reload
70 sudo systemctl enable check-prox-system-setup.service
75 function mblib_install()
77 export AESNI_MULTI_BUFFER_LIB_PATH="${BUILD_DIR}/intel-ipsec-mb-${MULTI_BUFFER_LIB_VER}"
79 # Downloading the Multi-buffer library. Note that the version to download is linked to the DPDK version being used
80 pushd ${BUILD_DIR} > /dev/null 2>&1
81 wget https://github.com/01org/intel-ipsec-mb/archive/v${MULTI_BUFFER_LIB_VER}.zip
82 unzip v${MULTI_BUFFER_LIB_VER}.zip
83 pushd ${AESNI_MULTI_BUFFER_LIB_PATH}
84 make -j`getconf _NPROCESSORS_ONLN`
90 function dpdk_install()
92 # Build DPDK for the latest kernel installed
93 LATEST_KERNEL_INSTALLED=`ls -v1 /lib/modules/ | tail -1`
94 export RTE_KERNELDIR="/lib/modules/${LATEST_KERNEL_INSTALLED}/build"
96 # Get and compile DPDK
97 pushd ${BUILD_DIR} > /dev/null 2>&1
98 wget http://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz
99 tar -xf ./dpdk-${DPDK_VERSION}.tar.xz
100 popd > /dev/null 2>&1
102 sudo ln -s ${RTE_SDK} ${WORK_DIR}/dpdk
104 pushd ${RTE_SDK} > /dev/null 2>&1
105 make config T=${RTE_TARGET}
106 # The next sed lines make sure that we can compile DPDK 17.11 with a relatively new OS. Using a newer DPDK (18.5) should also resolve this issue
107 #sudo sed -i '/CONFIG_RTE_LIBRTE_KNI=y/c\CONFIG_RTE_LIBRTE_KNI=n' ${RTE_SDK}/build/.config
108 #sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_KNI=y/c\CONFIG_RTE_LIBRTE_PMD_KNI=n' ${RTE_SDK}/build/.config
109 #sudo sed -i '/CONFIG_RTE_KNI_KMOD=y/c\CONFIG_RTE_KNI_KMOD=n' ${RTE_SDK}/build/.config
110 #sudo sed -i '/CONFIG_RTE_KNI_PREEMPT_DEFAULT=y/c\CONFIG_RTE_KNI_PREEMPT_DEFAULT=n' ${RTE_SDK}/build/.config
111 # Compile with MB library
112 sed -i '/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/c\CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y' ${RTE_SDK}/build/.config
113 make -j`getconf _NPROCESSORS_ONLN`
114 ln -s ${RTE_SDK}/build ${RTE_SDK}/${RTE_TARGET}
115 popd > /dev/null 2>&1
118 function prox_compile()
121 pushd ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX
122 make -j`getconf _NPROCESSORS_ONLN`
123 popd > /dev/null 2>&1
126 function prox_install()
128 # Clone and compile PROX
129 pushd ${BUILD_DIR} > /dev/null 2>&1
130 git clone https://git.opnfv.org/samplevnf
131 pushd ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX
132 #git checkout ${PROX_COMMIT}
134 popd > /dev/null 2>&1
136 sudo ln -s ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX ${WORK_DIR}/prox
137 popd > /dev/null 2>&1
140 if [ "$1" == "compile" ]; then
143 [ ! -d ${BUILD_DIR} ] && sudo mkdir -p ${BUILD_DIR}
144 sudo chmod 0777 ${BUILD_DIR}