gendumpheader: Originator details info added
There are two parameters available for each dump,
Originator ID and Originator Type. This change
aims to include these fields into the BMC dump
header.
If for any reason either the originator ID or
originator type or both are unavailable then
they are been replaced by their allocated null
bytes.
Test Results:
Tested on generated BMC dumps and verified.
Signed-off-by: Swarnendu Roy Chowdhury <swarnendu.roy.chowdhury@ibm.com>
Signed-off-by: Gopichand Paturi <gopichandpaturi@gmail.com>
Change-Id: I611cce4f19aaef13c3ee68c16cf7b4fb2f841591
diff --git a/dump/tools/common/include/opfunctions b/dump/tools/common/include/opfunctions
index 5b6acda..6469652 100644
--- a/dump/tools/common/include/opfunctions
+++ b/dump/tools/common/include/opfunctions
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
declare -rx TYPE_FAULTDATA="faultdata"
+#Dump originator variables
+declare -x ORIGINATOR_TYPE=""
+declare -x ORIGINATOR_ID=""
# @brief fetch serial number
# @param serial number
@@ -27,3 +30,72 @@
name="BMCDUMP.${serialNo}.${dump_id}.${dDay}"
fi
}
+
+# @brief Function to get the Originator details
+# @param Originator Type and Originator ID
+function get_originator_details() {
+ if [ -z "$dump_dir" ]; then
+ return
+ fi
+
+ dump_type_received=""
+ dump_entry_id="$dump_id"
+
+ if [ "$1" = "bmc" ] || [ "$1" = "system" ]; then
+ dump_type_received="$1"
+ else
+ echo "Invalid dump type received"
+ return
+ fi
+
+ if [ "$dump_type_received" = "bmc" ]; then
+ dump_entry_id=$(echo "$dump_entry_id" | sed "s/^0*//")
+ fi
+
+ local DBUS_DUMP_MANAGER="xyz.openbmc_project.Dump.Manager"
+ local DBUS_DUMP_PATH="/xyz/openbmc_project/dump/$dump_type_received/entry/$dump_entry_id"
+ local DBUS_DUMP_ORIGINATOR_IFACE="xyz.openbmc_project.Common.OriginatedBy"
+ local DBUS_ORIGINATOR_TYPE_STRING="OriginatorType"
+ local DBUS_ORIGINATOR_ID_STRING="OriginatorId"
+
+ ORIGINATOR_TYPE=$(busctl get-property "$DBUS_DUMP_MANAGER" \
+ "$DBUS_DUMP_PATH" "$DBUS_DUMP_ORIGINATOR_IFACE" \
+ "$DBUS_ORIGINATOR_TYPE_STRING")
+
+ ORIGINATOR_ID=$(busctl get-property "$DBUS_DUMP_MANAGER" \
+ "$DBUS_DUMP_PATH" "$DBUS_DUMP_ORIGINATOR_IFACE" \
+ "$DBUS_ORIGINATOR_ID_STRING")
+
+ # The following two lines would extract the originator type and id
+ # from the received long string in response of the above dbus calls
+ # like <s "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Internal">
+ # to only <Internal> for the originator type and so on for the originator ID
+ ORIGINATOR_TYPE=$(echo "$ORIGINATOR_TYPE" | cut -d' ' -f 2 \
+ | cut -d'.' -f 6 | cut -d'"' -f 1)
+
+ ORIGINATOR_ID=$(echo "$ORIGINATOR_ID" | cut -d' ' -f 2 \
+ | cut -d'"' -f 2)
+
+ # This hash map for Originator Type is populated based on
+ # the info provided by the OriginatedBy.interface.yaml file under
+ # https://github.com/openbmc/phosphor-dbus-interfaces/
+ # Feel free to amend the table as per the evolving requirement
+ local -A originator_type_enum_map
+ originator_type_enum_map["Client"]=0
+ originator_type_enum_map["Internal"]=1
+ originator_type_enum_map["SupportingService"]=2
+
+ local originator_type_mapped="$ORIGINATOR_TYPE"
+ # If the originator type comes something which is not known to
+ # the enum list/map then make it blank so that can be filled
+ # with null bytes in gendumpheader script and won't be
+ # breaking the dump extraction
+ ORIGINATOR_TYPE=""
+ for key in "${!originator_type_enum_map[@]}"
+ do
+ if [ "$key" = "$originator_type_mapped" ]; then
+ ORIGINATOR_TYPE="${originator_type_enum_map[$key]}"
+ break
+ fi
+ done
+}