blob: 2bbe46e848c48046cdf6190df29318a7a7cfc4b2 [file] [log] [blame]
George Hungde864a92020-07-20 21:02:11 +08001#!/bin/bash
2
3SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
George Hungc1449692020-09-02 22:20:04 +08004PRESENT_OBJPATH=("/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab0_prsnt"
5"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab1_prsnt"
6"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab2_prsnt"
7"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab3_prsnt"
8"/xyz/openbmc_project/inventory/system/chassis/cable/hsbp_cab_prsnt"
9"/xyz/openbmc_project/inventory/system/chassis/cable/fanbd_cab_prsnt"
10"/xyz/openbmc_project/inventory/system/chassis/cable/bp12v_cab_prsnt"
11"/xyz/openbmc_project/inventory/system/chassis/entity/sata0_prsnt"
12"/xyz/openbmc_project/inventory/system/chassis/entity/pe_slot0_prsnt"
13"/xyz/openbmc_project/inventory/system/chassis/entity/pe_slot1_prsnt")
George Hungde864a92020-07-20 21:02:11 +080014INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
15
16IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
17IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
18IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
19IPMI_LOG_FUNCT="IpmiSelAdd"
20IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16
21LOG_ERR="Configuration Error(Incorrect_interconnection)"
22LOG_EVENT_DATA="3 0x01 0xff 0xfe"
23LOG_ASSERT_FLAG="true"
24LOG_DEASSERT_FLAG="false"
25LOG_GENID_FLAG="0x0020"
26present_state=("true" "true" "true" "true" "true" "true" "true" "true" "true" "true")
27
28while true; do
29 for i in ${!PRESENT_OBJPATH[@]}
30 do
31 mapper wait ${PRESENT_OBJPATH[$i]}
32 boot_status="$(busctl get-property $SERVICE_NAME ${PRESENT_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')"
33
34 if [ $boot_status == "false" ] && [ ${present_state[$i]} == "true" ];then
35 echo "Update cable $(($i+1)) state."
36 present_state[$i]="false"
George Hungc1449692020-09-02 22:20:04 +080037 busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG
George Hungde864a92020-07-20 21:02:11 +080038 elif [ $boot_status == "true" ] && [ ${present_state[$i]} == "false" ];then
39 echo "Update cable $(($i+1)) state."
40 present_state[$i]="true"
George Hungc1449692020-09-02 22:20:04 +080041 busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
George Hungde864a92020-07-20 21:02:11 +080042 fi
43 done
44 sleep 1
45done
46
47exit 0