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.hpp b/phosphor-regulators/src/vpd.hpp
index 3222d50..8ae1314 100644
--- a/phosphor-regulators/src/vpd.hpp
+++ b/phosphor-regulators/src/vpd.hpp
@@ -17,8 +17,10 @@
#include <sdbusplus/bus.hpp>
+#include <cstdint>
#include <map>
#include <string>
+#include <vector>
namespace phosphor::power::regulators
{
@@ -60,8 +62,8 @@
* @param keyword VPD keyword
* @return VPD keyword value
*/
- virtual std::string getValue(const std::string& inventoryPath,
- const std::string& keyword) = 0;
+ virtual std::vector<uint8_t> getValue(const std::string& inventoryPath,
+ const std::string& keyword) = 0;
};
/**
@@ -96,14 +98,14 @@
}
/** @copydoc VPD::getValue() */
- virtual std::string getValue(const std::string& inventoryPath,
- const std::string& keyword) override;
+ virtual std::vector<uint8_t> getValue(const std::string& inventoryPath,
+ const std::string& keyword) override;
private:
/**
* Type alias for map from keyword names to values.
*/
- using KeywordMap = std::map<std::string, std::string>;
+ using KeywordMap = std::map<std::string, std::vector<uint8_t>>;
/**
* D-Bus bus object.