Error code for insertorMerge API
This commit updates insertOrMerge API to set error code in case of
error. This helps the caller of API to take action based on the error
code returned from the API.
Change-Id: I4bd37c226a7f2f73076d811e641e39159eadf874
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index a6970aa..373883b 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -535,8 +535,17 @@
if (!propertyValueMap.empty())
{
+ uint16_t l_errCode = 0;
vpdSpecificUtility::insertOrMerge(
- interfaceMap, constants::kwdVpdInf, move(propertyValueMap));
+ interfaceMap, constants::kwdVpdInf, move(propertyValueMap),
+ l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
}
}
@@ -547,6 +556,7 @@
{
for (const auto& interfacesPropPair : interfaceJson.items())
{
+ uint16_t l_errCode = 0;
const std::string& interface = interfacesPropPair.key();
types::PropertyMap propertyMap;
@@ -574,7 +584,14 @@
vpdSpecificUtility::insertOrMerge(
interfaceMap,
std::string(constants::xyzLocationCodeInf),
- move(l_locCodeProperty));
+ move(l_locCodeProperty), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
else
{
@@ -694,8 +711,15 @@
}
}
}
+ l_errCode = 0;
vpdSpecificUtility::insertOrMerge(interfaceMap, interface,
- move(propertyMap));
+ move(propertyMap), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage("Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
}
@@ -737,10 +761,18 @@
// Check if its required to handle presence for this FRU.
if (singleFru.value("handlePresence", true))
{
+ uint16_t l_errCode = 0;
types::PropertyMap presProp;
presProp.emplace("Present", true);
- vpdSpecificUtility::insertOrMerge(
- interfaces, "xyz.openbmc_project.Inventory.Item", move(presProp));
+ vpdSpecificUtility::insertOrMerge(interfaces,
+ "xyz.openbmc_project.Inventory.Item",
+ move(presProp), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage("Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
}
@@ -898,11 +930,19 @@
// Implies value is not there in D-Bus. Populate it with default
// value "true".
+ uint16_t l_errCode = 0;
types::PropertyMap l_functionalProp;
l_functionalProp.emplace("Functional", true);
vpdSpecificUtility::insertOrMerge(io_interfaces,
constants::operationalStatusInf,
- move(l_functionalProp));
+ move(l_functionalProp), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert interface into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
// if chassis is power on. Functional property should be there on D-Bus.
@@ -936,10 +976,18 @@
// Implies value is not there in D-Bus. Populate it with default
// value "true".
+ uint16_t l_errCode = 0;
types::PropertyMap l_enabledProp;
l_enabledProp.emplace("Enabled", true);
vpdSpecificUtility::insertOrMerge(io_interfaces, constants::enableInf,
- move(l_enabledProp));
+ move(l_enabledProp), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert interface into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
}
// if chassis is power on. Enabled property should be there on D-Bus.
@@ -1837,10 +1885,18 @@
types::PropertyMap l_propertyValueMap;
l_propertyValueMap.emplace("Present", i_value);
+ uint16_t l_errCode = 0;
types::InterfaceMap l_interfaces;
- vpdSpecificUtility::insertOrMerge(l_interfaces,
- constants::inventoryItemInf,
- move(l_propertyValueMap));
+ vpdSpecificUtility::insertOrMerge(
+ l_interfaces, constants::inventoryItemInf,
+ move(l_propertyValueMap), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
l_objectInterfaceMap.emplace(std::move(l_fruObjectPath),
std::move(l_interfaces));
@@ -1858,10 +1914,18 @@
types::PropertyMap l_propertyValueMap;
l_propertyValueMap.emplace("Present", i_value);
+ uint16_t l_errCode = 0;
types::InterfaceMap l_interfaces;
- vpdSpecificUtility::insertOrMerge(l_interfaces,
- constants::inventoryItemInf,
- move(l_propertyValueMap));
+ vpdSpecificUtility::insertOrMerge(
+ l_interfaces, constants::inventoryItemInf,
+ move(l_propertyValueMap), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
l_objectInterfaceMap.emplace(i_vpdPath, std::move(l_interfaces));
}
@@ -2120,10 +2184,18 @@
l_propertyValueMap.insert(l_timeStampMap.begin(),
l_timeStampMap.end());
+ uint16_t l_errCode = 0;
types::InterfaceMap l_interfaces;
vpdSpecificUtility::insertOrMerge(
l_interfaces, constants::vpdCollectionInterface,
- move(l_propertyValueMap));
+ move(l_propertyValueMap), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
l_objectInterfaceMap.emplace(std::move(l_fruObjectPath),
std::move(l_interfaces));
@@ -2144,10 +2216,18 @@
l_propertyValueMap.insert(l_timeStampMap.begin(),
l_timeStampMap.end());
+ uint16_t l_errCode = 0;
types::InterfaceMap l_interfaces;
- vpdSpecificUtility::insertOrMerge(l_interfaces,
- constants::vpdCollectionInterface,
- move(l_propertyValueMap));
+ vpdSpecificUtility::insertOrMerge(
+ l_interfaces, constants::vpdCollectionInterface,
+ move(l_propertyValueMap), l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to insert value into map, error : " +
+ commonUtility::getErrCodeMsg(l_errCode));
+ }
l_objectInterfaceMap.emplace(i_vpdPath, std::move(l_interfaces));
}