3 touch /var/lock/subsys/local
5 # Waiting for cloud-init to generate $NFVBENCH_CONF, retry 60 seconds
6 NFVBENCH_CONF=/etc/nfvbenchvm.conf
7 OPENRC=/etc/nfvbench/openrc
9 until [ $retry -eq 0 ]; do
10 if [ -f $NFVBENCH_CONF ]; then break; fi
14 if [ ! -f $NFVBENCH_CONF ]; then
18 # Parse and obtain all configurations
19 echo "Generating configurations for NFVbench and TRex..."
20 eval $(cat $NFVBENCH_CONF)
21 touch /nfvbench_configured.flag
23 if [ -f $OPENRC ]; then
28 if [ $DNS_SERVERS ]; then
29 IFS="," read -a dns <<< $DNS_SERVERS
30 for d in "${dns[@]}"; do
31 echo "nameserver $d" >> /etc/resolv.conf
35 # CPU isolation optimizations
36 echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
37 echo 1 > /sys/devices/virtual/workqueue/cpumask
38 echo 1 > /proc/irq/default_smp_affinity
39 for irq in `ls /proc/irq/`; do
40 if [ -f /proc/irq/$irq/smp_affinity ]; then
41 echo 1 > /proc/irq/$irq/smp_affinity
45 NET_PATH=/sys/class/net
48 # device mapping for CentOS Linux 7:
50 # 00.03.0 Ethernet controller: Red Hat, Inc. Virtio network device
51 # 00.04.0 Ethernet controller: Red Hat, Inc. Virtio network device
53 # /sys/class/net/eth0 -> ../../devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
54 # /sys/class/net/eth1 -> ../../devices/pci0000:00/0000:00:04.0/virtio1/net/eth1
57 for f in $(ls $NET_PATH/); do
58 if grep -q "$mac" $NET_PATH/$f/address; then
59 eth_port=$(readlink $NET_PATH/$f | cut -d "/" -f8)
60 # some virtual interfaces match on MAC and do not have a PCI address
61 if [ "$eth_port" -a "$eth_port" != "N/A" ]; then
62 # Found matching interface
63 logger "NFVBENCHVM: found interface $f ($eth_port) matching $mac"
70 if [ -z "$eth_port" ]; then
71 echo "ERROR: Cannot find eth port for MAC $mac" >&2
72 logger "NFVBENCHVM ERROR: Cannot find eth port for MAC $mac"
79 # Set VM MANAGEMENT port up and running
80 if [ $INTF_MGMT_CIDR ] && [ $INTF_MGMT_IP_GW ]; then
81 if [ $INTF_MAC_MGMT ]; then
82 ETH_PORT=$(get_eth_port $INTF_MAC_MGMT)
83 elif [ -f $OPENRC ] && [ "$PORT_MGMT_NAME" ]; then
84 $INTF_MAC_MGMT=$(openstack port list | grep $PORT_MGMT_NAME | grep -o -Ei '([a-fA-F0-9:]{17}|[a-fA-F0-9]{12}$)' | head -1)
85 ETH_PORT=$(get_eth_port $INTF_MAC_MGMT)
89 if [ -z "$ETH_PORT" ]; then
90 echo "ERROR: Cannot find eth port for management port" >&2
91 logger "NFVBENCHVM ERROR: Cannot find eth port for management port"
94 ip addr add $INTF_MGMT_CIDR dev $ETH_PORT
95 ip link set $ETH_PORT up
96 ip route add default via $INTF_MGMT_IP_GW dev $ETH_PORT
98 echo "INFO: VM management IP Addresses missing in $NFVBENCH_CONF"
101 /nfvbench/configure-nfvbench.sh
104 /nfvbench/start-nfvbench.sh $ACTION
106 /nfvbench/start-nfvbench.sh