Blob Blame History Raw
From b45d6c4fb2c340872ed7d61d94f0d9198b68a960 Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Wed, 24 Jun 2015 14:49:26 +1000
Subject: [PATCH 04/26] improve model and chassis retrieval for IBM systems
 (#685)

---
 src/core/device-tree.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 61 insertions(+), 4 deletions(-)

diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
index 8908fd1..8be5966 100644
--- a/src/core/device-tree.cc
+++ b/src/core/device-tree.cc
@@ -1233,6 +1233,64 @@ static bool get_apple_model(hwNode & n)
   return false;
 }
 
+struct ibm_model_def {
+  const char *model;
+  const char *modelname;
+  const char *icon;
+  const char *chassis; // matches DMI chassis types
+};
+struct ibm_model_def ibm_model_defs[] =
+{
+  {"0200", "BladeCenter QS20", "", "blade"},
+  {"0792", "BladeCenter QS21", "", "blade"},
+  {"6778", "BladeCenter JS21", "", "blade"},
+  {"6779", "BladeCenter JS21", "", "blade"},
+  {"7047-185", "IntelliStation POWER 185", "towercomputer", "tower"},
+  {"7988", "BladeCenter JS21", "", "blade"},
+  {"8202", "Power 720 Express", "", "rackmount"},
+  {"8205", "Power 740 Express", "", "rackmount"},
+  {"8231-E1C", "Power 710 Express", "", "rackmount"},
+  {"8231-E1D", "Power 710 Express", "", "rackmount"},
+  {"8231-E2C", "Power 730 Express", "", "rackmount"},
+  {"8231-E2D", "Power 730 Express", "", "rackmount"},
+  {"8233-E8B", "Power 750 Express", "", "rackmount"},
+  {"8236-E8C", "Power 755", "", "rackmount"},
+  {"8286-41A", "Power Systems S814", "", "rackmount"},
+  {"8286-42A", "Power Systems S824", "", "rackmount"},
+  {"8406-70Y", "Power PS700", "", "rackmount"},
+  {"8406-71Y", "BladeCenter PS702", "", "blade"},
+  {"8842", "BladeCenter JS20", "", "blade"},
+  {"8844", "BladeCenter JS21", "", "blade"},
+  {"9111-285", "IntelliStation POWER 285", "towercomputer", "tower"},
+  {"9112-265", "IntelliStation POWER 265", "towercomputer", "tower"},
+  {"9114-275", "IntelliStation POWER 275", "towercomputer", "tower"},
+  {"9123", "eServer OpenPower 710", "", "rackmount"},
+  {"9124", "eServer OpenPower 720", "", "rackmount"},
+};
+
+static void get_ibm_model(hwNode & n)
+{
+  string product = n.getProduct();
+  if (product.empty())
+    return;
+  if (product.compare(0, 4, "IBM,") != 0)
+    return;
+
+  n.setVendor("IBM");
+  string machinetype = product.substr(4, 4);
+  string model = product.substr(4);
+
+  for (size_t i = 0; i < sizeof(ibm_model_defs) / sizeof(ibm_model_def); i ++)
+  {
+    if (ibm_model_defs[i].model == machinetype || ibm_model_defs[i].model == model)
+    {
+      n.setProduct(ibm_model_defs[i].modelname);
+      n.addHint("icon", string(ibm_model_defs[i].icon));
+      n.setConfig("chassis", ibm_model_defs[i].chassis);
+      return;
+    }
+  }
+}
 
 static void fix_serial_number(hwNode & n)
 {
@@ -1265,10 +1323,11 @@ bool scan_device_tree(hwNode & n)
     n.setSerial(get_string(DEVICETREE "/system-id"));
   fix_serial_number(n);
 
+  n.setVendor(get_string(DEVICETREE "/copyright", n.getVendor()));
+  get_apple_model(n);
+  get_ibm_model(n);
   if (matches(get_string(DEVICETREE "/compatible"), "^ibm,powernv"))
   {
-    n.setVendor(get_string(DEVICETREE "/vendor", "IBM"));
-
     if (exists(DEVICETREE "/model-name"))
       n.setProduct(n.getProduct() + " (" +
 		   hw::strip(get_string(DEVICETREE "/model-name")) + ")");
@@ -1323,8 +1381,6 @@ bool scan_device_tree(hwNode & n)
   }
   else
   {
-    n.setVendor(get_string(DEVICETREE "/copyright", n.getVendor()));
-    get_apple_model(n);
     if (core)
     {
       core->addHint("icon", string("board"));
-- 
2.10.2