Skip to content

Commit

Permalink
Adding centos.json to be used with packer to generate a VM with PROX
Browse files Browse the repository at this point in the history
Based on a CentOS cloud image downloadable from the web, you can now use
packer to create an image that has DPDK and PROX installed in the
proper directories. The VM is also tuned for guest VNFs.
A service is also created to deal with the proper isolated_cpu settings
for tuned. The service will also make sure uio and igb_uio are loaded.
The prox_user_data.sh is not needed any more and hence deleted.
ctrl-c of runrapid.py will now also stop prox in all the VMs so a new
test can be started.

Change-Id: I16cc59878e2d4912757f42e05f98d51dff5feb89
Signed-off-by: Luc Provoost <[email protected]>
  • Loading branch information
Luc Provoost authored and sdeepak2 committed Jun 29, 2018
1 parent bc032ee commit 260bc7b
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 84 deletions.
31 changes: 25 additions & 6 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/README
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ rapid is a set of files offering an easy way to do a sanity check of the
dataplane performance of an OpenStack environment.

Copy the files in a directory on a machine that can run the OpenStack CLI
commands and that can reach the OpenStack public network. Also create a qcow2
image in the same directory with the following characteristics:
commands and that can reach the OpenStack public network.
One option is to create a qcow2 image in the same directory with the
following characteristics:
* Name of the qcow2 file should be: rapidVM.qcow2
This default name can be overruled on the rapid command line (--image_file)
* Should have DPDK and PROX installed. PROX should be in /root/prox/ directory
Expand All @@ -31,8 +32,19 @@ image in the same directory with the following characteristics:
* Compile prox with 'make crc=soft'. This is a workaround for some cases where the crc calculation offload is not working as expected.
* Compile dpdk to support AESN-NI Multi Buffer Crypto Poll Mode Driver: http://dpdk.org/doc/guides/cryptodevs/aesni_mb.html

Source the openrc file of the OpenStack environment so that the OpenStack CLI
commands can be run:
Alternatively, you can create an image in OpenStack using Packer and then specify
the image to be used as a parameter to createrapid.py. First step is to upload an
existing CentOs cloud image from the internet into OpenStack.
Check out: https://cloud.centos.org/centos/7/images/
You should now source the proper .rc file so Packer can connect to your OpenStack.
There are 2 files: centos.json and deploycentos.sh, allowing you to create
an image automatically. Run
# packer build centos.json
Note that this procedure is not only installing the necessary tools to run PROX,
but also does some system optimizations (tuned).

Now that the image exists in OpenStack, source the openrc file of the OpenStack
environment so that the OpenStack CLI commands can be run:
# source openrc
Now you can run the createrapid.py file. Use help for more info on the usage:
# ./createrapid.py --help
Expand All @@ -45,6 +57,10 @@ You can use floating IP addresses by specifying the floating IP network
--floating_network NETWORK
or directly connect throught the INTERNAL_NETWORK by using the following parameter:
--floating_network NO
/etc/resolv.conf will contain DNS info from the "best" interface. Since we are
deploying VMs with multiple interface on different networks, this info might be
taken from the "wrong" network (e.g. the dataplane network). It is good to provide
also a working DNS on that network.

Now you can run the runrapid.py file. Use help for more info on the usage:
# ./runrapid.py --help
Expand Down Expand Up @@ -88,8 +104,11 @@ An example of the env file generated by createrapid.py can be found below.
Note that this file can be created manually in case the stack is created in a
different way (not using the createrapid.py). This can be useful in case you are
not using OpenStack as a VIM or when using special configurations that cannot be
achieved using createrapid.py. Only the [Mx] sections are used as
input for runrapid.py.
achieved using creater needed for runrapid are:
* all info in the [Mx] sections
* the key information in the [OpenStack] section
* the total_number_of_vms information in the [rapid] section

[DEFAULT]
admin_ip = none

Expand Down
7 changes: 3 additions & 4 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/basicrapid.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ config_file = swap.cfg
group1cores = [1]

[test1]
cmd=run_speedtest(sock[0],sock[1])
cmd=run_speedtest(socks[0],socks[1])
[test2]
cmd=run_sizetest(sock[0],sock[1])
cmd=run_sizetest(socks[0],socks[1])
[test3]
cmd=run_flowtest(sock[0],sock[1])

