phosphor-ipmi-config: Refactor phosphor-ipmi-config provider

The phopshor-ipmi-config provider witherspoon-ipmi-config is removed to use the
default configuration files. cipher_list.json and dcmi_cap.json for the
witherspoon is the same as the default configuration file. dcmi_sensors.json,
dev_id.json and power_reading.json is specific to witherspoon. do_patch
populates the aux field in dev_id.json for witherspoon.

Change-Id: I8d5aa255cd27865135028661cc89913695fdcb5b
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/meta-witherspoon/conf/machine/witherspoon.conf b/meta-witherspoon/conf/machine/witherspoon.conf
index 1ccd1cf..0b17762 100644
--- a/meta-witherspoon/conf/machine/witherspoon.conf
+++ b/meta-witherspoon/conf/machine/witherspoon.conf
@@ -19,9 +19,6 @@
 # Inhibit phosphor-hwmon-config-mrw
 VIRTUAL-RUNTIME_phosphor-hwmon-config_df-mrw = ""
 
-# Pick up the Witherspoon-specific IPMI configuration
-VIRTUAL-RUNTIME_ipmi-config = "witherspoon-ipmi-config"
-
 # Inhibit phosphor-fan-presence-mrw-native
 PREFERRED_PROVIDER_virtual/phosphor-fan-presence-config_df-mrw = \
     "phosphor-fan-presence-config-native"
@@ -29,5 +26,3 @@
 # Inhibit phosphor-fan-control-fan-config-mrw-native
 PREFERRED_PROVIDER_virtual/phosphor-fan-control-fan-config_df-mrw = \
     "phosphor-fan-control-fan-config-native"
