Adding centos.json to be used with packer to generate a VM with PROX
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / openstackrapid / deploycentos.sh
1 #!/bin/bash
2
3 ##
4 ## Copyright (c) 2010-2018 Intel Corporation
5 ##
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
9 ##
10 ##     http://www.apache.org/licenses/LICENSE-2.0
11 ##
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
17 ##
18 sudo sh -c '(echo "export RTE_TARGET=\"build\"";echo "export RTE_SDK=\"/root/dpdk\"";echo "export AESNI_MULTI_BUFFER_LIB_PATH=\"/home/centos/intel-ipsec-mb-0.48\"";) >> /root/.bashrc'
19 sudo yum install deltarpm -y
20 sudo yum update -y
21 sudo yum-config-manager --add-repo http://www.nasm.us/nasm.repo
22 sudo yum install git wget gcc unzip libpcap-devel ncurses-devel libedit-devel lua-devel kernel-devel iperf3 pciutils numactl-devel vim tuna openssl-devel nasm -y
23 # Enabling root ssh access
24 sudo sed -i '/disable_root: 1/c\disable_root: 0' /etc/cloud/cloud.cfg
25 # The following line is commented since this was a workaround for a problem with the content of /etc/resolv.conf.
26 # That file could contain DNS information coming from the dataplane which might be wrong. A solution is to confire the correct DNS for the dataplne
27 # in OpenStack.  DNS might be slowing down ssh access. We don't need that for our dataplane benchmarking purposes
28 # sudo sed -i '/#UseDNS yes/c\UseDNS no' /etc/ssh/sshd_config
29
30 # Mounting huge pages to be used by DPDK
31 sudo mkdir -p /mnt/huge
32 sudo umount `awk '/hugetlbfs/ { print $2 }' /proc/mounts` >/dev/null 2>&1
33 sudo mount -t hugetlbfs nodev /mnt/huge/
34 sudo sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'
35
36 # Downloading the Multi-buffer library
37 wget https://github.com/01org/intel-ipsec-mb/archive/v0.48.zip
38 unzip v0.48.zip
39 export  AESNI_MULTI_BUFFER_LIB_PATH=/home/centos/intel-ipsec-mb-0.48
40 cd $AESNI_MULTI_BUFFER_LIB_PATH
41 make -j8
42 # Clone and compile DPDK
43 cd /home/centos/
44 git clone http://dpdk.org/git/dpdk
45 cd dpdk
46 git checkout v17.11
47 export RTE_TARGET=build
48 export RTE_SDK=/home/centos/dpdk
49 make config T=x86_64-native-linuxapp-gcc
50 # 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
51 sudo sed -i '/CONFIG_RTE_LIBRTE_KNI=y/c\CONFIG_RTE_LIBRTE_KNI=n' /home/centos/dpdk/build/.config
52 sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_KNI=y/c\CONFIG_RTE_LIBRTE_PMD_KNI=n' /home/centos/dpdk/build/.config
53 sudo sed -i '/CONFIG_RTE_KNI_KMOD=y/c\CONFIG_RTE_KNI_KMOD=n' /home/centos/dpdk/build/.config
54 sudo sed -i '/CONFIG_RTE_KNI_PREEMPT_DEFAULT=y/c\CONFIG_RTE_KNI_PREEMPT_DEFAULT=n' /home/centos/dpdk/build/.config
55 # Compile with MB library
56 sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/c\CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y' /home/centos/dpdk/build/.config
57 make -j8 
58 cd /home/centos
59 # Copy everything to root since the scripts are assuming /root as the directory for PROX
60 sudo cp -r dpdk /root/
61
62 # Clone and compile PROX
63 git clone https://git.opnfv.org/samplevnf
64 cp -r /home/centos/samplevnf/VNFs/DPPD-PROX /home/centos/prox
65 cd /home/centos/prox
66 make -j8
67 cd /home/centos
68 # Copy everything to root since the scripts are assuming /root as the directory for PROX
69 sudo cp -r /home/centos/prox /root/
70
71 # Enabling tuned with the realtime-virtual-guest profile
72 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm
73 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
74 # Install with --nodeps. The latest CentOS cloud images come with a tuned version higher than 2.8. These 2 packages however
75 # do not depend on v2.8 and also work with tuned 2.9. Need to be careful in the future
76 sudo rpm -ivh /home/centos/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm --nodeps
77 sudo rpm -ivh /home/centos/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm --nodeps
78 # 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
79 # isolated CPUs so we can start the realtime-virtual-guest profile. If we don't, that command will fail.
80 # When the VM will be instantiated, the check_kernel_params service will check for the real number of cores available to this VM 
81 # and update the realtime-virtual-guest-variables.conf accordingly.
82 echo "isolated_cores=1" | sudo tee -a /etc/tuned/realtime-virtual-guest-variables.conf
83 sudo tuned-adm profile realtime-virtual-guest
84
85 # 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
86 # assigned to this VM depends on the flavor used. We don't know at this time what that will be.
87 sudo cp -r /home/centos/check_prox_system_setup.sh /usr/local/libexec/
88 sudo cp -r /home/centos/check-prox-system-setup.service /etc/systemd/system/
89 sudo systemctl daemon-reload
90 sudo systemctl enable check-prox-system-setup.service