cmd=run_flowtest(socks[0],socks[1])
33 changes: 33 additions & 0 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/centos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"_Copyright": "Copyright (c) 2010-2018 Intel Corporation",
"_License": "SPDX-License-Identifier: Apache-2.0",
"builders": [
{
"type": "openstack",
"ssh_username": "centos",
"image_name": "newrapidVM",
"source_image": "aa0f8333-d8e1-42db-8210-6b39d9ee7267",
"flavor": "7aaec028-eccc-4612-8f9b-29a1e039943a",
"networks": "97bbe96f-ee1b-4789-ace8-e922f76bea3f",
"use_floating_ip": true,
"floating_ip_pool": "1f564356-8c23-41e2-8292-7696ffd98adf",
"security_groups": "8fd498fc-5bd8-4be6-94e4-a2cc3b02d151"
}
],
"provisioners": [
{
"type": "file",
"source": "./check_prox_system_setup.sh",
"destination": "/home/centos/"
},
{
"type": "file",
"source": "./check-prox-system-setup.service",
"destination": "/home/centos/"
},
{
"type": "shell",
"script": "deploycentos.sh"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Check PROX system setup (isolated_cores, uio)
DefaultDependencies=no
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/local/libexec/check_prox_system_setup.sh

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
##
## Copyright (c) 2010-2018 Intel Corporation
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
NCPUS="$(lscpu | egrep '^CPU\(s\):' | awk '{ print $2 }')"
MAXCOREID="$((NCPUS-1))"

filename="/etc/tuned/realtime-virtual-guest-variables.conf"
logfile="/home/centos/prox_system_setup.log"
if [ -f "$filename" ]
then
while read -r line
do
case $line in
isolated_cores=1-$MAXCOREID*)
echo "Isolated CPU(s) OK, no reboot: $line">>$logfile
modprobe uio
insmod /root/dpdk/build/kmod/igb_uio.ko
exit 0
;;
isolated_cores=*)
echo "Isolated CPU(s) NOK, change the config and reboot: $line">>$logfile
sed -i "/^isolated_cores=.*/c\isolated_cores=1-$MAXCOREID" $filename
tuned-adm profile realtime-virtual-guest
reboot
exit 0
;;
*)
echo "$line"
;;
esac
done < "$filename"
echo "isolated_cores=1-$MAXCOREID" >> $filename
echo "No Isolated CPU(s) defined in config, line added: $line">>$logfile
tuned-adm profile realtime-virtual-guest
reboot
else
echo "$filename not found.">>$logfile
fi
36 changes: 20 additions & 16 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/createrapid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from prox_ctrl import prox_ctrl
import ConfigParser

version="18.3.27"
version="18.6.15"
stack = "rapid" #Default string for stack. This is not an OpenStack Heat stack, just a group of VMs
vms = "rapidVMs" #Default string for vms file
key = "prox" # default name for kay
Expand Down Expand Up @@ -296,7 +296,8 @@ def usage():
log.exception("Failed to create subnet: " + subnet)
raise Exception("Failed to create subnet: " + subnet)


