Allow byte array values in extraInterfaces
This commit allows the parser to pick up "immediate" values of
type byte arrays from within the extrInterfaces key in the JSON.
One use case where this is needed is when we have to "hard-code"
or synthesize certain VPD data (ex. Fans on Rainier system).
This is an example of how one would specify such values in the
JSON:
...
...
"extraInterfaces": {
"com.ibm.ipzvpd.Location" : {
"LocationCode" : "Ufcs-A5"
},
"com.ibm.ipzvpd.VINI" : {
"FN": [48, 50, 89, 75, 51, 50, 55],
"CC": [55, 66, 53, 71]
},
...
...
Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: I0b73cb7cd65d37e0421b60cd28e25acdbbc4517a
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index f091500..2501186 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -227,6 +227,18 @@
props.emplace(busProp, itr.value().get<string>());
}
}
+ else if (itr.value().is_array())
+ {
+ try
+ {
+ props.emplace(busProp, itr.value().get<Binary>());
+ }
+ catch (nlohmann::detail::type_error& e)
+ {
+ std::cerr << "Type exception: " << e.what() << "\n";
+ // Ignore any type errors
+ }
+ }
else if (itr.value().is_object())
{
const string& rec = itr.value().value("recordName", "");
@@ -441,7 +453,6 @@
presProp.emplace("Present", false);
interfaces.emplace("xyz.openbmc_project.Inventory.Item",
move(presProp));
-
if (itemEEPROM.find("extraInterfaces") != itemEEPROM.end())
{
for (const auto& eI : itemEEPROM["extraInterfaces"].items())