3 touch /var/lock/subsys/local
5 # Waiting for cloud-init to generate $NFVBENCH_CONF, retry 60 seconds
6 NFVBENCH_CONF=/etc/nfvbenchvm.conf
8 until [ $retry -eq 0 ]; do
9 if [ -f $NFVBENCH_CONF ]; then break; fi
13 if [ ! -f $NFVBENCH_CONF ]; then
17 # Parse and obtain all configurations
18 echo "Generating configurations for NFVbench and TRex..."
19 eval $(cat $NFVBENCH_CONF)
20 touch /nfvbench_configured.flag
23 if [ $DNS_SERVERS ]; then
24 IFS="," read -a dns <<< $DNS_SERVERS
25 for d in "${dns[@]}"; do
26 echo "nameserver $d" >> /etc/resolv.conf
30 # CPU isolation optimizations
31 echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
32 echo 1 > /sys/devices/virtual/workqueue/cpumask
33 echo 1 > /proc/irq/default_smp_affinity
34 for irq in `ls /proc/irq/`; do
35 if [ -f /proc/irq/$irq/smp_affinity ]; then
36 echo 1 > /proc/irq/$irq/smp_affinity
40 NET_PATH=/sys/class/net
43 # device mapping for CentOS Linux 7:
45 # 00.03.0 Ethernet controller: Red Hat, Inc. Virtio network device
46 # 00.04.0 Ethernet controller: Red Hat, Inc. Virtio network device
48 # /sys/class/net/eth0 -> ../../devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
49 # /sys/class/net/eth1 -> ../../devices/pci0000:00/0000:00:04.0/virtio1/net/eth1
52 for f in $(ls $NET_PATH/); do
53 if grep -q "$mac" $NET_PATH/$f/address; then
54 eth_port=$(readlink $NET_PATH/$f | cut -d "/" -f8)
55 # some virtual interfaces match on MAC and do not have a PCI address
56 if [ "$eth_port" -a "$eth_port" != "N/A" ]; then
57 # Found matching interface
58 logger "NFVBENCHVM: found interface $f ($eth_port) matching $mac"
65 if [ -z "$eth_port" ]; then
66 echo "ERROR: Cannot find eth port for MAC $mac" >&2
67 logger "NFVBENCHVM ERROR: Cannot find eth port for MAC $mac"
74 # Set VM MANAGEMENT port up and running
75 if [ $INTF_MGMT_CIDR ] && [ $INTF_MGMT_IP_GW ]; then
76 if [ $INTF_MAC_MGMT ]; then
77 ETH_PORT=$(get_eth_port $INTF_MAC_MGMT)
78 elif [ "$CLOUD_DETAIL" ] && [ "$PORT_MGMT_NAME" ]; then
79 $INTF_MAC_MGMT=$(openstack --os-cloud $CLOUD_DETAIL port list | grep $PORT_MGMT_NAME | grep -o -Ei '([a-fA-F0-9:]{17}|[a-fA-F0-9]{12}$)' | head -1)
80 ETH_PORT=$(get_eth_port $INTF_MAC_MGMT)
84 if [ -z "$ETH_PORT" ]; then
85 echo "ERROR: Cannot find eth port for management port" >&2
86 logger "NFVBENCHVM ERROR: Cannot find eth port for management port"
90 # By default, configure the MTU of the management interface to the
91 # conservative value of 1500: this will reduce the risk to get an
92 # unmanageable VM in some setups.
94 # To set the MTU to a different value, configure the INTF_MGMT_MTU variable
95 # in /etc/nfvbenchvm.conf. If INTF_MGMT_MTU is set to the special value
96 # "auto", the MTU will not be configured and it will keep the value set by
97 # the hypervisor ("legacy" nfvbenchvm behavior). If INTF_MGMT_MTU is unset,
98 # the MTU will be set to 1500. In other cases, the MTU will be set to the
99 # value of INTF_MGMT_MTU.
101 if [[ -z "$INTF_MGMT_MTU" ]]; then
102 ip link set $ETH_PORT mtu 1500
103 elif [[ "$INTF_MGMT_MTU" != "auto" ]]; then
104 ip link set $ETH_PORT mtu $INTF_MGMT_MTU
107 ip addr add $INTF_MGMT_CIDR dev $ETH_PORT
108 ip link set $ETH_PORT up
109 ip route add default via $INTF_MGMT_IP_GW dev $ETH_PORT
111 echo "INFO: VM management IP Addresses missing in $NFVBENCH_CONF"
114 /nfvbench/configure-nfvbench.sh
117 /nfvbench/start-nfvbench.sh $ACTION
119 /nfvbench/start-nfvbench.sh