Inventory.pm: Point chassis at the motherboard

Give the chassis MRW target the same inventory name as
the motherboard.  Requested by the FRU management code.

For multi-chassis systems, this will probably need to be
revisited.

Change-Id: I3bbfe552a31e5a3aa3059c7ff2b6c8a3e414eb7a
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/Inventory.pm b/Inventory.pm
index b5d4144..9f37f3b 100644
--- a/Inventory.pm
+++ b/Inventory.pm
@@ -138,6 +138,8 @@
 
     #We want card1, not card-1
     removeHyphensFromInstanceNum($inventory);
+
+    pointChassisAtMotherboard($targetObj, $inventory);
 }
 
 
@@ -328,6 +330,33 @@
 }
 
 
+#FRU management code needs the node/chassis item to point
+#to the motherboard and not /system/chassis.  Can revisit this
+#for multi-chassis systems if they ever show up.
+sub pointChassisAtMotherboard
+{
+    my ($targetObj, $inventory) = @_;
+    my $newName = undef;
+
+    for my $item (@$inventory) {
+        my $type = $targetObj->getTargetType($item->{TARGET});
+        if ($type eq "card-motherboard") {
+            $newName = $item->{OBMC_NAME};
+            last;
+        }
+    }
+
+    for my $item (@$inventory) {
+        if ($targetObj->getType($item->{TARGET}) eq "NODE") {
+            if (defined $newName) {
+                $item->{OBMC_NAME} = $newName;
+            }
+            last;
+        }
+    }
+}
+
+
 #Removes the instance number from the OBMC_NAME segments
 #where only 1 of those segments exists because numbering isn't
 #necessary to distinguish them.