58 lines
1.1 KiB
Bash
58 lines
1.1 KiB
Bash
#!/bin/bash
|
|
#%stage: device
|
|
#%depends: network lldpad
|
|
#%programs: fcoeadm
|
|
#%programs: fipvlan
|
|
#%programs: ip
|
|
#%programs: sed
|
|
#%programs: sleep
|
|
#%programs: vconfig
|
|
#%modules: fcoe 8021q
|
|
#%if: "$root_fcoe"
|
|
#
|
|
##### FCoE initialization
|
|
##
|
|
## This script initializes FCoE (FC over Ethernet).
|
|
|
|
load_modules
|
|
|
|
create_fcoe_vlan()
|
|
{
|
|
local if=$1
|
|
local vlan=$2
|
|
local vif=$3
|
|
|
|
vconfig add $if $vlan
|
|
tmp_vif=$(sed -n "s/\([^ ]*\).*${vlan}.*${if}/\1/p" /proc/net/vlan/config)
|
|
if [ "$vif" ] && [ "$tmp_vif" != "$vif" ] ; then
|
|
ip link set dev $tmp_vif name $vif
|
|
fi
|
|
wait_for_events
|
|
ip link set $if up
|
|
ip link set $vif up
|
|
}
|
|
|
|
wait_for_fcoe_if()
|
|
{
|
|
local ifname=$1
|
|
local retry_count=$udev_timeout
|
|
|
|
echo -n "Wait for FCoE link on $ifname: "
|
|
while [ $retry_count -gt 0 ] ; do
|
|
status=$(fcoeadm -i $ifname 2> /dev/null | sed -n "s/.*State: *\(.*\)/\1/p")
|
|
if [ "$status" = "Online" ] ; then
|
|
echo "Ok"
|
|
return 0
|
|
fi
|
|
echo -n "."
|
|
retry_count=$(($retry_count-1))
|
|
sleep 2
|
|
done
|
|
|
|
emergency "Failed!"
|
|
}
|
|
|
|
create_fcoe_vlan $fcoe_if $fcoe_vlan $fcoe_vif
|
|
fipvlan -s $fcoe_if
|
|
wait_for_fcoe_if $fcoe_vif
|