Merge hardcoded sensor yamls with generated sensor.yaml
This change will enable adding sensors which is not part
of the MRW to the MRW bases systems.
Change-Id: I0d7d2ff94a668ae77bb8c906e85ef6280dc49830
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host.bbappend
new file mode 100644
index 0000000..f5b39fc
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host.bbappend
@@ -0,0 +1,2 @@
+FILESEXTRAPATHS_append_witherspoon := ":${THISDIR}/${PN}"
+SRC_URI_append_witherspoon = " file://occ_sensors.hardcoded.yaml"
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host/occ_sensors.hardcoded.yaml b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host/occ_sensors.hardcoded.yaml
new file mode 100644
index 0000000..de3c840
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-host/occ_sensors.hardcoded.yaml
@@ -0,0 +1,34 @@
+0x08:
+ sensorType: 0x09
+ path: /org/open_power/control/occ0
+ sensorReadingType: 0x09
+ serviceInterface: org.freedesktop.DBus.Properties
+ readingType: assertion
+ interfaces:
+ org.open_power.OCC.Status:
+ OccActive:
+ 0x00:
+ assert: false
+ deassert: true
+ type: bool
+ 0x01:
+ assert: true
+ deassert: false
+ type: bool
+0x09:
+ sensorType: 0x09
+ path: /org/open_power/control/occ1
+ sensorReadingType: 0x09
+ serviceInterface: org.freedesktop.DBus.Properties
+ readingType: assertion
+ interfaces:
+ org.open_power.OCC.Status:
+ OccActive:
+ 0x00:
+ assert: false
+ deassert: true
+ type: bool
+ 0x01:
+ assert: true
+ deassert: false
+ type: bool
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
index f2fa39e..45cb2ee 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
@@ -52,6 +52,8 @@
S = "${WORKDIR}/git"
+SRC_URI += "file://merge_yamls.py"
+
HOSTIPMI_PROVIDER_LIBRARY += "libapphandler.so"
HOSTIPMI_PROVIDER_LIBRARY += "libsysintfcmds.so"
@@ -70,3 +72,34 @@
SOFT_TGTFMT = "obmc-host-shutdown@{0}.target"
SOFT_FMT = "../${SOFT_SVC}:${SOFT_TGTFMT}.requires/${SOFT_SVC}"
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'SOFT_FMT', 'OBMC_HOST_INSTANCES')}"
+
+#Collect all hardcoded sensor yamls from different recipes and
+#merge all of them with sensor.yaml.
+python do_merge_sensors () {
+ import subprocess
+
+ # TODO: Perform the merge in a temporary directory?
+ workdir = d.getVar('WORKDIR', True)
+ nativedir = d.getVar('STAGING_DIR_NATIVE', True)
+ sensorsdir = d.getVar('sensor_datadir', True)
+ sensorsdir = sensorsdir[1:]
+ sensorsdir = os.path.join(nativedir, sensorsdir)
+ cmd = []
+ cmd.append(os.path.join(workdir, 'merge_yamls.py'))
+ cmd.append(os.path.join(sensorsdir, 'sensor.yaml'))
+
+ if os.stat(os.path.join(sensorsdir, 'sensor.yaml')).st_size == 0:
+ return
+ fetch = bb.fetch2.Fetch([], d)
+ override_urls = filter(lambda f: f.endswith('.hardcoded.yaml'), fetch.urls)
+ for url in override_urls:
+ bb.debug(2, 'Overriding with source: ' + url)
+ local_base = os.path.basename(fetch.localpath(url))
+ filename = os.path.join(workdir, local_base)
+ cmd.append(filename)
+
+ # Invoke the script and don't catch any resulting exception.
+ subprocess.check_call(cmd)
+}
+# python-pyyaml-native is installed by do_configure, so put this task after
+addtask merge_sensors after do_configure before do_compile