Skip to content

Commit

Permalink
fby2: update server type separately when hot-service (#694)
Browse files Browse the repository at this point in the history
Summary:
1. as title, since has used separated server type files (ie. /tmp/server_type*.bin) to avoid race condition.
Pull Request resolved: facebookexternal/openbmc.quanta#694

Test Plan: 1. hot-service TL+TL, TL+GP, EP+EP, and then check server type

Reviewed By: benwei13

fbshipit-source-id: f5ef40391
  • Loading branch information
benwei13 authored and facebook-github-bot committed Oct 31, 2018
1 parent 0d4e414 commit f01fd50
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,60 @@

. /usr/local/fbpackages/utils/ast-functions

if [ "$#" -eq 1 ]; then
case $1 in
slot1)
SLOT=(1)
;;
slot2)
SLOT=(2)
;;
slot3)
SLOT=(3)
;;
slot4)
SLOT=(4)
;;
*)
exit 1
;;
esac
else
SLOT=(1 2 3 4)
fi

TL_PRODUCT_ID0=39
TL_PRODUCT_ID1=30
RC_PRODUCT_ID0=43
RC_PRODUCT_ID1=52
EP_PRODUCT_ID0=50
EP_PRODUCT_ID1=45
TL_PRODUCT_ID0=39
TL_PRODUCT_ID1=30

j=0
max_retry=3
for i in 1 2 3 4
do
slot_12v=$(is_slot_12v_on $i)
server_type=3
if [[ $(is_server_prsnt $i) == "1" && "$slot_12v" == "1" && $(get_slot_type $i) == "0" ]] ; then

for (( i=0; i<${#SLOT[@]}; i++ )); do
slot_id=${SLOT[$i]}
slot_12v=$(is_slot_12v_on $slot_id)
if [ $(is_server_prsnt $slot_id) != "1" ]; then
server_type=3
elif [[ "$slot_12v" == "1" && $(get_slot_type $slot_id) == "0" ]]; then
j=0
while [ ${j} -lt ${max_retry} ]
do
while [ ${j} -lt ${max_retry} ]; do
# Use standard IPMI command 'get-device-id' to read product id of server board
output=$(/usr/bin/bic-util slot$i 0x18 0x01)
output=$(/usr/bin/bic-util slot$slot_id 0x18 0x01)
# if the command fails and the number of retry times reach max retry, continue to next slot
if [ $(echo $output | wc -c) == 45 ] ; then
if [ $(echo $output | wc -c) == 45 ]; then
product_id_l=`echo "$output" | cut -c 28-29`
product_id_h=`echo "$output" | cut -c 31-32`
if [[ "$product_id_l" == "$RC_PRODUCT_ID0" && "$product_id_h" == "$RC_PRODUCT_ID1" ]] ; then
if [[ "$product_id_l" == "$TL_PRODUCT_ID0" && "$product_id_h" == "$TL_PRODUCT_ID1" ]]; then
#TL
server_type=0
elif [[ "$product_id_l" == "$RC_PRODUCT_ID0" && "$product_id_h" == "$RC_PRODUCT_ID1" ]]; then
#RC
server_type=1
elif [[ "$product_id_l" == "$EP_PRODUCT_ID0" && "$product_id_h" == "$EP_PRODUCT_ID1" ]] ; then
elif [[ "$product_id_l" == "$EP_PRODUCT_ID0" && "$product_id_h" == "$EP_PRODUCT_ID1" ]]; then
#EP
server_type=2
elif [[ "$product_id_l" == "$TL_PRODUCT_ID0" && "$product_id_h" == "$TL_PRODUCT_ID1" ]] ; then
#TL
server_type=0
else
#unknown
server_type=3
Expand All @@ -61,13 +83,12 @@ do
sleep 1
j=$(($j+1))
done
elif [ "$slot_12v" == "1" || ! -f "/tmp/server_type$slot_id.bin" ]; then
server_type=3
else
# Do not replace slotX server type when it is 12V off
if [[ "$slot_12v" == "0" && -f "/tmp/server_type$i.bin" ]] ; then
server_type=$(get_server_type $i)
fi
continue
fi

echo "Slot$i Server Type: $server_type"
echo $server_type > /tmp/server_type$i.bin
echo "Slot$slot_id Server Type: $server_type"
echo $server_type > /tmp/server_type$slot_id.bin
done
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ case $OPTION in

# Server Type recognition restart
echo "restart server type recognition for $SLOT"
/etc/init.d/setup-server-type.sh
/usr/local/bin/check_server_type.sh $SLOT

echo "restart gpiod for $SLOT $OPTION"
sv start gpiod
Expand Down

0 comments on commit f01fd50

Please sign in to comment.