ServerToBeCreated=[]
ServerName=[]
config = ConfigParser.RawConfigParser()
vmconfig = ConfigParser.RawConfigParser()
vmconfig.read(vms+'.vms')
Expand All @@ -306,16 +307,18 @@ def usage():
flavor_meta_data = vmconfig.get('VM%d'%vm, 'flavor_meta_data')
boot_info = vmconfig.get('VM%d'%vm, 'boot_info')
SRIOV_port = vmconfig.get('VM%d'%vm, 'SRIOV_port')
server_name = '%s-VM%d'%(stack,vm)
ServerName.append('%s-VM%d'%(stack,vm))
flavor_name = '%s-VM%d-flavor'%(stack,vm)
log.debug("Checking server: "+server_name)
cmd = 'openstack server show '+server_name
log.debug("Checking server: "+ServerName[-1])
cmd = 'openstack server show '+ServerName[-1]
log.debug (cmd)
cmd = cmd + ' |grep "\sname\s" | tr -s " " | cut -d" " -f 4'
ServerExist = subprocess.check_output(cmd , shell=True).strip()
if ServerExist == server_name:
log.info("Server ("+server_name+") already active")
if ServerExist == ServerName[-1]:
log.info("Server ("+ServerName[-1]+") already active")
ServerToBeCreated.append("no")
else:
ServerToBeCreated.append("yes")
# Checking if the flavor already exists, if not create it
log.debug("Checking flavor: "+flavor_name)
cmd = 'openstack flavor show '+flavor_name
Expand Down Expand Up @@ -353,24 +356,25 @@ def usage():
else:
wait = ' '
log.info("Creating server...")
cmd = 'openstack server create --flavor %s --key-name %s --image %s %s %s%s%s'%(flavor_name,key,image,nic_info,boot_info,wait,server_name)
cmd = 'openstack server create --flavor %s --key-name %s --image %s %s %s%s%s'%(flavor_name,key,image,nic_info,boot_info,wait,ServerName[-1])
log.debug(cmd)
cmd = cmd + ' |grep "\sname\s" | tr -s " " | cut -d" " -f 4'
ServerExist = subprocess.check_output(cmd , shell=True).strip()
if floating_network <> 'NO':
if floating_network <> 'NO':
for vm in range(0, int(total_number_of_VMs)):
if ServerToBeCreated[vm] =="yes":
log.info('Creating floating IP ...')
cmd = 'openstack floating ip create ' + floating_network
log.debug(cmd)
cmd = cmd + ' |grep "floating_ip_address " | tr -s " " | cut -d"|" -f 3'
vmAdminIP = subprocess.check_output(cmd , shell=True).strip()
log.info('Associating floating IP ...')
cmd = 'openstack server add floating ip %s %s'%(server_name,vmAdminIP)
cmd = 'openstack server add floating ip %s %s'%(ServerName[vm],vmAdminIP)
log.debug(cmd)
output = subprocess.check_output(cmd , shell=True).strip()
print (output)

for vm in range(1, int(total_number_of_VMs)+1):
server_name = '%s-VM%d'%(stack,vm)
cmd = 'openstack server show %s'%(server_name)
cmd = 'openstack server show %s'%(ServerName[vm-1])
log.debug(cmd)
output = subprocess.check_output(cmd , shell=True).strip()
searchString = '.*%s.*?([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)' %(dataplane_network)
Expand All @@ -381,15 +385,15 @@ def usage():
vmAdminIP = matchObj.group(2)
if vmAdminIP == None:
vmAdminIP = matchObj.group(1)
cmd = 'openstack port list |grep %s | tr -s " " | cut -d"|" -f 4'%(vmDPIP)
cmd = 'openstack port list |egrep "\\b%s\\b" | tr -s " " | cut -d"|" -f 4'%(vmDPIP)
log.debug(cmd)
vmDPmac = subprocess.check_output(cmd , shell=True).strip()
config.add_section('M%d'%vm)
config.set('M%d'%vm, 'name', server_name)
config.set('M%d'%vm, 'name', ServerName[vm-1])
config.set('M%d'%vm, 'admin_ip', vmAdminIP)
config.set('M%d'%vm, 'dp_ip', vmDPIP)
config.set('M%d'%vm, 'dp_mac', vmDPmac)
log.info('%s: (admin IP: %s), (dataplane IP: %s), (dataplane MAC: %s)' % (server_name,vmAdminIP,vmDPIP,vmDPmac))
log.info('%s: (admin IP: %s), (dataplane IP: %s), (dataplane MAC: %s)' % (ServerName[vm-1],vmAdminIP,vmDPIP,vmDPmac))

config.add_section('OpenStack')
config.set('OpenStack', 'stack', stack)
Expand Down
90 changes: 90 additions & 0 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/deploycentos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

##
## Copyright (c) 2010-2018 Intel Corporation
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
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'
sudo yum install deltarpm -y
sudo yum update -y
sudo yum-config-manager --add-repo http://www.nasm.us/nasm.repo
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
# Enabling root ssh access
sudo sed -i '/disable_root: 1/c\disable_root: 0' /etc/cloud/cloud.cfg
# The following line is commented since this was a workaround for a problem with the content of /etc/resolv.conf.
# 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
# in OpenStack. DNS might be slowing down ssh access. We don't need that for our dataplane benchmarking purposes
# sudo sed -i '/#UseDNS yes/c\UseDNS no' /etc/ssh/sshd_config

# Mounting huge pages to be used by DPDK
sudo mkdir -p /mnt/huge
sudo umount `awk '/hugetlbfs/ { print $2 }' /proc/mounts` >/dev/null 2>&1
sudo mount -t hugetlbfs nodev /mnt/huge/
sudo sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'

