@@ -115,8 +115,8 @@ int VpdTool::dumpObject(std::string i_fruPath) const noexcept
115115 catch (std::exception& l_ex)
116116 {
117117 // TODO: Enable logging when verbose is enabled.
118- // std::cerr << "Dump Object failed for FRU [" << i_fruPath
119- // << "], Error: " << l_ex.what() << std::endl;
118+ std::cerr << " Dump Object failed for FRU [" << i_fruPath
119+ << " ], Error: " << l_ex.what () << std::endl;
120120 }
121121 return l_rc;
122122}
@@ -131,9 +131,15 @@ nlohmann::json VpdTool::getFruProperties(const std::string& i_objectPath) const
131131
132132 nlohmann::json l_fruJson = nlohmann::json::object_t ({});
133133
134- l_fruJson.emplace (i_objectPath, nlohmann::json::object_t ({}));
134+ // need to trim out the base inventory path in the FRU JSON.
135+ const std::string l_displayObjectPath =
136+ (i_objectPath.find (constants::baseInventoryPath) == std::string::npos)
137+ ? i_objectPath
138+ : i_objectPath.substr (strlen (constants::baseInventoryPath));
135139
136- auto & l_fruObject = l_fruJson[i_objectPath];
140+ l_fruJson.emplace (l_displayObjectPath, nlohmann::json::object_t ({}));
141+
142+ auto & l_fruObject = l_fruJson[l_displayObjectPath];
137143
138144 const auto l_prettyNameInJson = getInventoryPropertyJson<std::string>(
139145 i_objectPath, constants::inventoryItemInf, " PrettyName" );
@@ -151,15 +157,6 @@ nlohmann::json VpdTool::getFruProperties(const std::string& i_objectPath) const
151157 l_locationCodeInJson.cend ());
152158 }
153159
154- const auto l_subModelInJson = getInventoryPropertyJson<std::string>(
155- i_objectPath, constants::assetInf, " SubModel" );
156-
157- if (!l_subModelInJson.empty () &&
158- !l_subModelInJson.value (" SubModel" , " " ).empty ())
159- {
160- l_fruObject.insert (l_subModelInJson.cbegin (), l_subModelInJson.cend ());
161- }
162-
163160 // Get the properties under VINI interface.
164161
165162 nlohmann::json l_viniPropertiesInJson = nlohmann::json::object ({});
@@ -184,6 +181,24 @@ nlohmann::json VpdTool::getFruProperties(const std::string& i_objectPath) const
184181 l_fruObject.insert (l_viniPropertiesInJson.cbegin (),
185182 l_viniPropertiesInJson.cend ());
186183 }
184+ // if a FRU doesn't have VINI properties, we need to get the properties from
185+ // Decorator.Asset interface
186+ else
187+ {
188+ // Get properties under Decorator.Asset interface
189+ const auto l_decoratorAssetPropertiesMap =
190+ utils::getPropertyMap (constants::inventoryManagerService,
191+ i_objectPath, constants::assetInf);
192+
193+ for (const auto & l_aProperty : l_decoratorAssetPropertiesMap)
194+ {
195+ if (const auto l_propertyValueStr =
196+ std::get_if<std::string>(&l_aProperty.second ))
197+ {
198+ l_fruObject.emplace (l_aProperty.first , *l_propertyValueStr);
199+ }
200+ }
201+ }
187202
188203 const auto l_typePropertyJson = getFruTypeProperty (i_objectPath);
189204 if (!l_typePropertyJson.empty ())
@@ -192,6 +207,9 @@ nlohmann::json VpdTool::getFruProperties(const std::string& i_objectPath) const
192207 l_typePropertyJson.cend ());
193208 }
194209
210+ // insert FRU "TYPE"
211+ l_fruObject.emplace (" TYPE" , " FRU" );
212+
195213 return l_fruJson;
196214}
197215
0 commit comments