Fix for Verify BMC Version From PEL
Changes:
Fix for test to verify PEL content if only expected
PEL with the given message error type is created
Testing:
Tested test_bmc_pel.robot successfully on BMC environment
Change-Id: I29ac160de6d5f63f6ff45cbedfef6951d2c79c22
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/pel_utils.py b/lib/pel_utils.py
index 58222e5..389dee6 100644
--- a/lib/pel_utils.py
+++ b/lib/pel_utils.py
@@ -330,3 +330,40 @@
pel_data = peltool("-lr")
pel_ids = list(pel_data.keys())
return pel_ids[:number_of_pels]
+
+
+def fetch_all_pel_ids_based_on_error_message(
+ error_msg, include_hidden_pels=False, include_informational_pels=False
+):
+ r"""
+ Fetch all PEL IDs based on the input error message and return
+ in the list format.
+
+ Description of arguments:
+ error_msg Error message
+ include_hidden_pels True/False (default: False).
+ Set True to get hidden PELs else False.
+ include_informational_pels True/False (default: False).
+ Set True to get informational PELs else False
+ """
+
+ try:
+ err_pel_ids = []
+ pel_data = get_pel_data_from_bmc(
+ include_hidden_pels, include_informational_pels
+ )
+ pel_id_list = pel_data.keys()
+ for pel_id in pel_id_list:
+ # Check if required PEL with error message is created.
+ if error_msg in pel_data[pel_id]["Message"]:
+ err_pel_ids.append(pel_id)
+
+ if not err_pel_ids:
+ raise PeltoolException(
+ "Failed to get PEL ID with error message : " + error_msg
+ )
+ except Exception as exception:
+ raise PeltoolException(
+ "Failed to fetch PEL ID for required SRC : " + str(exception)
+ ) from exception
+ return err_pel_ids
diff --git a/openpower/pel/test_bmc_pel.robot b/openpower/pel/test_bmc_pel.robot
index 492d6e1..7ec00da 100644
--- a/openpower/pel/test_bmc_pel.robot
+++ b/openpower/pel/test_bmc_pel.robot
@@ -89,9 +89,8 @@
Create Test PEL Log
- ${pel_ids}= Get PEL Log Via BMC CLI
- ${pel_id}= Get From List ${pel_ids} -1
- ${pel_output}= Peltool -i ${pel_id}
+ ${pel_ids}= Fetch All Pel Ids Based On Error Message test error
+ ${pel_output}= Peltool -i ${pel_ids[0]}
${pel_sections}= Get Dictionary Keys ${pel_output}
List Should Contain Sub List ${pel_sections} ${mandatory_pel_fields}
@@ -219,9 +218,8 @@
Create Test PEL Log
- ${pel_ids}= Get PEL Log Via BMC CLI
- ${id}= Get From List ${pel_ids} -1
- ${pel_bmc_version}= Get PEL Field Value ${id} User Data FW Version ID
+ ${pel_ids}= Fetch All Pel Ids Based On Error Message test error
+ ${pel_bmc_version}= Get PEL Field Value ${pel_ids[0]} User Data FW Version ID
${bmc_version}= Get BMC Version
Valid Value bmc_version ['${bmc_version}']