blob: b1bc46e6fdb7c6e78ac6107420cb8367d409dc97 [file] [log] [blame]
George Hungfd8041e2020-07-20 21:02:11 +08001#!/bin/bash
2
3SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
George Hungcad17882020-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"
George Hunge7588f82021-04-15 15:45:02 +080013"/xyz/openbmc_project/inventory/system/chassis/entity/pe_slot1_prsnt"
George Hung65cba582021-07-29 18:35:22 +080014"/xyz/openbmc_project/inventory/system/chassis/entity/fans_efuse_pg"
15"/xyz/openbmc_project/inventory/system/chassis/entity/pwrgd_p12v_slots")
George Hungfd8041e2020-07-20 21:02:11 +080016INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
17
18IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
19IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
20IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
21IPMI_LOG_FUNCT="IpmiSelAdd"
22IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16
23LOG_ERR="Configuration Error(Incorrect_interconnection)"
24LOG_EVENT_DATA="3 0x01 0xff 0xfe"
25LOG_ASSERT_FLAG="true"
26LOG_DEASSERT_FLAG="false"
27LOG_GENID_FLAG="0x0020"
George Hung65cba582021-07-29 18:35:22 +080028present_state=("true" "true" "true" "true" "true" "true" "true" "true" "true" "true" "true" "true")
George Hungfd8041e2020-07-20 21:02:11 +080029
Patrick Williams8c226232023-04-15 20:05:21 -050030for i in "${!PRESENT_OBJPATH[@]}"
Brandon Kimb9a86732021-03-29 18:01:40 -070031do
Patrick Williams8c226232023-04-15 20:05:21 -050032 mapper wait "${PRESENT_OBJPATH[$i]}"
Brandon Kimb9a86732021-03-29 18:01:40 -070033done
34
George Hungfd8041e2020-07-20 21:02:11 +080035while true; do
Patrick Williams8c226232023-04-15 20:05:21 -050036 for i in "${!PRESENT_OBJPATH[@]}"
George Hungfd8041e2020-07-20 21:02:11 +080037 do
Patrick Williams8c226232023-04-15 20:05:21 -050038 boot_status="$(busctl get-property $SERVICE_NAME "${PRESENT_OBJPATH[$i]}" $INTERFACE_NAME Present | awk '{print $2}')"
George Hungfd8041e2020-07-20 21:02:11 +080039
Patrick Williams8c226232023-04-15 20:05:21 -050040 if [ "$boot_status" == "false" ] && [ "${present_state[$i]}" == "true" ];then
41 echo "Update cable $((i+1)) state."
42 present_state[i]="false"
43 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
44 elif [ "$boot_status" == "true" ] && [ "${present_state[$i]}" == "false" ];then
45 echo "Update cable $((i+1)) state."
46 present_state[i]="true"
47 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 Hungfd8041e2020-07-20 21:02:11 +080048 fi
49 done
50 sleep 1
51done
52
53exit 0