-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaz_check_an_init.sh
executable file
·48 lines (45 loc) · 1.61 KB
/
az_check_an_init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
# check for failover sriov pairing to detect if accelnet is up in az vm
# runs for 10 minutes
# author: Matthew G. McGovern mamcgove @ microsoft dotcom
VIRTUAL_NETDEV=$(ls /sys/devices/virtual/net/)
ALL_NETDEV=$(ls /sys/class/net)
NONVIRTUAL_NETDEV=$(echo "$ALL_NETDEV" | grep -v "$VIRTUAL_NETDEV")
DEVICE_PAIRS=""
for _i in 0 .. 30 ; do
for upper in $NONVIRTUAL_NETDEV; do
lowers=$(ls /sys/class/net/"$upper"/lower_*/ 2> /dev/null)
lower_exists=$(echo "$lowers" | wc -l)
if [ "$lower_exists" == "1" ] && [ -e "$lowers" ];
then
echo "found upper (failover) $upper"
for lower in $NONVIRTUAL_NETDEV; do
if [ -e /sys/class/net/"$upper"/lower_"$lower"/ ];
then
echo "Found lower $lower paired to $upper."
LOWER_UP=$(ip link show "$lower" up)
if [ -n "$LOWER_UP" ];
then
echo "Lower interface is up!"
else
echo "Warning: $lower was not reported as 'up' by ip"
fi
if [ -z "$DEVICE_PAIRS" ]; then
DEVICE_PAIRS="$upper,$lower"
else
DEVICE_PAIRS="$upper,$lower $DEVICE_PAIRS"
fi
break;
fi
done
fi;
done
sleep 20s
done;
if [ -z "$DEVICE_PAIRS" ]; then
echo "No accelerated networking pair found up after 10m!"
exit 1;
else
echo "Accelerated working interface pairs found: $DEVICE_PAIRS"
exit 0;
fi