Configuration yaml changes for virtual sensors
Change-Id: I270a62022340d6be382091a6595859dafdb634ae
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb b/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
index db018c6..169b547 100644
--- a/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
+++ b/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
@@ -4,17 +4,19 @@
inherit native
inherit obmc-phosphor-license
inherit phosphor-ipmi-host
-
-SRC_URI += "file://config.yaml"
+inherit pythonnative
DEPENDS += " \
mrw-native \
mrw-perl-tools-native \
+ packagegroup-obmc-ipmi-sensors \
+ phosphor-ipmi-sensor-inventory-mrw-config-native \
"
PROVIDES += "virtual/phosphor-ipmi-sensor-inventory"
S = "${WORKDIR}"
+SRC_URI += "file://merge_sensor_config.py"
do_install() {
DEST=${D}${sensor_datadir}
@@ -23,6 +25,30 @@
${bindir}/perl-native/perl \
${bindir}/gen_ipmi_sensor.pl \
-i ${datadir}/obmc-mrw/${MACHINE}.xml \
- -m config.yaml \
+ -m ${sensor_yamldir}/config.yaml \
-o ${DEST}/sensor.yaml
}
+
+python do_merge_sensor_config () {
+ import subprocess
+
+ # TODO: Perform the merge in a temporary directory?
+ workdir = d.getVar('WORKDIR', True)
+ nativedir = d.getVar('STAGING_DIR_NATIVE', True)
+ sensoryamldir = d.getVar('sensor_yamldir', True)
+ cmd = []
+ cmd.append(os.path.join(workdir, 'merge_sensor_config.py'))
+ cmd.append(os.path.join(sensoryamldir, 'config.yaml'))
+
+ fetch = os.listdir(sensoryamldir)
+ override_urls = filter(lambda f: f.endswith('-config.yaml'), fetch)
+ for url in override_urls:
+ bb.debug(2, 'Merging extra configurations: ' + url)
+ filename = os.path.join(sensoryamldir, url)
+ 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_sensor_config after do_configure before do_compile