Witherspoon: Destroy invalid inventory on startup

During development, the inventory name of the power supplies
changed from power_supply to powersupply.  Because the
inventory manager persists everything, systems that were
code updated to a level that had the name change would now
show both the old and new names in the inventory.

This commit adds a rule to the inventory manager to destroy
the old objects with the old name when it starts up.

Resolves openbmc/openbmc#2726

Change-Id: Id9f68d686fbc4d8959113593f4c5837c31a73c19
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup-native.bb b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup-native.bb
new file mode 100644
index 0000000..6efde48
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup-native.bb
@@ -0,0 +1,15 @@
+SUMMARY = "Copy Witherspoon inventory cleanup yaml for inventory manager"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-license
+inherit phosphor-inventory-manager
+
+SRC_URI += "file://inventory-cleanup.yaml"
+
+S = "${WORKDIR}"
+
+do_install() {
+        install -d ${D}${base_datadir}/events.d/
+        install ${S}/inventory-cleanup.yaml ${D}${base_datadir}/events.d/inventory-cleanup.yaml
+}
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml
new file mode 100644
index 0000000..454ae5d
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml
@@ -0,0 +1,13 @@
+description: >
+    Witherspoon inventory fixups
+
+events:
+    - name: Remove power_supplies
+      description: >
+          Remove the deprecated 'power_supply' objects
+      type: startup
+      actions:
+          - name: destroyObjects
+            paths:
+                - /system/chassis/power_supply0
+                - /system/chassis/power_supply1
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/phosphor-inventory-manager-config-native.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/phosphor-inventory-manager-config-native.bbappend
new file mode 100644
index 0000000..d9304c0
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/inventory/phosphor-inventory-manager-config-native.bbappend
@@ -0,0 +1 @@
+PHOSPHOR_INVENTORY_MANAGER_CONFIGS += "inventory-cleanup-native"