George Hung | 09b8cd9 | 2020-06-04 19:54:41 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | SERVICE_NAME="xyz.openbmc_project.Inventory.Manager" |
| 4 | SAS_CABLE_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 | INTERFACE_NAME="xyz.openbmc_project.Inventory.Item" |
| 9 | |
| 10 | IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI" |
| 11 | IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI" |
| 12 | IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI" |
| 13 | IPMI_LOG_FUNCT="IpmiSelAdd" |
| 14 | IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16 |
| 15 | LOG_ERR="Cable_error(Incorrect_interconnection)" |
| 16 | LOG_EVENT_DATA="3 0x01 0xff 0xfe" |
| 17 | LOG_ASSERT_FLAG="true" |
| 18 | LOG_DEASSERT_FLAG="false" |
| 19 | LOG_GENID_FLAG="0x0020" |
| 20 | cable_state=("true" "true" "true" "true") |
| 21 | |
| 22 | mapper wait ${SAS_CABLE_OBJPATH[0]} |
| 23 | mapper wait ${SAS_CABLE_OBJPATH[1]} |
| 24 | mapper wait ${SAS_CABLE_OBJPATH[2]} |
| 25 | mapper wait ${SAS_CABLE_OBJPATH[3]} |
| 26 | |
| 27 | while true; do |
| 28 | for i in {0..3}; |
| 29 | do |
| 30 | boot_status="$(busctl get-property $SERVICE_NAME ${SAS_CABLE_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')" |
| 31 | |
| 32 | if [ $boot_status == "false" ] && [ ${cable_state[$i]} == "true" ];then |
| 33 | echo "Update cable $(($i+1)) state." |
| 34 | cable_state[$i]="false" |
| 35 | busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG |
| 36 | elif [ $boot_status == "true" ] && [ ${cable_state[$i]} != "true" ];then |
| 37 | echo "Update cable $(($i+1)) state." |
| 38 | cable_state[$i]="true" |
| 39 | busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG |
| 40 | fi |
| 41 | done |
| 42 | sleep 1 |
| 43 | done |
| 44 | |
| 45 | exit 0 |