-
-PREFERRED_RPROVIDER_virtual/phosphor-ipmi-config = "witherspoon-ipmi-config"
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend b/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
new file mode 100644
index 0000000..8445c83
--- /dev/null
+++ b/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend
@@ -0,0 +1,44 @@
+FILESEXTRAPATHS_prepend_witherspoon := "${THISDIR}/${PN}:"
+
+# Calculate the auxiliary firmware revision to be updated in the dev_id.json
+# file. It is calculated from the VERSION_ID field which currently has two
+# formats. The revision field is 4 bytes, the first two bytes represent the
+# count of commits from the tagging and next two bytes represent the version.
+# Both fields are represented in BCD encoded format, so 9999 is the maximum
+# value both fields can take. With the format "v2.1-216-ga78ace8", Petitboot
+# would display the firmware revision as "Firmware version: 2.01.02160000",
+# "0216" is count and the revision is "0000". With the format
+# "ibm-v2.0-10-r41-0-gd0c319e" Petitboot would display the firmware revision
+# as "Firmware version: 2.00.00100041", "0010" is count and the revision
+# is "0041".
+inherit image_version
+
+unset do_patch[noexec]
+do_patch[depends] = "os-release:do_populate_sysroot"
+
+python do_patch() {
+    import json
+    import re
+    from shutil import copyfile
+    version_id = do_get_version(d)
+
+    # count from the commit version
+    count = re.findall("-(\d{1,4})-", version_id)
+
+    release = re.findall("-r(\d{1,4})", version_id)
+    if release:
+        auxVer = count[0] + "{0:0>4}".format(release[0])
+    else:
+        auxVer = count[0] + "0000"
+
+    workdir = d.getVar('WORKDIR', True)
+    file = os.path.join(workdir, 'dev_id.json')
+
+    # Update dev_id.json with the auxiliary firmware revision
+    with open(file, "r+") as jsonFile:
+        data = json.load(jsonFile)
+        jsonFile.seek(0)
+        jsonFile.truncate()
+        data["aux"] = int(auxVer, 16)
+        json.dump(data, jsonFile)
+}
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dcmi_sensors.json b/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/dcmi_sensors.json
similarity index 100%
rename from meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dcmi_sensors.json
rename to meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/dcmi_sensors.json
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dev_id.json b/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/dev_id.json
similarity index 100%
rename from meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dev_id.json
rename to meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/dev_id.json
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/power_reading.json b/meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/power_reading.json
similarity index 100%
rename from meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/power_reading.json
rename to meta-witherspoon/recipes-phosphor/ipmi/phosphor-ipmi-config/power_reading.json
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config.bb b/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config.bb
deleted file mode 100644
index 8ab47c6..0000000
--- a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config.bb
+++ /dev/null
@@ -1,82 +0,0 @@
-SUMMARY = "Witherspoon IPMI daemon configuration"
-PR = "r1"
-
-inherit obmc-phosphor-license
-inherit allarch
-
-SRC_URI = " \
-    file://cipher_list.json \
-    file://dcmi_cap.json \
-    file://dcmi_sensors.json \
-    file://dev_id.json \
-    file://power_reading.json \
-    "
-
-FILES_${PN} = " \
-    ${datadir}/ipmi-providers/cipher_list.json \
-    ${datadir}/ipmi-providers/dcmi_cap.json \
-    ${datadir}/ipmi-providers/dcmi_sensors.json \
-    ${datadir}/ipmi-providers/dev_id.json \
-    ${datadir}/ipmi-providers/power_reading.json \
-    "
-
-do_fetch[noexec] = "1"
-do_configure[noexec] = "1"
-do_compile[noexec] = "1"
-
-# Calculate the auxiliary firmware revision to be updated in the dev_id.json
-# file. It is calculated from the VERSION_ID field which currently has two
-# formats. The revision field is 4 bytes, the first two bytes represent the
-# count of commits from the tagging and next two bytes represent the version.
-# Both fields are represented in BCD encoded format, so 9999 is the maximum
-# value both fields can take. With the format "v2.1-216-ga78ace8", Petitboot
-# would display the firmware revision as "Firmware version: 2.01.02160000",
-# "0216" is count and the revision is "0000". With the format
-# "ibm-v2.0-10-r41-0-gd0c319e" Petitboot would display the firmware revision
-# as "Firmware version: 2.00.00100041", "0010" is count and the revision
-# is "0041".
-
-inherit image_version
-
-do_patch[depends] = "os-release:do_populate_sysroot"
-
-python do_patch() {
-    import json
-    import re
-    from shutil import copyfile
-    version_id = do_get_version(d)
-
-    # count from the commit version
-    count = re.findall("-(\d{1,4})-", version_id)
-
-    release = re.findall("-r(\d{1,4})", version_id)
-    if release:
-        auxVer = count[0] + "{0:0>4}".format(release[0])
-    else:
-        auxVer = count[0] + "0000"
-
-    workdir = d.getVar('WORKDIR', True)
-    file = os.path.join(workdir, 'dev_id.json')
-
-    # Update dev_id.json with the auxiliary firmware revision
-    with open(file, "r+") as jsonFile:
-        data = json.load(jsonFile)
-        jsonFile.seek(0)
-        jsonFile.truncate()
-        data["aux"] = int(auxVer, 16)
-        json.dump(data, jsonFile)
-}
-
-do_install() {
-    install -d ${D}${datadir}/ipmi-providers
-    install -m 0644 -D ${WORKDIR}/cipher_list.json \
-        ${D}${datadir}/ipmi-providers/cipher_list.json
-    install -m 0644 -D ${WORKDIR}/dcmi_cap.json \
-        ${D}${datadir}/ipmi-providers/dcmi_cap.json
-    install -m 0644 -D ${WORKDIR}/dcmi_sensors.json \
-        ${D}${datadir}/ipmi-providers/dcmi_sensors.json
-    install -m 0644 -D ${WORKDIR}/dev_id.json \
-        ${D}${datadir}/ipmi-providers/dev_id.json
-    install -m 0644 -D ${WORKDIR}/power_reading.json \
-        ${D}${datadir}/ipmi-providers/power_reading.json
-}
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/cipher_list.json b/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/cipher_list.json
deleted file mode 100644
index 0f13b1e..0000000
--- a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/cipher_list.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-    "a":{
-        "cipher":1,
-        "authentication":1,
-        "integrity":0,
-        "confidentiality":0
-    },
-    "b":{
-        "cipher":2,
-        "authentication":1,
-        "integrity":1,
-        "confidentiality":0
-    },
-    "c":{
-        "cipher":3,
-        "authentication":1,
-        "integrity":1,
-        "confidentiality":1
-    },
-    "d":{
-        "cipher":15,
-        "authentication":3,
-        "integrity":0,
-        "confidentiality":0
-    },
-    "e":{
-        "cipher":16,
-        "authentication":3,
-        "integrity":4,
-        "confidentiality":0
-    },
-    "f":{
-        "cipher":17,
-        "authentication":3,
-        "integrity":4,
-        "confidentiality":1
-    }
-}
diff --git a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dcmi_cap.json b/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dcmi_cap.json
deleted file mode 100644
index 2d88320..0000000
--- a/meta-witherspoon/recipes-phosphor/ipmi/witherspoon-ipmi-config/dcmi_cap.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-    "PowerManagement": 1,
-    "OOBSecondaryLan": 0,
-    "SerialTMODE": 0,
-    "InBandSystemInterfaceChannel": 1,
-    "SELAutoRollOver": 1,
-    "FlushEntireSELUponRollOver": 0,
-    "RecordLevelSELFlushUponRollOver": 0,
-    "NumberOfSELEntries": 200,
-    "TempMonitoringSamplingFreq":0,
-    "PowerMgmtDeviceSlaveAddress": 0,
-    "BMCChannelNumber": 0,
-    "DeviceRivision": 0,
-    "MandatoryPrimaryLanOOBSupport": 1,
-    "OptionalSecondaryLanOOBSupport": 255,
-    "OptionalSerialOOBMTMODECapability": 255
-}