summaryrefslogtreecommitdiffstats
path: root/rapidvm/dib
diff options
context:
space:
mode:
Diffstat (limited to 'rapidvm/dib')
-rwxr-xr-xrapidvm/dib/build-image.sh99
-rw-r--r--rapidvm/dib/elements/rapid/element-deps5
-rw-r--r--rapidvm/dib/elements/rapid/package-installs.yaml20
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/40-mlib30
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/50-compile-dpdk38
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/60-compile-prox28
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/70-os-cfg50
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/80-change-permissions18
-rwxr-xr-xrapidvm/dib/elements/rapid/post-install.d/81-clean-rpms20
-rw-r--r--rapidvm/dib/elements/rapid/source-repository-dpdk1
-rw-r--r--rapidvm/dib/elements/rapid/source-repository-samplevnf1
11 files changed, 310 insertions, 0 deletions
diff --git a/rapidvm/dib/build-image.sh b/rapidvm/dib/build-image.sh
new file mode 100755
index 00000000..23fe17ca
--- /dev/null
+++ b/rapidvm/dib/build-image.sh
@@ -0,0 +1,99 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+# A shell script to build the PROX VM image using diskimage-builder
+#
+usage() {
+ echo "Usage: $0 [-i image_name] [-g gs-url] [-v]"
+ echo " -i image_appendix image name to be pushed to google storage)"
+ echo " -g gs_url url to store the image"
+ echo " -v verify only (build but do not push to google storage)"
+ echo " -w cache cache directory for disk-image-create"
+ exit 1
+}
+
+# set -e
+#default values
+image_appendix="test"
+workspace="/home/jenkins-ci/opnfv/slave_root/workspace"
+gs_url="artifacts.opnfv.org/samplevnf/images"
+verify_only=0
+while getopts i:g:vw: flag
+do
+ case "${flag}" in
+ i) image_appendix=${OPTARG};;
+ g) gs_url=${OPTARG};;
+ v) verify_only=1;;
+ w) workspace=${OPTARG};;
+ *) usage;exit 1;;
+ esac
+done
+echo "gs_url: $gs_url";
+echo "Verify only: $verify_only";
+image_name=rapid-${image_appendix}
+echo "image name: $image_name.qcow2"
+echo "workspace: $workspace"
+
+ install diskimage-builder
+python3 -m venv dib-rapid-venv
+. dib-rapid-venv/bin/activate
+pip3 install --upgrade pip
+pip3 install six
+pip3 install diskimage-builder
+pip3 install gsutil
+
+echo "Checking if image exists in google storage..."
+if command -v gsutil >/dev/null; then
+ if gsutil -q stat gs://$gs_url/$image_name.qcow2; then
+ echo "Image already exists at http://$gs_url/$image_name.qcow2"
+ fi
+ echo "Starting build..."
+ echo
+else
+ echo "Cannot check image availability in OPNFV artifact repository (gsutil not available)"
+fi
+
+# Add rapid elements directory to the DIB elements path
+export ELEMENTS_PATH=`pwd`/elements
+# canned user/password for direct login
+export DIB_DEV_USER_USERNAME=prox
+export DIB_DEV_USER_PASSWORD=prox
+export DIB_DEV_USER_PWDLESS_SUDO=Y
+# Set the data sources to have ConfigDrive only
+export DIB_CLOUD_INIT_DATASOURCES="Ec2, ConfigDrive, OpenStack"
+# Use ELRepo to have latest kernel
+export DIB_USE_ELREPO_KERNEL=True
+echo "Building $image_name.qcow2..."
+cache=$workspace/cache
+mkdir $cache
+time disk-image-create -o $image_name --image-cache $cache centos7 cloud-init rapid vm
+
+ls -l $image_name.qcow2
+
+
+if [ $verify_only -eq 1 ]; then
+ echo "Image verification SUCCESS"
+ echo "NO upload to google storage (-v)"
+else
+ if command -v gsutil >/dev/null; then
+ echo "Uploading $image_name.qcow2..."
+ gsutil cp $image_name.qcow2 gs://$gs_url/$image_name.qcow2
+ echo "You can access image at http://$gs_url/$image_name.qcow2"
+ else
+ echo "Cannot upload new image to the OPNFV artifact repository (gsutil not available)"
+ exit 1
+ fi
+fi
+deactivate
+rm -r dib-rapid-venv
diff --git a/rapidvm/dib/elements/rapid/element-deps b/rapidvm/dib/elements/rapid/element-deps
new file mode 100644
index 00000000..c6be0aa3
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/element-deps
@@ -0,0 +1,5 @@
+vm
+cloud-init-datasources
+install-static
+package-installs
+devuser
diff --git a/rapidvm/dib/elements/rapid/package-installs.yaml b/rapidvm/dib/elements/rapid/package-installs.yaml
new file mode 100644
index 00000000..8b3a3cf3
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/package-installs.yaml
@@ -0,0 +1,20 @@
+deltarpm:
+yum-utils:
+git:
+wget:
+gcc:
+unzip:
+libpcap-devel:
+ncurses-devel:
+libedit-devel:
+lua-devel:
+kernel-devel:
+iperf3:
+pciutils:
+numactl-devel:
+vim:
+tuna:
+openssl-devel:
+wireshark:
+make:
+driverctl:
diff --git a/rapidvm/dib/elements/rapid/post-install.d/40-mlib b/rapidvm/dib/elements/rapid/post-install.d/40-mlib
new file mode 100755
index 00000000..34dc1b9c
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/40-mlib
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+MULTI_BUFFER_LIB_VER="0.52"
+BUILD_DIR="/opt/rapid"
+export AESNI_MULTI_BUFFER_LIB_PATH="${BUILD_DIR}/intel-ipsec-mb-${MULTI_BUFFER_LIB_VER}"
+# Downloading the Multi-buffer library. Note that the version to download is linked to the DPDK version being used
+pushd ${BUILD_DIR} > /dev/null 2>&1
+wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/linux/nasm-2.14.02-0.fc27.x86_64.rpm
+rpm -ivh nasm-2.14.02-0.fc27.x86_64.rpm
+wget https://github.com/01org/intel-ipsec-mb/archive/v${MULTI_BUFFER_LIB_VER}.zip
+unzip v${MULTI_BUFFER_LIB_VER}.zip
+pushd ${AESNI_MULTI_BUFFER_LIB_PATH}
+make -j`getconf _NPROCESSORS_ONLN`
+make install
+popd > /dev/null 2>&1
+popd > /dev/null 2>&1
diff --git a/rapidvm/dib/elements/rapid/post-install.d/50-compile-dpdk b/rapidvm/dib/elements/rapid/post-install.d/50-compile-dpdk
new file mode 100755
index 00000000..6a7fdf36
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/50-compile-dpdk
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+# pick up the kernel version for the target image
+BUILD_DIR="/opt/rapid"
+export RTE_SDK="${BUILD_DIR}/dpdk"
+export RTE_TARGET="x86_64-native-linuxapp-gcc"
+
+LATEST_KERNEL_INSTALLED=`ls -v1 /lib/modules/ | tail -1`
+export RTE_KERNELDIR="/lib/modules/${LATEST_KERNEL_INSTALLED}/build"
+
+pushd ${RTE_SDK} > /dev/null 2>&1
+make config T=${RTE_TARGET}
+# Starting from DPDK 20.05, the IGB_UIO driver is not compiled by default.
+# Uncomment the sed command to enable the driver compilation
+sed -i 's/CONFIG_RTE_EAL_IGB_UIO=n/CONFIG_RTE_EAL_IGB_UIO=y/g' ${RTE_SDK}/build/.config
+#sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y/g' ${RTE_SDK}/build/.config
+sed -i 's/CONFIG_RTE_APP_TEST=y/CONFIG_RTE_APP_TEST=n/g' ${RTE_SDK}/build/.config
+sed -i 's/CONFIG_RTE_TEST_PMD=y/CONFIG_RTE_TEST_PMD=n/g' ${RTE_SDK}/build/.config
+sed -i 's/CONFIG_RTE_TEST_BBDEV=y/CONFIG_RTE_TEST_BBDEV=n/g' ${RTE_SDK}/build/.config
+sed -i 's/CONFIG_RTE_APP_COMPRESS_PERF=y/CONFIG_RTE_APP_COMPRESS_PERF=n/g' ${RTE_SDK}/build/.config
+sed -i 's/CONFIG_RTE_APP_CRYPTO_PERF=y/CONFIG_RTE_APP_CRYPTO_PERF=n/g' ${RTE_SDK}/build/.config
+#sed -i 's/CONFIG_RTE_APP_EVENTDEV=y/CONFIG_RTE_APP_EVENTDEV=n/g' ${RTE_SDK}/build/.config
+make -j`getconf _NPROCESSORS_ONLN`
+popd > /dev/null 2>&1
diff --git a/rapidvm/dib/elements/rapid/post-install.d/60-compile-prox b/rapidvm/dib/elements/rapid/post-install.d/60-compile-prox
new file mode 100755
index 00000000..ebb87fd8
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/60-compile-prox
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+BUILD_DIR="/opt/rapid"
+export RTE_SDK="${BUILD_DIR}/dpdk"
+export RTE_TARGET="build"
+pushd ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX > /dev/null 2>&1
+make -j`getconf _NPROCESSORS_ONLN`
+cp ${BUILD_DIR}/samplevnf/VNFs/DPPD-PROX/build/app/prox ${BUILD_DIR}/prox
+cp helper-scripts/rapid/check_prox_system_setup.sh ${BUILD_DIR}
+cp helper-scripts/rapid/check-prox-system-setup.service ${BUILD_DIR}
+cp helper-scripts/rapid/sharkproxlog.sh ${BUILD_DIR}
+cp helper-scripts/rapid/deploycentostools.sh ${BUILD_DIR}
+cp helper-scripts/rapid/rapid_rsa_key.pub ${BUILD_DIR}
+popd > /dev/null 2>&1
diff --git a/rapidvm/dib/elements/rapid/post-install.d/70-os-cfg b/rapidvm/dib/elements/rapid/post-install.d/70-os-cfg
new file mode 100755
index 00000000..5171a32b
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/70-os-cfg
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+BUILD_DIR="/opt/rapid"
+# huge pages to be used by DPDK
+sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'
+
+sh -c '(echo "options vfio enable_unsafe_noiommu_mode=1") > /etc/modprobe.d/vfio.conf'
+sh -c '(echo "vfio") > /etc/modules-load.d/vfio.conf'
+sh -c '(echo "vfio-pci") > /etc/modules-load.d/vfio.conf'
+# Enabling tuned with the realtime-virtual-guest profile
+pushd ${BUILD_DIR} > /dev/null 2>&1
+wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.9.0-1.el7_5.2.noarch.rpm
+wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-nfv-guest-2.9.0-1.el7_5.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
+rpm -ivh ${BUILD_DIR}/tuned-profiles-realtime-2.9.0-1.el7_5.2.noarch.rpm --nodeps
+rpm -ivh ${BUILD_DIR}/tuned-profiles-nfv-guest-2.9.0-1.el7_5.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-3" | tee -a /etc/tuned/realtime-virtual-guest-variables.conf
+# The actual tuned-adm profile is now done in check_prox_system_setup.sh and is started through
+# the check-prox-system-setup.service. This will happen when the system is booting.
+
+# 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.
+chmod +x ${BUILD_DIR}/check_prox_system_setup.sh
+mv ${BUILD_DIR}/check_prox_system_setup.sh /usr/local/libexec/
+mv ${BUILD_DIR}/check-prox-system-setup.service /etc/systemd/system/
+# systemctl daemon-reload, will be skipped when building image with disk-image-builder. That is OK
+systemctl daemon-reload
+systemctl enable check-prox-system-setup.service
+# Add the default rapid key as an authorized key for the rapid user
+cat ${BUILD_DIR}/rapid_rsa_key.pub >> /home/rapid/.ssh/authorized_keys
+popd > /dev/null 2>&1
diff --git a/rapidvm/dib/elements/rapid/post-install.d/80-change-permissions b/rapidvm/dib/elements/rapid/post-install.d/80-change-permissions
new file mode 100755
index 00000000..86368431
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/80-change-permissions
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+BUILD_DIR="/opt/rapid"
+chmod ugo+rwx ${BUILD_DIR}
diff --git a/rapidvm/dib/elements/rapid/post-install.d/81-clean-rpms b/rapidvm/dib/elements/rapid/post-install.d/81-clean-rpms
new file mode 100755
index 00000000..0fc166e3
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/post-install.d/81-clean-rpms
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 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.
+#
+BUILD_DIR="/opt/rapid"
+rm ${BUILD_DIR}/tuned-profiles-realtime-2.9.0-1.el7_5.2.noarch.rpm
+rm ${BUILD_DIR}/tuned-profiles-nfv-guest-2.9.0-1.el7_5.2.noarch.rpm
+rm ${BUILD_DIR}/nasm-2.14.02-0.fc27.x86_64.rpm
diff --git a/rapidvm/dib/elements/rapid/source-repository-dpdk b/rapidvm/dib/elements/rapid/source-repository-dpdk
new file mode 100644
index 00000000..ce19a904
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/source-repository-dpdk
@@ -0,0 +1 @@
+dpdk tar /opt/rapid/dpdk http://fast.dpdk.org/rel/dpdk-20.05.tar.gz *
diff --git a/rapidvm/dib/elements/rapid/source-repository-samplevnf b/rapidvm/dib/elements/rapid/source-repository-samplevnf
new file mode 100644
index 00000000..80331875
--- /dev/null
+++ b/rapidvm/dib/elements/rapid/source-repository-samplevnf
@@ -0,0 +1 @@
+samplevnf git /opt/rapid/samplevnf https://git.opnfv.org/samplevnf