Integrate contiv/vpp CNI into IEC
[iec.git] / src / foundation / scripts / cni / contivpp / contiv-update-config.sh
1 #!/bin/bash
2 set -o xtrace
3 set -e
4
5 SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
6
7 echo "SCRIPTS_DIR is :$SCRIPTS_DIR"
8
9 DEV_NAME=${1:-}
10
11 if [ -z "${DEV_NAME}" ]
12 then
13   echo "Please specify a device name!"
14   exit 1
15 fi
16
17 # Extract PCI address
18 PCI_ADDRESS=$(lshw -class network -businfo | awk -F '@| ' '/pci.*'$DEV_NAME'/ {printf $2}')
19 if [ -z "${PCI_ADDRESS}" ]
20 then
21   echo "PCI_ADDRESS is NULL, maybe $DEV_NAME is wrong!"
22   exit 1
23 fi
24
25 # Update config file
26 mkdir -p /etc/vpp
27 cp -f ${SCRIPTS_DIR}/contiv-vswitch.conf  /etc/vpp/contiv-vswitch.conf
28 cat <<EOF >> /etc/vpp/contiv-vswitch.conf
29 dpdk {
30     dev $PCI_ADDRESS
31 }
32 EOF
33
34 # make sure that the selected interface is shut down, otherwise VPP would not grab it
35 ifconfig $DEV_NAME down