Enable JSON to Map Inventory Object with Network Interface

- This commit would enable a configuration JSON file, through which
  one can map the inventory object paths to the actual ethernet
  interfaces which are managed Network Service.

For Example:

- Lets say the Inventory path for a single ethernet Interface machine
  would look something like below:

  `/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc/ethernet`

  Then the corresponding configuration JSON would looks something like below:
  {
            "eth0":"ethernet"
  }

  Note that the key (eth0) in the JSON is the actual ethernet Interface
  managed by the Network Service, and the value (ethernet) is the search
  pattern to be found in the Inventory Path String.

- The above JSON would help the phosphor-network service to look for a
  match on the Interface Added signal under Inventory Path with an object
  path that contains the pattern String ("ethernet"), and there it gets the
  MAC address populated under the respective inventory path and set it as
  the MAC address of the eth0 Interface.

(From meta-ibm rev: 0e69c800da414c88d24e4fa5fe8d9bf560b87637)

Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I9e0ab9d8368efae226334086f7b1c5b6fa821770
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-ibm/recipes-phosphor/network/network/ibm-ac-server/inventory-object-map.json b/meta-ibm/recipes-phosphor/network/network/ibm-ac-server/inventory-object-map.json
new file mode 100644
index 0000000..52280a4
--- /dev/null
+++ b/meta-ibm/recipes-phosphor/network/network/ibm-ac-server/inventory-object-map.json
@@ -0,0 +1,3 @@
+{
+    "eth0":"ethernet"
+}
diff --git a/meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service b/meta-ibm/recipes-phosphor/network/network/ibm-ac-server/ncsi-netlink.service
similarity index 100%
copy from meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service
copy to meta-ibm/recipes-phosphor/network/network/ibm-ac-server/ncsi-netlink.service
diff --git a/meta-ibm/recipes-phosphor/network/network/mihawk/inventory-object-map.json b/meta-ibm/recipes-phosphor/network/network/mihawk/inventory-object-map.json
new file mode 100644
index 0000000..52280a4
--- /dev/null
+++ b/meta-ibm/recipes-phosphor/network/network/mihawk/inventory-object-map.json
@@ -0,0 +1,3 @@
+{
+    "eth0":"ethernet"
+}
diff --git a/meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service b/meta-ibm/recipes-phosphor/network/network/mihawk/ncsi-netlink.service
similarity index 100%
rename from meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service
rename to meta-ibm/recipes-phosphor/network/network/mihawk/ncsi-netlink.service
diff --git a/meta-ibm/recipes-phosphor/network/network/rainier/inventory-object-map.json b/meta-ibm/recipes-phosphor/network/network/rainier/inventory-object-map.json
new file mode 100644
index 0000000..08bb92a
--- /dev/null
+++ b/meta-ibm/recipes-phosphor/network/network/rainier/inventory-object-map.json
@@ -0,0 +1,4 @@
+{
+        "eth0":"ethernet0",
+        "eth1":"ethernet1"
+}
diff --git a/meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service b/meta-ibm/recipes-phosphor/network/network/rainier/ncsi-netlink.service
similarity index 100%
copy from meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service
copy to meta-ibm/recipes-phosphor/network/network/rainier/ncsi-netlink.service
diff --git a/meta-ibm/recipes-phosphor/network/network/witherspoon-tacoma/inventory-object-map.json b/meta-ibm/recipes-phosphor/network/network/witherspoon-tacoma/inventory-object-map.json
new file mode 100644
index 0000000..9f535ca
--- /dev/null
+++ b/meta-ibm/recipes-phosphor/network/network/witherspoon-tacoma/inventory-object-map.json
@@ -0,0 +1,3 @@
+{
+        "eth0":"eth0"
+}
diff --git a/meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service b/meta-ibm/recipes-phosphor/network/network/witherspoon-tacoma/ncsi-netlink.service
similarity index 100%
copy from meta-ibm/recipes-phosphor/network/network/ncsi-netlink.service
copy to meta-ibm/recipes-phosphor/network/network/witherspoon-tacoma/ncsi-netlink.service
diff --git a/meta-ibm/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-ibm/recipes-phosphor/network/phosphor-network_%.bbappend
index bcb2d01..178a921 100644
--- a/meta-ibm/recipes-phosphor/network/phosphor-network_%.bbappend
+++ b/meta-ibm/recipes-phosphor/network/phosphor-network_%.bbappend
@@ -1,15 +1,32 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/network:"
-SRC_URI_append_ibm-ac-server = " file://ncsi-netlink.service"
-SRC_URI_append_mihawk = " file://ncsi-netlink.service"
 
-SYSTEMD_SERVICE_${PN}_append_ibm-ac-server = " ncsi-netlink.service"
-SYSTEMD_SERVICE_${PN}_append_mihawk = " ncsi-netlink.service"
+SRC_URI += " file://ncsi-netlink.service"
+SYSTEMD_SERVICE_${PN} += " ncsi-netlink.service"
+FILES_${PN} += "${datadir}/network/*.json"
 
-do_install_append_ibm-ac-server() {
+install_network_configuration(){
     install -d ${D}${systemd_system_unitdir}
     install -m 0644 ${WORKDIR}/ncsi-netlink.service ${D}${systemd_system_unitdir}
+    install -d ${D}${datadir}/network/
+    install -m 0644 ${WORKDIR}/inventory-object-map.json ${D}${datadir}/network/config.json
 }
+
+SRC_URI_append_rainier = " file://inventory-object-map.json"
+do_install_append_rainier(){
+    install_network_configuration
+}
+
+SRC_URI_append_ibm-ac-server = " file://inventory-object-map.json"
+do_install_append_ibm-ac-server() {
+    install_network_configuration
+}
+
+SRC_URI_append_mihawk = " file://inventory-object-map.json"
 do_install_append_mihawk() {
-    install -d ${D}${systemd_system_unitdir}
-    install -m 0644 ${WORKDIR}/ncsi-netlink.service ${D}${systemd_system_unitdir}
+    install_network_configuration
+}
+
+SRC_URI_append_witherspoon-tacoma = " file://inventory-object-map.json"
+do_install_append_witherspoon-tacoma(){
+    install_network_configuration
 }