Skip to content

Commit cba4f44

Browse files
SunnySrivastava1984edtanous
authored andcommitted
Add additional Redfish Processor properties
This commit adds the following inventory properties for the Processor resource in bmcweb: a) LocationCode, a free form, implementation-defined string to provide the location of the processor. This is needed so an implementation can identify the processor via system diagrams. b) SparePartNumber, also field-replaceable unit (FRU) Part Number, is a part number that identifies the FRU for replacement specifically ordering of a new part. c) PartNumber, also called a Marketing Number, describes a specific part within a specific system among a manufactures various product lines. These numbers tell IT infrastructure technicians exactly which parts are included in their servers, storage and networking equipment. These properties are essential to locate and replace the FRU. Validator has been executed and no new error has been found. Sample Output: { "@odata.id": "/redfish/v1/Systems/system/Processors/cpu0", "@odata.type": "#Processor.v1_11_0.Processor", "Id": "cpu0", "Location": { "PartLocation": { "ServiceLabel": "Ufcs-P0-C15" } }, "Manufacturer": "", "Model": "AB41", "Name": "Processor", "PartNumber": "2345678", "ProcessorType": "CPU", "SerialNumber": "YLAB41010000", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Absent" } } Signed-off-by: Sunny Srivastava <[email protected]> Change-Id: Ifc0e13fd7eb94e86eade223608a1ecad2487ed37
1 parent 071d8fd commit cba4f44

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

Diff for: redfish-core/lib/processor.hpp

+73-2
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,30 @@ inline void getCpuAssetData(std::shared_ptr<AsyncResp> aResp,
281281
}
282282
}
283283
}
284+
else if (property.first == "PartNumber")
285+
{
286+
const std::string* partNumber =
287+
std::get_if<std::string>(&property.second);
288+
289+
if (partNumber == nullptr)
290+
{
291+
messages::internalError(aResp->res);
292+
return;
293+
}
294+
aResp->res.jsonValue["PartNumber"] = *partNumber;
295+
}
296+
else if (property.first == "SparePartNumber")
297+
{
298+
const std::string* sparePartNumber =
299+
std::get_if<std::string>(&property.second);
300+
301+
if (sparePartNumber == nullptr)
302+
{
303+
messages::internalError(aResp->res);
304+
return;
305+
}
306+
aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
307+
}
284308
}
285309
},
286310
service, objPath, "org.freedesktop.DBus.Properties", "GetAll",
@@ -544,6 +568,47 @@ inline void getCpuConfigData(const std::shared_ptr<AsyncResp>& aResp,
544568
"xyz.openbmc_project.Control.Processor.CurrentOperatingConfig");
545569
}
546570

571+
/**
572+
* @brief Fill out location info of a processor by
573+
* requesting data from the given D-Bus object.
574+
*
575+
* @param[in,out] aResp Async HTTP response.
576+
* @param[in] service D-Bus service to query.
577+
* @param[in] objPath D-Bus object to query.
578+
*/
579+
inline void getCpuLocationCode(std::shared_ptr<AsyncResp> aResp,
580+
const std::string& service,
581+
const std::string& objPath)
582+
{
583+
BMCWEB_LOG_DEBUG << "Get Cpu Location Data";
584+
crow::connections::systemBus->async_method_call(
585+
[objPath,
586+
aResp{std::move(aResp)}](const boost::system::error_code ec,
587+
const std::variant<std::string>& property) {
588+
if (ec)
589+
{
590+
BMCWEB_LOG_DEBUG << "DBUS response error";
591+
messages::internalError(aResp->res);
592+
return;
593+
}
594+
595+
const std::string* value = std::get_if<std::string>(&property);
596+
597+
if (value == nullptr)
598+
{
599+
// illegal value
600+
BMCWEB_LOG_DEBUG << "Location code value error";
601+
messages::internalError(aResp->res);
602+
return;
603+
}
604+
605+
aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
606+
*value;
607+
},
608+
service, objPath, "org.freedesktop.DBus.Properties", "Get",
609+
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode");
610+
}
611+
547612
inline void getProcessorData(std::shared_ptr<AsyncResp> aResp,
548613
const std::string& processorId)
549614
{
@@ -605,6 +670,11 @@ inline void getProcessorData(std::shared_ptr<AsyncResp> aResp,
605670
getCpuConfigData(aResp, processorId, serviceName,
606671
objectPath);
607672
}
673+
else if (interface == "xyz.openbmc_project.Inventory."
674+
"Decorator.LocationCode")
675+
{
676+
getCpuLocationCode(aResp, serviceName, objectPath);
677+
}
608678
}
609679
}
610680
return;
@@ -617,10 +687,11 @@ inline void getProcessorData(std::shared_ptr<AsyncResp> aResp,
617687
"/xyz/openbmc_project/object_mapper",
618688
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
619689
"/xyz/openbmc_project/inventory", 0,
620-
std::array<const char*, 5>{
690+
std::array<const char*, 6>{
621691
"xyz.openbmc_project.Inventory.Decorator.Asset",
622692
"xyz.openbmc_project.Inventory.Decorator.Revision",
623693
"xyz.openbmc_project.Inventory.Item.Cpu",
694+
"xyz.openbmc_project.Inventory.Decorator.LocationCode",
624695
"xyz.openbmc_project.Inventory.Item.Accelerator",
625696
"xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"});
626697
}
@@ -973,7 +1044,7 @@ class Processor : public Node
9731044
return;
9741045
}
9751046
const std::string& processorId = params[0];
976-
res.jsonValue["@odata.type"] = "#Processor.v1_9_0.Processor";
1047+
res.jsonValue["@odata.type"] = "#Processor.v1_11_0.Processor";
9771048
res.jsonValue["@odata.id"] =
9781049
"/redfish/v1/Systems/system/Processors/" + processorId;
9791050

0 commit comments

Comments
 (0)