dreport: Collect IBM error objects on IBM systems

Add a plugin for systems in the meta-ibm layer
to collect the com.ibm.Logging objects in a dump.

Resolves openbmc/openbmc#3043

Tested: Run dreport and check that the IBM data is there.

Change-Id: Iaa01a07633265c767649caaf8b9b1580f31ce7cd
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/recipes-phosphor/dump/phosphor-debug-collector.bbappend b/recipes-phosphor/dump/phosphor-debug-collector.bbappend
new file mode 100644
index 0000000..402e4fa
--- /dev/null
+++ b/recipes-phosphor/dump/phosphor-debug-collector.bbappend
@@ -0,0 +1,21 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://plugins.d/ibm_elogall"
+
+install_ibm_plugins() {
+
+    install -m 0755 ${WORKDIR}/plugins.d/ibm_elogall ${D}${dreport_plugin_dir}
+
+}
+
+#Link in the plugins so dreport run them at the appropriate time
+python link_ibm_plugins() {
+
+    workdir = d.getVar('WORKDIR', True)
+    script = os.path.join(workdir, 'plugins.d', 'ibm_elogall')
+    install_dreport_user_script(script, d)
+
+}
+
+do_install[postfuncs] += "install_ibm_plugins"
+do_install[postfuncs] += "link_ibm_plugins"
diff --git a/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/ibm_elogall b/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/ibm_elogall
new file mode 100644
index 0000000..3054f23
--- /dev/null
+++ b/recipes-phosphor/dump/phosphor-debug-collector/plugins.d/ibm_elogall
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# config: 2 20
+# @brief: Get the IBM specific elog objects
+#
+
+. $DREPORT_INCLUDE/functions
+
+desc="IBM elog"
+
+entries=$(busctl --list --no-pager tree \
+                 com.ibm.Logging | grep \
+                 '/xyz/openbmc_project/logging/entry/')
+
+#check for elog entries.
+if [ -z "$entries" ]; then
+    log_info "No $desc entries"
+    exit 0
+fi
+
+command="busctl call --verbose --no-pager \
+                com.ibm.Logging \
+                /xyz/openbmc_project/logging \
+                org.freedesktop.DBus.ObjectManager \
+                GetManagedObjects"
+
+file_name="ibm_elogall.log"
+
+add_cmd_output "$command" "$file_name" "$desc"