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/openstackrapid"
19 COPY_DIR="/home/centos" # Directory where the packer tool has copied some files (e.g. check_prox_system_setup.sh)
21 PROX_COMMIT="c8e9e6bb696363a397b2e718eb4d3e5f38a8ef22"
22 export RTE_SDK="${BUILD_DIR}/dpdk-${DPDK_VERSION}"
23 export RTE_TARGET="x86_64-native-linuxapp-gcc"
25 function os_pkgs_install()
27 # NASM repository for AESNI MB library
28 sudo yum-config-manager --add-repo http://www.nasm.us/nasm.repo
30 sudo yum install -y deltarpm
32 sudo yum install -y git wget gcc unzip libpcap-devel ncurses-devel \
33 libedit-devel lua-devel kernel-devel iperf3 pciutils \
34 numactl-devel vim tuna openssl-devel nasm wireshark
39 # Enabling root ssh access
40 sudo sed -i '/disable_root: 1/c\disable_root: 0' /etc/cloud/cloud.cfg
42 # huge pages to be used by DPDK
43 sudo sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'
45 # Enabling tuned with the realtime-virtual-guest profile
46 pushd ${BUILD_DIR} > /dev/null 2>&1
47 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm
48 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
49 # Install with --nodeps. The latest CentOS cloud images come with a tuned version higher than 2.8. These 2 packages however
50 # do not depend on v2.8 and also work with tuned 2.9. Need to be careful in the future
51 sudo rpm -ivh ${BUILD_DIR}/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm --nodeps
52 sudo rpm -ivh ${BUILD_DIR}/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm --nodeps
53 # 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
54 # isolated CPUs so we can start the realtime-virtual-guest profile. If we don't, that command will fail.
55 # When the VM will be instantiated, the check_kernel_params service will check for the real number of cores available to this VM
56 # and update the realtime-virtual-guest-variables.conf accordingly.
57 echo "isolated_cores=1" | sudo tee -a /etc/tuned/realtime-virtual-guest-variables.conf
58 sudo tuned-adm profile realtime-virtual-guest
60 # 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
61 # assigned to this VM depends on the flavor used. We don't know at this time what that will be.
62 sudo chmod +x ${COPY_DIR}/check_prox_system_setup.sh
63 sudo cp -r ${COPY_DIR}/check_prox_system_setup.sh /usr/local/libexec/
64 sudo cp -r ${COPY_DIR}/check-prox-system-setup.service /etc/systemd/system/
65 sudo systemctl daemon-reload
66 sudo systemctl enable check-prox-system-setup.service
71 function mblib_install()
73 export AESNI_MULTI_BUFFER_LIB_PATH="${BUILD_DIR}/intel-ipsec-mb-0.50"
75 # Downloading the Multi-buffer library. Note that the version to download is linked to the DPDK version being used
76 pushd ${BUILD_DIR} > /dev/null 2>&1
77 wget https://github.com/01org/intel-ipsec-mb/archive/v0.50.zip
79 pushd ${AESNI_MULTI_BUFFER_LIB_PATH}
80 make -j`getconf _NPROCESSORS_ONLN`
86 function dpdk_install()
88 # Build DPDK for the latest kernel installed
89 LATEST_KERNEL_INSTALLED=`ls -v1 /lib/modules/ | tail -1`
90 export RTE_KERNELDIR="/lib/modules/${LATEST_KERNEL_INSTALLED}/build"
92 # Get and compile DPDK
93 pushd ${BUILD_DIR} > /dev/null 2>&1
94 wget http://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz
95 tar -xf ./dpdk-${DPDK_VERSION}.tar.xz
98 # Runtime scripts are assuming /root as the directory for PROX
99 sudo ln -s ${RTE_SDK} /root/dpdk
101 pushd ${RTE_SDK} > /dev/null 2>&1
102 make config T=${RTE_TARGET}
103 # 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
104 #sudo sed -i '/CONFIG_RTE_LIBRTE_KNI=y/c\CONFIG_RTE_LIBRTE_KNI=n' ${RTE_SDK}/build/.config
105 #sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_KNI=y/c\CONFIG_RTE_LIBRTE_PMD_KNI=n' ${RTE_SDK}/build/.config
106 #sudo sed -i '/CONFIG_RTE_KNI_KMOD=y/c\CONFIG_RTE_KNI_KMOD=n' ${RTE_SDK}/build/.config
107 #sudo sed -i '/CONFIG_RTE_KNI_PREEMPT_DEFAULT=y/c\CONFIG_RTE_KNI_PREEMPT_DEFAULT=n' ${RTE_SDK}/build/.config
108 # Compile with MB library
109 sed -i '/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/c\CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y' ${RTE_SDK}/build/.config
110 make -j`getconf _NPROCESSORS_ONLN`
111 ln -s ${RTE_SDK}/build ${RTE_SDK}/${RTE_TARGET}
112 popd > /dev/null 2>&1
115 function prox_compile()
118 pushd ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX
119 make -j`getconf _NPROCESSORS_ONLN`
120 popd > /dev/null 2>&1
123 function prox_install()
125 # Clone and compile PROX
126 pushd ${BUILD_DIR} > /dev/null 2>&1
127 git clone https://git.opnfv.org/samplevnf
128 pushd ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX
129 git checkout ${PROX_COMMIT}
130 popd > /dev/null 2>&1
132 sudo ln -s ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX /root/prox
133 popd > /dev/null 2>&1
136 if [ "$1" == "compile" ]; then
139 echo "Positional parameter 1 is empty"
140 [ ! -d ${BUILD_DIR} ] && sudo mkdir -p ${BUILD_DIR}
141 sudo chmod 0777 ${BUILD_DIR}