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/bmcdump/scripts/package b/dump/tools/bmcdump/scripts/package
index aec48c9..00dcb81 100644
--- a/dump/tools/bmcdump/scripts/package
+++ b/dump/tools/bmcdump/scripts/package
@@ -31,6 +31,8 @@
return "$INTERNAL_FAILURE"
fi
+ get_originator_details "bmc"
+
echo "Adding Dump Header :"$HEADER_EXTENSION
("$HEADER_EXTENSION")
diff --git a/dump/tools/common/include/gendumpheader b/dump/tools/common/include/gendumpheader
index 201c08a..d83ce20 100644
--- a/dump/tools/common/include/gendumpheader
+++ b/dump/tools/common/include/gendumpheader
@@ -50,6 +50,31 @@
printf '%*s' $a | tr ' ' "\0" >> $FILE
}
+# Function to add Originator details to dump header
+function add_originator_details() {
+ if [ -z "$ORIGINATOR_TYPE" ]; then
+ add_null 4
+ else
+ len=${#ORIGINATOR_TYPE}
+ nulltoadd=$(( SIZE_4 - len ))
+ printf '%s' "$ORIGINATOR_TYPE" >> "$FILE"
+ if [ "$nulltoadd" -gt 0 ]; then
+ add_null "$nulltoadd"
+ fi
+ fi
+
+ if [ -z "$ORIGINATOR_ID" ]; then
+ add_null 32
+ else
+ len=${#ORIGINATOR_ID}
+ nulltoadd=$(( SIZE_32 - len ))
+ printf '%s' "$ORIGINATOR_ID" >> "$FILE"
+ if [ "$nulltoadd" -gt 0 ]; then
+ add_null "$nulltoadd"
+ fi
+ fi
+}
+
#Function to is to convert the EPOCHTIME collected
#from dreport into hex values and write the same in
#header.
@@ -376,7 +401,9 @@
add_null 2 # SRC size
add_null 320 # SRC dump
getbmc_serial
- add_null 68 # Dump requester details
+ # Dump requester/Originator details
+ add_originator_details
+ add_null 32 # Dump Req user ID
}
#Function to add Dump entry, consists of below entries
@@ -546,4 +573,4 @@
get_bmc_model_serial_number
#Run gen_header_package
-gen_header_package
\ No newline at end of file
+gen_header_package
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
+}
diff --git a/dump/tools/opdump/opdreport b/dump/tools/opdump/opdreport
index 7fc43db..92a7ce9 100644
--- a/dump/tools/opdump/opdreport
+++ b/dump/tools/opdump/opdreport
@@ -73,6 +73,9 @@
declare -x dump_content_type=""
declare -x FILE=""
+#Source opdreport common functions
+. $DREPORT_INCLUDE/opfunctions
+
# @brief Get serial number property from inventory
function fetch_serial_number() {
serialNo=$(busctl get-property "$INVENTORY_MANAGER" "$INVENTORY_PATH" \
@@ -109,6 +112,8 @@
dump_size=$UNLIMITED
fi
+ get_originator_details "system"
+
return "$SUCCESS"
}