124226c4fSGopichand Paturi#!/usr/bin/env bash 224226c4fSGopichand Paturi 30d72381fSGopichand Paturideclare -rx TYPE_FAULTDATA="faultdata" 4*1bee03b8SSwarnendu-R-C#Dump originator variables 5*1bee03b8SSwarnendu-R-Cdeclare -x ORIGINATOR_TYPE="" 6*1bee03b8SSwarnendu-R-Cdeclare -x ORIGINATOR_ID="" 70d72381fSGopichand Paturi 824226c4fSGopichand Paturi# @brief fetch serial number 924226c4fSGopichand Paturi# @param serial number 1024226c4fSGopichand Paturifunction fetch_serial_number() { 1124226c4fSGopichand Paturi serialNo=$(busctl get-property xyz.openbmc_project.Inventory.Manager \ 1224226c4fSGopichand Paturi /xyz/openbmc_project/inventory/system xyz.openbmc_project.Inventory.Decorator.Asset \ 1324226c4fSGopichand Paturi SerialNumber | cut -d " " -f 2 | sed "s/^\(\"\)\(.*\)\1\$/\2/g") 1424226c4fSGopichand Paturi 1524226c4fSGopichand Paturi if [ -z "$serialNo" ]; then 1624226c4fSGopichand Paturi serialNo="0000000" 1724226c4fSGopichand Paturi fi 1824226c4fSGopichand Paturi} 1924226c4fSGopichand Paturi 2024226c4fSGopichand Paturi# @brief Add BMC dump File Name 2124226c4fSGopichand Paturi# @param BMC Dump File Name 2224226c4fSGopichand Paturifunction get_bmc_dump_filename() { 2324226c4fSGopichand Paturi fetch_serial_number 249a39f43dSSwethaParasa dump_id=$(printf %08d $dump_id) 2524226c4fSGopichand Paturi if [ $dump_type = "$TYPE_FAULTDATA" ]; then 2624226c4fSGopichand Paturi header_dump_name="FLTDUMP" 2724226c4fSGopichand Paturi name="NAGDUMP.${serialNo}.${dump_id}.${dDay}" 2824226c4fSGopichand Paturi else 2924226c4fSGopichand Paturi header_dump_name="BMCDUMP" 3024226c4fSGopichand Paturi name="BMCDUMP.${serialNo}.${dump_id}.${dDay}" 3124226c4fSGopichand Paturi fi 3224226c4fSGopichand Paturi} 33*1bee03b8SSwarnendu-R-C 34*1bee03b8SSwarnendu-R-C# @brief Function to get the Originator details 35*1bee03b8SSwarnendu-R-C# @param Originator Type and Originator ID 36*1bee03b8SSwarnendu-R-Cfunction get_originator_details() { 37*1bee03b8SSwarnendu-R-C if [ -z "$dump_dir" ]; then 38*1bee03b8SSwarnendu-R-C return 39*1bee03b8SSwarnendu-R-C fi 40*1bee03b8SSwarnendu-R-C 41*1bee03b8SSwarnendu-R-C dump_type_received="" 42*1bee03b8SSwarnendu-R-C dump_entry_id="$dump_id" 43*1bee03b8SSwarnendu-R-C 44*1bee03b8SSwarnendu-R-C if [ "$1" = "bmc" ] || [ "$1" = "system" ]; then 45*1bee03b8SSwarnendu-R-C dump_type_received="$1" 46*1bee03b8SSwarnendu-R-C else 47*1bee03b8SSwarnendu-R-C echo "Invalid dump type received" 48*1bee03b8SSwarnendu-R-C return 49*1bee03b8SSwarnendu-R-C fi 50*1bee03b8SSwarnendu-R-C 51*1bee03b8SSwarnendu-R-C if [ "$dump_type_received" = "bmc" ]; then 52*1bee03b8SSwarnendu-R-C dump_entry_id=$(echo "$dump_entry_id" | sed "s/^0*//") 53*1bee03b8SSwarnendu-R-C fi 54*1bee03b8SSwarnendu-R-C 55*1bee03b8SSwarnendu-R-C local DBUS_DUMP_MANAGER="xyz.openbmc_project.Dump.Manager" 56*1bee03b8SSwarnendu-R-C local DBUS_DUMP_PATH="/xyz/openbmc_project/dump/$dump_type_received/entry/$dump_entry_id" 57*1bee03b8SSwarnendu-R-C local DBUS_DUMP_ORIGINATOR_IFACE="xyz.openbmc_project.Common.OriginatedBy" 58*1bee03b8SSwarnendu-R-C local DBUS_ORIGINATOR_TYPE_STRING="OriginatorType" 59*1bee03b8SSwarnendu-R-C local DBUS_ORIGINATOR_ID_STRING="OriginatorId" 60*1bee03b8SSwarnendu-R-C 61*1bee03b8SSwarnendu-R-C ORIGINATOR_TYPE=$(busctl get-property "$DBUS_DUMP_MANAGER" \ 62*1bee03b8SSwarnendu-R-C "$DBUS_DUMP_PATH" "$DBUS_DUMP_ORIGINATOR_IFACE" \ 63*1bee03b8SSwarnendu-R-C "$DBUS_ORIGINATOR_TYPE_STRING") 64*1bee03b8SSwarnendu-R-C 65*1bee03b8SSwarnendu-R-C ORIGINATOR_ID=$(busctl get-property "$DBUS_DUMP_MANAGER" \ 66*1bee03b8SSwarnendu-R-C "$DBUS_DUMP_PATH" "$DBUS_DUMP_ORIGINATOR_IFACE" \ 67*1bee03b8SSwarnendu-R-C "$DBUS_ORIGINATOR_ID_STRING") 68*1bee03b8SSwarnendu-R-C 69*1bee03b8SSwarnendu-R-C # The following two lines would extract the originator type and id 70*1bee03b8SSwarnendu-R-C # from the received long string in response of the above dbus calls 71*1bee03b8SSwarnendu-R-C # like <s "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Internal"> 72*1bee03b8SSwarnendu-R-C # to only <Internal> for the originator type and so on for the originator ID 73*1bee03b8SSwarnendu-R-C ORIGINATOR_TYPE=$(echo "$ORIGINATOR_TYPE" | cut -d' ' -f 2 \ 74*1bee03b8SSwarnendu-R-C | cut -d'.' -f 6 | cut -d'"' -f 1) 75*1bee03b8SSwarnendu-R-C 76*1bee03b8SSwarnendu-R-C ORIGINATOR_ID=$(echo "$ORIGINATOR_ID" | cut -d' ' -f 2 \ 77*1bee03b8SSwarnendu-R-C | cut -d'"' -f 2) 78*1bee03b8SSwarnendu-R-C 79*1bee03b8SSwarnendu-R-C # This hash map for Originator Type is populated based on 80*1bee03b8SSwarnendu-R-C # the info provided by the OriginatedBy.interface.yaml file under 81*1bee03b8SSwarnendu-R-C # https://github.com/openbmc/phosphor-dbus-interfaces/ 82*1bee03b8SSwarnendu-R-C # Feel free to amend the table as per the evolving requirement 83*1bee03b8SSwarnendu-R-C local -A originator_type_enum_map 84*1bee03b8SSwarnendu-R-C originator_type_enum_map["Client"]=0 85*1bee03b8SSwarnendu-R-C originator_type_enum_map["Internal"]=1 86*1bee03b8SSwarnendu-R-C originator_type_enum_map["SupportingService"]=2 87*1bee03b8SSwarnendu-R-C 88*1bee03b8SSwarnendu-R-C local originator_type_mapped="$ORIGINATOR_TYPE" 89*1bee03b8SSwarnendu-R-C # If the originator type comes something which is not known to 90*1bee03b8SSwarnendu-R-C # the enum list/map then make it blank so that can be filled 91*1bee03b8SSwarnendu-R-C # with null bytes in gendumpheader script and won't be 92*1bee03b8SSwarnendu-R-C # breaking the dump extraction 93*1bee03b8SSwarnendu-R-C ORIGINATOR_TYPE="" 94*1bee03b8SSwarnendu-R-C for key in "${!originator_type_enum_map[@]}" 95*1bee03b8SSwarnendu-R-C do 96*1bee03b8SSwarnendu-R-C if [ "$key" = "$originator_type_mapped" ]; then 97*1bee03b8SSwarnendu-R-C ORIGINATOR_TYPE="${originator_type_enum_map[$key]}" 98*1bee03b8SSwarnendu-R-C break 99*1bee03b8SSwarnendu-R-C fi 100*1bee03b8SSwarnendu-R-C done 101*1bee03b8SSwarnendu-R-C} 102