openpower:dreport: add guarded resolved and ephemeral records to BMC dump

1) Append GUARD blob to the dump
2) List guard records, resolved records and ephemeral records
and write to guard.log file
3) Append guard.log file to the dump

Tested:
root@ever8bmc:/tmp/test/obmcdump_00000000_1648632722# ls -lah GUARD
-r--r-----    1 root     root       20.0K Mar 30 09:32 GUARD
root@ever8bmc:/tmp/test/obmcdump_00000000_1648632722#

root@ever8bmc:/tmp/test/obmcdump_00000000_1648632722# cat guard.log
[Guard List]
ID       | ERROR    |  Type  | Path
00000001 | 00000000 | manual | physical:sys-0/node-0/proc-1/eq-0/fc-0/core-0

[Guard resolved records]
ID       | ERROR    |  Type  | Path
ffffffff | 90001220 | unrecoverable |
physical:sys-0/node-0/proc-3/pauc-3/iohs-0/smpgroup-1
ffffffff | 90001220 | unrecoverable |
physical:sys-0/node-0/proc-0/pauc-3/iohs-1/smpgroup-0
ffffffff | 90001223 | unrecoverable |
physical:sys-0/node-0/proc-3/pauc-2/iohs-1/smpgroup-1
ffffffff | 90001223 | unrecoverable |
physical:sys-0/node-0/proc-6/pauc-3/iohs-1/smpgroup-0
ffffffff | 90001224 | unrecoverable |
physical:sys-0/node-0/proc-3/pauc-2/iohs-1/smpgroup-0
ffffffff | 90001224 | unrecoverable |
physical:sys-0/node-0/proc-7/pauc-3/iohs-1/smpgroup-0
ffffffff | 900007c3 | unrecoverable |
physical:sys-0/node-0/proc-7/pauc-3/iohs-1/smpgroup-0
ffffffff | 50000527 | predictive | physical:sys-0/node-0/proc-6
ffffffff | 50000528 | predictive | physical:sys-0/node-0/proc-7
ffffffff | 50000712 | predictive |
physical:sys-0/node-0/proc-2/pauc-3/iohs-1/smpgroup-1
ffffffff | 50000712 | predictive |
physical:sys-0/node-0/proc-0/pauc-3/iohs-1/smpgroup-1

[Guard ephemeral records]

Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Change-Id: Ibd3e21a69cd98c3d1b5bee9fa8251566f04e741b
diff --git a/tools/dreport.d/openpower.d/plugins.d/guardlist b/tools/dreport.d/openpower.d/plugins.d/guardlist
new file mode 100644
index 0000000..f99d78c
--- /dev/null
+++ b/tools/dreport.d/openpower.d/plugins.d/guardlist
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# config: 234 40
+# @brief: Collect GUARD record information.
+#
+
+. $DREPORT_INCLUDE/functions
+
+desc="GUARD Records"
+guard_part_file="/media/hostfw/running/GUARD"
+
+# Check file is present and not empty.
+if [ -e "$guard_part_file" ]; then
+    add_copy_file "$guard_part_file" "GUARD partition"
+fi
+
+# collect guarded list
+guard_log_file=guard.log
+if [ -e "/usr/bin/guard" ]; then
+    add_cmd_output "echo $'\n[Guard List]'" "$guard_log_file" "guard"
+    add_cmd_output "/usr/bin/guard -l" "$guard_log_file" "guard -l"
+
+    add_cmd_output "echo $'\n[Guard resolved records]'" "$guard_log_file" "guard"
+    add_cmd_output "/usr/bin/guard -a" "$guard_log_file" "guard -a"
+
+    add_cmd_output "echo $'\n[Guard ephemeral records]'" "$guard_log_file" "guard"
+    add_cmd_output "/usr/bin/guard -e" "$guard_log_file" "guard -e"
+fi