summaryrefslogtreecommitdiffstats
path: root/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files
diff options
context:
space:
mode:
Diffstat (limited to 'fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files')
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/build_ovs_dpdk.erb36
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/clean.sh45
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/configure_bridges.sh25
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/kvm-wrapper.sh46
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch-switch.conf13
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch.service11
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/ovs-dpdk-conf.erb28
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/set_vcpu_pin.sh24
-rwxr-xr-xfuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/tune_params.sh86
9 files changed, 314 insertions, 0 deletions
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/build_ovs_dpdk.erb b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/build_ovs_dpdk.erb
new file mode 100755
index 0000000..215d0b1
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/build_ovs_dpdk.erb
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+set -o xtrace
+
+if [ -e <%= @ovs_dir %>/BUILD_COMPLETE ]; then
+ echo "Build already done."
+ cd <%= @ovs_dir %>
+ sudo make install
+else
+ cd <%= @ovs_dpdk_dir %>
+ make config T=<%= @rte_target %>
+
+ if [ -e <%= @ovs_dpdk_dir %>/<%= @rte_target %> ]; then
+ rm <%= @rte_target %>
+ fi
+
+ # block of code with more strict error handling
+ set -o errexit
+ ln -s -f build <%= @rte_target %>
+ sed "s/CONFIG_RTE_BUILD_COMBINE_LIBS=n/CONFIG_RTE_BUILD_COMBINE_LIBS=y/" -i <%= @ovs_dpdk_dir %>/build/.config
+ sed "s/CONFIG_RTE_MAX_MEMSEG=.*$/CONFIG_RTE_MAX_MEMSEG=<%= @ovs_dpdk_mem_segments %>/" -i <%= @ovs_dpdk_dir %>/build/.config
+ sed "s/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=<%= @ovs_dpdk_rte_librte_vhost %>/" -i <%= @ovs_dpdk_dir %>/build/.config
+ sed "s/CONFIG_RTE_LIBRTE_VHOST_DEBUG=.*$/CONFIG_RTE_LIBRTE_VHOST_DEBUG=<%= @ovs_dpdk_vhost_user_debug %>/" -i <%= @ovs_dpdk_dir %>/build/.config
+ make -j `nproc`
+ sudo cp <%= @ovs_dpdk_dir %>/build/lib/*dpdk.* /lib
+ cd <%= @ovs_dir %>
+ ./boot.sh
+ ./configure --with-dpdk=<%= @ovs_dpdk_dir %>/<%= @rte_target %> --prefix=/usr --with-dbdir=<%= @ovs_db_conf_dir %> --with-rundir=<%= @ovs_db_socket_dir %>
+ make -j `nproc` CFLAGS='-O3 -march=native'
+ touch <%= @ovs_dir %>/BUILD_COMPLETE
+ sudo make install
+ set +o errexit
+fi
+
+
+set +o xtrace
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/clean.sh b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/clean.sh
new file mode 100755
index 0000000..9110b45
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/clean.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+# Short script for uninstallation of OVS with DPDK
+
+# enable debugging:
+#set -o xtrace
+
+# Stopping service if needed
+echo "[debug] stopping ovs-dpdk (if needed)"
+sudo service ovs-dpdk status 2>&1 1>/dev/null
+res=$?
+
+if [ $res -eq 2 ]; then
+ echo "[warning] service ovs-dpdk is already stopped"
+else
+ echo "[debug] stopping ovs-dpdk service"
+ sudo service ovs-dpdk stop 2>&1 1>/dev/null
+fi
+
+# Remove ovs-dpdk service
+echo "[debug] removing ovs-dpdk service"
+sudo rm -f /etc/default/ovs-dpdk
+sudo rm -f /etc/init.d/ovs-dpdk
+
+# kvm wrapper
+echo "[debug] replacing kvm wrapper"
+if [ -e /usr/bin/kvm ]; then
+ KVM_CMD="/usr/bin/kvm"
+elif [ -e /usr/bin/qemu-kvm ]; then
+ KVM_CMD="/usr/bin/qemu-kvm"
+elif [ -e /usr/libexec/qemu-kvm ]; then
+ KVM_CMD="/usr/libexec/qemu-kvm"
+else
+ echo "[warning] package qemu-kvm probably not installed"
+fi
+
+cat << 'EOF' | sudo tee $KVM_CMD
+#!/bin/sh
+
+exec /usr/bin/qemu-system-x86_64 "${args[@]}"
+EOF
+
+
+# remove git repos
+echo "[warning] git repos were not automatically removed, you can remove it once you're finished with them"
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/configure_bridges.sh b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/configure_bridges.sh
new file mode 100755
index 0000000..c77258f
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/configure_bridges.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+for bridge in `sudo ovs-vsctl list-br`; do sudo ovs-vsctl --no-wait set Bridge $bridge datapath_type=netdev; done;
+
+# Configure integration bridge with specified datapath
+#sudo ovs-vsctl --no-wait -- --may-exist add-br br-int
+#if [ "$1" != "" ]; then
+ #sudo ovs-vsctl --no-wait set Bridge br-int datapath_type=$1
+#fi
+#sudo ovs-vsctl --no-wait br-set-external-id br-int bridge-id br-int
+
+# Configure external bridge with specified datapath
+#sudo ovs-vsctl --no-wait -- --may-exist add-br br-ex
+#if [ "$1" != "" ]; then
+ #sudo ovs-vsctl --no-wait set Bridge br-ex datapath_type=$1
+#fi
+#sudo ovs-vsctl --no-wait br-set-external-id br-ex bridge-id br-ex
+
+# Configure br-tun bridge with specified datapath
+#sudo ovs-vsctl --no-wait -- --may-exist add-br br-tun
+#if [ "$1" != "" ]; then
+ #sudo ovs-vsctl --no-wait set Bridge br-tun datapath_type=$1
+#fi
+#sudo ovs-vsctl --no-wait br-set-external-id br-tun bridge-id br-tun
+
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/kvm-wrapper.sh b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/kvm-wrapper.sh
new file mode 100755
index 0000000..ea98408
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/kvm-wrapper.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+VIRTIO_OPTIONS="csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off"
+VHOST_FORCE="vhostforce"
+SHARE="share=on"
+add_mem=False
+i=0
+while [ $# -gt 0 ]; do
+ case "$1" in
+
+ -device)
+ args[i]="$1"
+ (( i++ ))
+ shift
+ if [[ $1 =~ "vhost-user" ]]
+ then
+ args[i]=${1},${VHOST_FORCE}
+ (( i++))
+ shift
+
+ fi
+ ;;
+ -object)
+ args[i]="$1"
+ (( i++ ))
+ shift
+ if [[ $1 =~ "memory-backend-file" ]]
+ then
+ args[i]=${1},${SHARE}
+ (( i++))
+ shift
+
+ fi
+ ;;
+
+ *)
+ args[i]="$1"
+ (( i++ ))
+ shift ;;
+ esac
+done
+echo "qemu ${args[@]}" > /tmp/qemu.orig
+if [ -e /usr/bin/qemu-system-x86_64 ]; then
+ exec /usr/bin/qemu-system-x86_64 "${args[@]}"
+elif [ -e /usr/libexec/qemu-kvm.orig ]; then
+ exec /usr/libexec/qemu-kvm.orig "${args[@]}"
+fi
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch-switch.conf b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch-switch.conf
new file mode 100755
index 0000000..185ae8e
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch-switch.conf
@@ -0,0 +1,13 @@
+# vim: set ft=upstart ts=2 et:
+description "Open vSwitch switch DPDK"
+
+start on (local-filesystems and net-device-up IFACE=lo)
+stop on runlevel [!2345]
+
+pre-start script
+ /etc/init.d/ovs-dpdk start
+end script
+
+post-stop script
+ /etc/init.d/ovs-dpdk stop
+end script
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch.service b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch.service
new file mode 100755
index 0000000..f46f9c7
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/openvswitch.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Open vSwitch with DPDK
+
+[Service]
+Type=oneshot
+ExecStart=/etc/init.d/ovs-dpdk start
+ExecStop=/etc/init.d/ovs-dpdk stop
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/ovs-dpdk-conf.erb b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/ovs-dpdk-conf.erb
new file mode 100755
index 0000000..4fd8604
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/ovs-dpdk-conf.erb
@@ -0,0 +1,28 @@
+RTE_SDK=<%= @ovs_dpdk_dir %>
+RTE_TARGET=<%= @rte_target %>
+
+OVS_INSTALL_DIR=<%= @ovs_install_dir %>
+OVS_DB_CONF_DIR=<%= @ovs_db_conf_dir %>
+OVS_DB_SOCKET_DIR=<%= @ovs_db_socket_dir %>
+OVS_DB_CONF=<%= @ovs_db_conf_dir %>/conf.db
+OVS_DB_SOCKET=<%= @ovs_db_socket_dir %>/db.sock
+
+OVS_SOCKET_MEM=<%= @ovs_socket_mem %>
+OVS_MEM_CHANNELS=<%= @ovs_mem_channels %>
+OVS_CORE_MASK=<%= @ovs_core_mask %>
+OVS_PMD_CORE_MASK=<%= @ovs_pmd_core_mask %>
+OVS_LOG_DIR=<%= @ovs_log_dir %>
+OVS_LOCK_DIR=<%= @ovs_lock_dir %>
+OVS_DIR=<%= @ovs_dir %>
+OVS_UTILS=<%= @ovs_dir %>/utilities/
+OVS_DB_UTILS=<%= @ovs_dir %>/ovsdb/
+OVS_DPDK_DIR=<%= @ovs_dpdk_dir %>
+OVS_NUM_HUGEPAGES=<%= @ovs_num_hugepages %>
+OVS_HUGEPAGE_MOUNT=<%= @ovs_hugepage_mount %>
+OVS_HUGEPAGE_MOUNT_PAGESIZE=<%= @ovs_hugepage_mount_pagesize %>
+OVS_BRIDGE_MAPPINGS=<%= @ovs_bridge_mappings %>
+OVS_PCI_MAPPINGS=<%= @ovs_pci_mappings %>
+OVS_DPDK_PORT_MAPPINGS=<%= @ovs_dpdk_port_mappings %>
+OVS_TUNNEL_CIDR_MAPPING=<%= @ovs_tunnel_cidr_mapping %>
+OVS_ALLOCATE_HUGEPAGES=<%= @ovs_allocate_hugepages %>
+OVS_INTERFACE_DRIVER=<%= @ovs_interface_driver %>
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/set_vcpu_pin.sh b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/set_vcpu_pin.sh
new file mode 100755
index 0000000..0cb3791
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/set_vcpu_pin.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+# Small script for calculation of cores not suitable for deployment
+# of VM's and adaptation of nova.conf accordingly
+# nova.conf path should come as first param
+# this should be executed when nova is enabled and already configured
+
+source /etc/default/ovs-dpdk
+
+OVS_CORE_MASK=$(echo $OVS_CORE_MASK | sed 's/^0x//')
+OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
+BAD_CORES=$((`echo $((16#${OVS_CORE_MASK}))` | `echo $((16#${OVS_PMD_CORE_MASK}))`))
+TOTAL_CORES=`nproc`
+vcpu_pin_set=""
+
+for cpu in $(seq 0 `expr $TOTAL_CORES - 1`);do
+ tmp=`echo 2^$cpu | bc`
+ if [ $(($tmp & $BAD_CORES)) -eq 0 ]; then
+ vcpu_pin_set+=$cpu","
+ fi
+done
+vcpu_pin_set=${vcpu_pin_set::-1}
+
+crudini --set $1 DEFAULT vcpu_pin_set $vcpu_pin_set
diff --git a/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/tune_params.sh b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/tune_params.sh
new file mode 100755
index 0000000..e9908e4
--- /dev/null
+++ b/fuel-plugin-ovsnfv/deployment_scripts/puppet/modules/ovsdpdk/files/tune_params.sh
@@ -0,0 +1,86 @@
+#!/usr/bin/env bash
+
+# It adapts /etc/default/ovs-dpdk file
+# generated mainly from devstack/libs/ovs-dpdk
+# it will modify / tune variables, which are not configured directly
+
+source /etc/default/ovs-dpdk
+
+if [ $OVS_SOCKET_MEM == "auto" ] ; then
+ for d in /sys/devices/system/node/node? ; do
+ if [ $OVS_SOCKET_MEM == "auto" ]; then
+ OVS_SOCKET_MEM=2048
+ else
+ OVS_SOCKET_MEM=$OVS_SOCKET_MEM,2048
+ fi
+ done
+fi
+
+sudo sed "s#OVS_SOCKET_MEM=.*#OVS_SOCKET_MEM=$OVS_SOCKET_MEM#" -i /etc/default/ovs-dpdk
+
+# Creates an array of pci addres to interface names delimeted by # e.g. <pci_address>#<interface name>
+PAIRS=( `ls -al /sys/class/net/* | grep pci | rev | awk '{print $1;}' | cut -d '/' -f 1,3 | rev | sed s'/\//#/'` )
+# Populates OVS_BRIDGE_MAPPINGS if $PHYSICAL_NETWORK and $OVS_PHYSICAL_BRIDGE are used instead.
+if [[ "$OVS_DATAPATH_TYPE" != "" ]] && [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
+ OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
+fi
+
+if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
+ OVS_BRIDGES=${OVS_BRIDGE_MAPPINGS//,/ }
+ ARRAY=( $OVS_BRIDGES )
+ for net in "${ARRAY[@]}"; do
+ bridge="${net##*:}"
+ nic=${bridge/br-/}
+ if [[ -z "$OVS_DPDK_PORT_MAPPINGS" ]]; then
+ OVS_DPDK_PORT_MAPPINGS=$nic:$bridge
+ else
+ OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS,$nic:$bridge
+ fi
+ done
+fi
+
+MAPPINGS=${OVS_DPDK_PORT_MAPPINGS//,/ }
+
+ARRAY=( $MAPPINGS )
+NICS=""
+for net in "${ARRAY[@]}"; do
+ nic="${net%%:*}"
+ bridge="${net##*:}"
+ printf "%s in %s\n" "$KEY" "$VALUE"
+ for pair in "${PAIRS[@]}"; do
+ if [[ $nic == `echo $pair | cut -f 2 -d "#"` ]]; then
+ if [[ $NICS == "" ]]; then
+ NICS=$pair
+ else
+ NICS=$NICS,$pair
+ fi
+ fi
+ done
+done
+sudo sed "s/OVS_PCI_MAPPINGS=.*/OVS_PCI_MAPPINGS=$NICS/" -i /etc/default/ovs-dpdk
+sudo sed "s/OVS_BRIDGE_MAPPINGS=.*/OVS_BRIDGE_MAPPINGS=$OVS_BRIDGE_MAPPINGS/" -i /etc/default/ovs-dpdk
+sudo sed "s/OVS_DPDK_PORT_MAPPINGS=.*/OVS_DPDK_PORT_MAPPINGS=$OVS_DPDK_PORT_MAPPINGS/" -i /etc/default/ovs-dpdk
+
+OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
+
+if [ $OVS_PMD_CORE_MASK -eq 4 ]; then
+ #default value, check for siblings in case of hyperthreading enabled
+ SIBLINGS=""
+ RESULT=0
+ FILE="/sys/devices/system/cpu/cpu3/topology/thread_siblings_list"
+ if [ -e $FILE ]; then
+ SIBLINGS=`cat $FILE`
+ else
+ echo "warning: don't know how to check siblings"
+ SIBLINGS=3
+ fi
+
+ for SIBLING in $(echo $SIBLINGS | sed -n 1'p' | tr ',' '\n'); do
+ SIBLING_CORE=`echo "obase=10;$((1<<($SIBLING-1)))" | bc`
+ RESULT=$(($RESULT | $SIBLING_CORE))
+ done
+
+ OVS_PMD_CORE_MASK=`printf "%x" $RESULT`
+fi
+
+sudo sed "s#OVS_PMD_CORE_MASK=.*#OVS_PMD_CORE_MASK=$OVS_PMD_CORE_MASK#" -i /etc/default/ovs-dpdk