# Downloading the Multi-buffer library
wget https://github.com/01org/intel-ipsec-mb/archive/v0.48.zip
unzip v0.48.zip
export AESNI_MULTI_BUFFER_LIB_PATH=/home/centos/intel-ipsec-mb-0.48
cd $AESNI_MULTI_BUFFER_LIB_PATH
make -j8
# Clone and compile DPDK
cd /home/centos/
git clone http://dpdk.org/git/dpdk
cd dpdk
git checkout v17.11
export RTE_TARGET=build
export RTE_SDK=/home/centos/dpdk
make config T=x86_64-native-linuxapp-gcc
# 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
sudo sed -i '/CONFIG_RTE_LIBRTE_KNI=y/c\CONFIG_RTE_LIBRTE_KNI=n' /home/centos/dpdk/build/.config
sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_KNI=y/c\CONFIG_RTE_LIBRTE_PMD_KNI=n' /home/centos/dpdk/build/.config
sudo sed -i '/CONFIG_RTE_KNI_KMOD=y/c\CONFIG_RTE_KNI_KMOD=n' /home/centos/dpdk/build/.config
sudo sed -i '/CONFIG_RTE_KNI_PREEMPT_DEFAULT=y/c\CONFIG_RTE_KNI_PREEMPT_DEFAULT=n' /home/centos/dpdk/build/.config
# Compile with MB library
sudo sed -i '/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/c\CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y' /home/centos/dpdk/build/.config
make -j8
cd /home/centos
# Copy everything to root since the scripts are assuming /root as the directory for PROX
sudo cp -r dpdk /root/

# Clone and compile PROX
git clone https://git.opnfv.org/samplevnf
cp -r /home/centos/samplevnf/VNFs/DPPD-PROX /home/centos/prox
cd /home/centos/prox
make -j8
cd /home/centos
# Copy everything to root since the scripts are assuming /root as the directory for PROX
sudo cp -r /home/centos/prox /root/

# Enabling tuned with the realtime-virtual-guest profile
wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm
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
# Install with --nodeps. The latest CentOS cloud images come with a tuned version higher than 2.8. These 2 packages however
# do not depend on v2.8 and also work with tuned 2.9. Need to be careful in the future
sudo rpm -ivh /home/centos/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm --nodeps
sudo rpm -ivh /home/centos/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm --nodeps
# 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
# isolated CPUs so we can start the realtime-virtual-guest profile. If we don't, that command will fail.
# When the VM will be instantiated, the check_kernel_params service will check for the real number of cores available to this VM
# and update the realtime-virtual-guest-variables.conf accordingly.
echo "isolated_cores=1" | sudo tee -a /etc/tuned/realtime-virtual-guest-variables.conf
sudo tuned-adm profile realtime-virtual-guest

# 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
# assigned to this VM depends on the flavor used. We don't know at this time what that will be.
sudo cp -r /home/centos/check_prox_system_setup.sh /usr/local/libexec/
sudo cp -r /home/centos/check-prox-system-setup.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable check-prox-system-setup.service
1 change: 1 addition & 0 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/devbind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ then
else
echo Assuming port is already bound to DPDK
fi
exit 0
3 changes: 1 addition & 2 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/impair.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ sub mode=l3
rx port=if0
tx port=if0
delay us=10
probability=100
probability=80
local ipv4=${local_ip}

3 changes: 2 additions & 1 deletion VNFs/DPPD-PROX/helper-scripts/openstackrapid/impair.test
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ config_file = swap.cfg
group1cores = [1]

[test1]
cmd=run_speedtest(sock[0],sock[2])
cmd=run_impairtest(socks[0],socks[2],8)
# The last parameter specifies the speed at which this test will run
6 changes: 3 additions & 3 deletions VNFs/DPPD-PROX/helper-scripts/openstackrapid/irq.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ group1cores = [1,2,3]


[test1]
cmd=run_irqtest(sock[0])
cmd=run_irqtest(socks[0])
[test2]
cmd=run_irqtest(sock[1])
cmd=run_irqtest(socks[1])
[test3]
cmd=run_irqtest(sock[2])
cmd=run_irqtest(socks[2])

Loading

0 comments on commit 260bc7b

Please sign in to comment.