Bad VPD Installation in dreport

Bad VPD plugin is an IBM specific plugin which collects all the
corrupted VPD files from /tmp/bad-vpd and puts it as a part of user
initiated BMC dump.

Openpower-vpd-parser makes a copy of the corrupted vpd's into
/tmp/bad-vpd at runtime, whenever there occurs a VPD ECC exception or
VPD record/keyword data exception.

Installed badvpd plugin in dreport via phosphor-debug-collector recipe.

Placed badvpd plugin in
openbmc/phosphor-debug-collector/tools/dreport/ibm.d directory as we
collect bad vpds' only when "ibm-parser" feature flag is enabled.

Tested on simics.

root@rainier:~# dreport -v
Wed Mar 3 04:43:18 UTC 2021 Name:          obmcdump_00000000_1614746598.tar.xz
Wed Mar 3 04:43:18 UTC 2021 Epochtime:     1614746598
Wed Mar 3 04:43:18 UTC 2021 ID:            00000000
Wed Mar 3 04:43:18 UTC 2021 Type:          user
Wed Mar 3 04:43:18 UTC 2021 INFO: Collected disk usage
Wed Mar 3 04:43:18 UTC 2021 INFO: Collected failed services
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected Journal pretty log
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied Memory info /proc/meminfo
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected top
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied Bad VPD /tmp/bad-vpd
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied OS release info /etc/os-release
Wed Mar 3 04:43:19 UTC 2021 INFO: No elog entries
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected inventory
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied OBMC console log /var/log/obmc-console.log
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected ip addr
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected ip link
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected PRI-Flash: U-Boot environment variables
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied GUARD Records /var/lib/phosphor-software-manager/pnor/prsv/GUARD
Wed Mar 3 04:43:19 UTC 2021 ERROR: /etc/alt_fw_env.config does not exist
Wed Mar 3 04:43:19 UTC 2021 INFO: Copied CPU info /proc/cpuinfo
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected uptime
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected BMC State
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected Chassis State
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected hostnamectl
Wed Mar 3 04:43:19 UTC 2021 INFO: Collected Host State
Adding Dump Header :/usr/share/dreport.d/include.d/gendumpheader
Wed Mar 3 04:44:08 UTC 2021 Report is available in /tmp
Wed Mar 3 04:44:08 UTC 2021 Successfully completed

Check the dump tar file generated in /tmp directory.
After skipping 628 bytes of dump header in tar, untar it.
The files in /tmp/bad-vpd directory gets collected into the bmc dump.

Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
Change-Id: Ifdbfa56b8c67263271059dbee390092b92977775
diff --git a/meta-ibm/recipes-phosphor/dump/phosphor-debug-collector_%.bbappend b/meta-ibm/recipes-phosphor/dump/phosphor-debug-collector_%.bbappend
index 96b67b0..0cbca65 100644
--- a/meta-ibm/recipes-phosphor/dump/phosphor-debug-collector_%.bbappend
+++ b/meta-ibm/recipes-phosphor/dump/phosphor-debug-collector_%.bbappend
@@ -33,7 +33,20 @@
     install -m 0755 ${S}/tools/dreport.d/ibm.d/gendumpheader ${D}${dreport_include_dir}/
 }
 
+#Install ibm bad vpd script from dreport/ibm.d to dreport/plugins.d
+install_ibm_bad_vpd() {
+    install -d ${D}${dreport_plugin_dir}
+    install -m 0755 ${S}/tools/dreport.d/ibm.d/badvpd ${D}${dreport_plugin_dir}
+}
+
+#Link in the plugins so dreport run them at the appropriate time based on the plugin type
+python link_ibm_bad_vpd() {
+    sourcedir = d.getVar('S', True)
+    script = os.path.join(sourcedir, "tools", "dreport.d", "ibm.d", "badvpd")
+    install_dreport_user_script(script, d)
+}
+
 IBM_INSTALL_POSTFUNCS = "install_ibm_plugins link_ibm_plugins"
-IBM_INSTALL_POSTFUNCS_p10bmc += "install_dreport_header"
+IBM_INSTALL_POSTFUNCS_p10bmc += "install_dreport_header install_ibm_bad_vpd link_ibm_bad_vpd"
 
 do_install[postfuncs] += "${IBM_INSTALL_POSTFUNCS}"