summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarri Devender Rao <devenrao@in.ibm.com>2017-10-11 02:22:46 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-10-26 12:18:13 +0000
commitb6e5cb092da59fdc0fd6f4ca9deba053db7a0524 (patch)
treea2945ef5546ac73756cf03d656bcef8f9c723139
parentd425b7646d2f39f145444a014153198871794ac2 (diff)
downloadtalos-openbmc-b6e5cb092da59fdc0fd6f4ca9deba053db7a0524.tar.gz
talos-openbmc-b6e5cb092da59fdc0fd6f4ca9deba053db7a0524.zip
Enable support for usecase specific bash script invocation
Resolves openbmc/openbmc#2037 Install dreport, dreport.conf, plugins Parse the scripts to fetch config value Create user directories based on config value with softlinks to the plugins Change-Id: If1bdefca362a282132364306b26eecb4b7003390 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
-rw-r--r--meta-phosphor/classes/phosphor-debug-collector.bbclass4
-rw-r--r--meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb99
-rw-r--r--meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.inc2
-rw-r--r--meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb1
4 files changed, 101 insertions, 5 deletions
diff --git a/meta-phosphor/classes/phosphor-debug-collector.bbclass b/meta-phosphor/classes/phosphor-debug-collector.bbclass
index 2a2a3a415..d5d49a2db 100644
--- a/meta-phosphor/classes/phosphor-debug-collector.bbclass
+++ b/meta-phosphor/classes/phosphor-debug-collector.bbclass
@@ -1 +1,5 @@
bmc_dump_path="/var/lib/phosphor-debug-collector/dumps"
+dreport_plugin_dir = "${datadir}/dreport.d/plugins.d"
+dreport_include_dir = "${datadir}/dreport.d/include.d"
+dreport_conf_dir = "${datadir}/dreport.d/conf.d"
+dreport_dir = "${datadir}/dreport.d/"
diff --git a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
index c29c16ab4..24b233f85 100644
--- a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
+++ b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.bb
@@ -10,6 +10,7 @@ DEBUG_COLLECTOR_PKGS = " \
${PN}-manager \
${PN}-monitor \
${PN}-dreport \
+ ${PN}-scripts \
"
PACKAGES =+ "${DEBUG_COLLECTOR_PKGS}"
PACKAGES_remove = "${PN}"
@@ -54,6 +55,9 @@ RDEPENDS_${PN}-dreport += " \
bash \
xz \
"
+RDEPENDS_${PN}-scripts += " \
+ bash \
+"
MGR_SVC ?= "xyz.openbmc_project.Dump.Manager.service"
@@ -62,6 +66,7 @@ SYSTEMD_SUBSTITUTIONS += "BMC_DUMP_PATH:${bmc_dump_path}:${MGR_SVC}"
FILES_${PN}-manager += "${sbindir}/phosphor-dump-manager"
FILES_${PN}-monitor += "${sbindir}/phosphor-dump-monitor"
FILES_${PN}-dreport += "${bindir}/dreport"
+FILES_${PN}-scripts += "${dreport_dir}"
DBUS_SERVICE_${PN}-manager += "${MGR_SVC}"
SYSTEMD_SERVICE_${PN}-monitor += "obmc-dump-monitor.service"
@@ -70,10 +75,90 @@ EXTRA_OECONF = "BMC_DUMP_PATH=${bmc_dump_path}"
S = "${WORKDIR}/git"
-do_install_append() {
- install -d ${D}${bindir}
- install -m 0755 ${S}/tools/dreport \
- ${D}${bindir}/dreport
+# Install dreport script
+# From tools/dreport.d/dreport to /usr/bin/dreport
+install_dreport() {
+ install -d ${D}${bindir}
+ install -m 0755 ${S}/tools/dreport.d/dreport \
+ ${D}${bindir}/dreport
+}
+
+# Install dreport sample configuration file
+# From tools/dreport.d/sample.conf
+# to /usr/share/dreport.d/conf.d/dreport.conf
+install_dreport_conf_file() {
+ install -d ${D}${dreport_conf_dir}
+ install -m 0644 ${S}/tools/dreport.d/sample.conf \
+ ${D}${dreport_conf_dir}/dreport.conf
+}
+
+# Install dreport plugins
+# From tools/dreport.d/plugins.d to /usr/share/dreport.d/plugins.d
+install_dreport_plugins_scripts() {
+ install -d ${D}${dreport_plugin_dir}
+ install -m 0755 ${S}/tools/dreport.d/plugins.d/* ${D}${dreport_plugin_dir}/
+}
+
+# Install dreport utility functions
+# From tools/dreport.d/include.d to /usr/share/dreport.d/include.d
+install_dreport_include_scripts() {
+ install -d ${D}${dreport_include_dir}
+ install -m 0755 ${S}/tools/dreport.d/include.d/* \
+ ${D}${dreport_include_dir}/
+}
+
+# Parse the scripts in base directory, read config value
+# Create user directories based on the dump type value in the config section
+# Create softlinks for the base scripts in the user directories
+python install_dreport_user_scripts() {
+ from shutil import copyfile
+ import stat
+ import re
+ import configparser
+
+ #Read the user types from the dreport.conf file
+ configure = configparser.ConfigParser()
+ conf_dir = d.getVar('D', True) + d.getVar('dreport_conf_dir', True)
+ confsource = os.path.join(conf_dir, "dreport.conf")
+ configure.read(confsource)
+ section = "DumpType"
+ options = configure.options(section)
+
+ #open the script from base dir and read the config value
+ source = d.getVar('S', True)
+ source_path = os.path.join(source, "tools", "dreport.d", "plugins.d")
+ scripts = os.listdir(source_path)
+ dreport_dir= d.getVar('D', True) + d.getVar('dreport_dir', True)
+ config = ("config:")
+ for script in scripts:
+ srcname = os.path.join(source_path, script)
+ srclink = os.path.join(d.getVar('dreport_plugin_dir', True), script)
+ file = open(srcname, "r")
+ for line in file:
+ if not config in line:
+ continue
+ revalue = re.search('[0-9]+.[0-9]+', line)
+ if not revalue:
+ bb.warn("Invalid format for config value =%s" % line)
+ continue
+ parse_value = revalue.group(0)
+ config_values = re.split('\W+', parse_value, 1)
+ if(len(config_values) != 2):
+ bb.warn("Invalid config value=%s" % parse_value)
+ break;
+ priority = config_values[1]
+ types = [int(d) for d in str(config_values[0])]
+ for type in types:
+ if not configure.has_option(section, str(type)):
+ bb.warn("Invalid dump type id =%s" % (str(type)))
+ continue
+ typestr = configure.get(section, str(type))
+ destdir = os.path.join(dreport_dir, ("pl_" + typestr + ".d"))
+ if not os.path.exists(destdir):
+ os.makedirs(destdir)
+ linkname = "E" + priority + script
+ destlink = os.path.join(destdir, linkname)
+ os.symlink(srclink, destlink)
}
#Enable ubifs-workaround by MACHINE_FEATURE obmc-ubi-fs.
@@ -82,3 +167,9 @@ PACKAGECONFIG[ubifs-workaround] = " \
--enable-ubifs-workaround, \
--disable-ubifs-workaround \
"
+
+do_install[postfuncs] += "install_dreport"
+do_install[postfuncs] += "install_dreport_conf_file"
+do_install[postfuncs] += "install_dreport_plugins_scripts"
+do_install[postfuncs] += "install_dreport_include_scripts"
+do_install[postfuncs] += "install_dreport_user_scripts"
diff --git a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.inc b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.inc
index 8fd608b7d..d5f4af280 100644
--- a/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.inc
+++ b/meta-phosphor/common/recipes-phosphor/dump/phosphor-debug-collector.inc
@@ -2,4 +2,4 @@ HOMEPAGE = "https://github.com/openbmc/phosphor-debug-collector"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
SRC_URI += "git://github.com/openbmc/phosphor-debug-collector"
-SRCREV = "7f2f8027b013c39e28da6b3e1e10f6ddc7d3d042"
+SRCREV = "11eaab7b68d7984199a283bc6c78617ce72b8ca6"
diff --git a/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb b/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
index 50f906565..788bd483a 100644
--- a/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
+++ b/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
@@ -94,6 +94,7 @@ RDEPENDS_${PN}-debug-collector = " \
${VIRTUAL-RUNTIME_obmc-dump-manager} \
${VIRTUAL-RUNTIME_obmc-dump-monitor} \
phosphor-debug-collector-dreport \
+ phosphor-debug-collector-scripts \
"
SUMMARY_${PN}-settings = "Settings applications"
OpenPOWER on IntegriCloud