regulators: Support a string or vector for VPD

Add a 'byte_values' alternative to the 'value' entry in the compare VPD
action.  This is to support VPD values that are not strings, such as
'HW', a new IBM keyword that describes the version of a piece of
hardware.

To support this, the VPD class now treats all VPD keyword values as
vectors of uint8_ts, including in its data cache.  If a compare VPD
action in the JSON contains a string value, it will be converted to the
vector before the CompareVPDAction class is created.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I3fcabf896f4885feae1b07ee2c3da5929cf8bfa4
diff --git a/phosphor-regulators/src/vpd.cpp b/phosphor-regulators/src/vpd.cpp
index fc99904..5f5454e 100644
--- a/phosphor-regulators/src/vpd.cpp
+++ b/phosphor-regulators/src/vpd.cpp
@@ -22,10 +22,10 @@
 namespace phosphor::power::regulators
 {
 
-std::string DBusVPD::getValue(const std::string& inventoryPath,
-                              const std::string& keyword)
+std::vector<uint8_t> DBusVPD::getValue(const std::string& inventoryPath,
+                                       const std::string& keyword)
 {
-    std::string value{};
+    std::vector<uint8_t> value{};
 
     // Get cached keywords for the inventory path
     KeywordMap& cachedKeywords = cache[inventoryPath];
@@ -38,12 +38,28 @@
     }
     else
     {
-        // Get keyword value from D-Bus interface/property.  The property name
-        // is normally the same as the VPD keyword name.  However, the CCIN
-        // keyword is stored in the Model property.
-        std::string property{(keyword == "CCIN") ? "Model" : keyword};
-        util::getProperty(ASSET_IFACE, property, inventoryPath,
-                          INVENTORY_MGR_IFACE, bus, value);
+        if (keyword == "HW")
+        {
+            // HW is a vector<uint8_t>, the others are a string.
+            util::getProperty("com.ibm.ipzvpd.VINI", "HW", inventoryPath,
+                              INVENTORY_MGR_IFACE, bus, value);
+        }
+        else
+        {
+            // Get keyword value from D-Bus interface/property.  The property
+            // name is normally the same as the VPD keyword name.  However, the
+            // CCIN keyword is stored in the Model property.
+            std::string property{(keyword == "CCIN") ? "Model" : keyword};
+            std::string stringValue;
+            util::getProperty(ASSET_IFACE, property, inventoryPath,
+                              INVENTORY_MGR_IFACE, bus, stringValue);
+
+            if (!stringValue.empty())
+            {
+                value.insert(value.begin(), stringValue.begin(),
+                             stringValue.end());
+            }
+        }
 
         // Cache keyword value
         cachedKeywords[keyword] = value;