George Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | SERVICE_NAME="xyz.openbmc_project.Inventory.Manager" |
George Hung | cad1788 | 2020-09-02 22:20:04 +0800 | [diff] [blame] | 4 | PRESENT_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 Hung | e7588f8 | 2021-04-15 15:45:02 +0800 | [diff] [blame^] | 13 | "/xyz/openbmc_project/inventory/system/chassis/entity/pe_slot1_prsnt" |
| 14 | "/xyz/openbmc_project/inventory/system/chassis/entity/fans_efuse_pg") |
George Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 15 | INTERFACE_NAME="xyz.openbmc_project.Inventory.Item" |
| 16 | |
| 17 | IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI" |
| 18 | IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI" |
| 19 | IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI" |
| 20 | IPMI_LOG_FUNCT="IpmiSelAdd" |
| 21 | IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16 |
| 22 | LOG_ERR="Configuration Error(Incorrect_interconnection)" |
| 23 | LOG_EVENT_DATA="3 0x01 0xff 0xfe" |
| 24 | LOG_ASSERT_FLAG="true" |
| 25 | LOG_DEASSERT_FLAG="false" |
| 26 | LOG_GENID_FLAG="0x0020" |
George Hung | e7588f8 | 2021-04-15 15:45:02 +0800 | [diff] [blame^] | 27 | present_state=("true" "true" "true" "true" "true" "true" "true" "true" "true" "true" "true") |
George Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 28 | |
Brandon Kim | b9a8673 | 2021-03-29 18:01:40 -0700 | [diff] [blame] | 29 | for i in ${!PRESENT_OBJPATH[@]} |
| 30 | do |
| 31 | mapper wait ${PRESENT_OBJPATH[$i]} |
| 32 | done |
| 33 | |
George Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 34 | while true; do |
| 35 | for i in ${!PRESENT_OBJPATH[@]} |
| 36 | do |
George Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 37 | boot_status="$(busctl get-property $SERVICE_NAME ${PRESENT_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')" |
| 38 | |
| 39 | if [ $boot_status == "false" ] && [ ${present_state[$i]} == "true" ];then |
| 40 | echo "Update cable $(($i+1)) state." |
| 41 | present_state[$i]="false" |
George Hung | cad1788 | 2020-09-02 22:20:04 +0800 | [diff] [blame] | 42 | 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 Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 43 | elif [ $boot_status == "true" ] && [ ${present_state[$i]} == "false" ];then |
| 44 | echo "Update cable $(($i+1)) state." |
| 45 | present_state[$i]="true" |
George Hung | cad1788 | 2020-09-02 22:20:04 +0800 | [diff] [blame] | 46 | 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 Hung | fd8041e | 2020-07-20 21:02:11 +0800 | [diff] [blame] | 47 | fi |
| 48 | done |
| 49 | sleep 1 |
| 50 | done |
| 51 | |
| 52 | exit 0 |