Add virtual/phosphor-ipmi-fru-properties

This virtual provides an output file in YAML format, which has
property:value pairs for FRUs of interest.

Add a native recipe that builds the configuration from MRW. Set this
recipe as the default for OpenPOWER systems.

Change-Id: Icc816b777189a48aff79a958f38ad22d7002bfdc
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/meta-phosphor/classes/phosphor-ipmi-fru.bbclass b/meta-phosphor/classes/phosphor-ipmi-fru.bbclass
index 9c0d227..d833eaf 100644
--- a/meta-phosphor/classes/phosphor-ipmi-fru.bbclass
+++ b/meta-phosphor/classes/phosphor-ipmi-fru.bbclass
@@ -1,3 +1,4 @@
 hostfw_datadir="${datadir}/phosphor-ipmi-fru/hostfw"
 inventory_datadir="${datadir}/phosphor-ipmi-fru/inventory"
 config_datadir="${datadir}/phosphor-ipmi-fru/config"
+properties_datadir="${datadir}/phosphor-ipmi-fru/properties"
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example-native.bb
new file mode 100644
index 0000000..200dcd7
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example-native.bb
@@ -0,0 +1,22 @@
+SUMMARY = "FRU properties config for ipmi-fru-parser"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-license
+inherit phosphor-ipmi-fru
+
+SRC_URI += "file://out.yaml"
+
+PROVIDES += "virtual/phosphor-ipmi-fru-properties"
+
+S = "${WORKDIR}"
+
+do_install() {
+        # This recipe is supposed to create an output yaml file with
+        # FRU property values extracted from the MRW. This example recipe
+        # provides a sample output file.
+
+        DEST=${D}${properties_datadir}
+        install -d ${DEST}
+        install out.yaml ${DEST}
+}
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example/out.yaml b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example/out.yaml
new file mode 100644
index 0000000..626ef33
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-example/out.yaml
@@ -0,0 +1,11 @@
+/system/chassis/motherboard/cpu0:
+    xyz.openbmc_project.Inventory.Decorator.Replaceable:
+        FieldReplaceable: 'true'
+    xyz.openbmc_project.Inventory.Decorator.Cacheable:
+        Cached: 'true'
+
+/system/chassis/motherboard/dimm0:
+    xyz.openbmc_project.Inventory.Decorator.Replaceable:
+        FieldReplaceable: 'true' 
+    xyz.openbmc_project.Inventory.Decorator.Cacheable:
+        Cached: 'true'
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb
new file mode 100644
index 0000000..2188f04
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb
@@ -0,0 +1,28 @@
+SUMMARY = "FRU properties config for ipmi-fru-parser"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-license
+inherit phosphor-ipmi-fru
+
+SRC_URI += "file://config.yaml"
+
+DEPENDS += " \
+           mrw-native \
+           mrw-perl-tools-native \
+           "
+
+PROVIDES += "virtual/phosphor-ipmi-fru-properties"
+
+S = "${WORKDIR}"
+
+do_install() {
+        DEST=${D}${properties_datadir}
+        install -d ${DEST}
+
+        ${bindir}/perl-native/perl \
+            ${bindir}/gen_fru_properties.pl \
+            -m ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -c config.yaml \
+            -o ${DEST}/out.yaml
+}
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw/config.yaml b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw/config.yaml
new file mode 100644
index 0000000..eb62648
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw/config.yaml
@@ -0,0 +1,23 @@
+PROC:
+    xyz.openbmc_project.Inventory.Decorator.Replaceable:
+        FieldReplaceable: 'false'
+    xyz.openbmc_project.Inventory.Decorator.Cacheable:
+        Cached: 'false'
+    xyz.openbmc_project.Inventory.Item:
+        Present: 'true'
+
+DIMM:
+    xyz.openbmc_project.Inventory.Decorator.Replaceable:
+        FieldReplaceable: 'false'
+    xyz.openbmc_project.Inventory.Decorator.Cacheable:
+        Cached: 'false'
+    xyz.openbmc_project.Inventory.Item:
+        Present: 'true'
+
+SYS:
+    xyz.openbmc_project.Inventory.Decorator.Replaceable:
+        FieldReplaceable: 'false'
+    xyz.openbmc_project.Inventory.Decorator.Cacheable:
+        Cached: 'false'
+    xyz.openbmc_project.Inventory.Item:
+        Present: 'true'
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru.bb
index 16e26df..e99d16b 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru.bb
@@ -13,6 +13,7 @@
 DEPENDS += " \
         virtual/phosphor-ipmi-fru-hostfw-config\
         virtual/phosphor-ipmi-fru-inventory \
+        virtual/phosphor-ipmi-fru-properties \
         systemd \
         sdbusplus \
         python-mako-native \
@@ -43,4 +44,7 @@
 # EXTRA_OECONF += "HOSTFW_YAML=${hostfw_datadir}/config.yaml"
 #
 # For now the generator requires them to already be combined so we have:
-EXTRA_OECONF = "YAML_GEN=${STAGING_DIR_NATIVE}${config_datadir}/config.yaml"
+EXTRA_OECONF = " \
+             YAML_GEN=${STAGING_DIR_NATIVE}${config_datadir}/config.yaml \
+             PROP_YAML=${STAGING_DIR_NATIVE}${properties_datadir}/out.yaml \
+             "
diff --git a/meta-phosphor/conf/distro/include/phosphor-defaults.inc b/meta-phosphor/conf/distro/include/phosphor-defaults.inc
index 4c3ec5c8..64309d1 100644
--- a/meta-phosphor/conf/distro/include/phosphor-defaults.inc
+++ b/meta-phosphor/conf/distro/include/phosphor-defaults.inc
@@ -70,6 +70,8 @@
 # the phosphor-ipmi-fru build process in the native sysroot.
 PREFERRED_PROVIDER_virtual/phosphor-ipmi-fru-inventory ?= \
     "${@cf_enabled(d, 'obmc-mrw', 'phosphor-ipmi-fru-inventory-mrw-native', 'phosphor-ipmi-fru-inventory-example-native')}"
+PREFERRED_PROVIDER_virtual/phosphor-ipmi-fru-properties ?= \
+    "${@cf_enabled(d, 'obmc-mrw', 'phosphor-ipmi-fru-properties-mrw-native', 'phosphor-ipmi-fru-properties-example-native')}"
 
 OBMC_DBUS_PATH_ROOT ?= "/xyz/openbmc_project"
 OBMC_DBUS_IFACE_ROOT ?= "xyz.openbmc_project"