Showing with 30 additions and 34 deletions.
  1. +30 −34 redfish-core/lib/processor.hpp
@@ -50,36 +50,51 @@ inline void
{
BMCWEB_LOG_DEBUG << "Get CPU resources by interface.";

// Added for future purpose. Once present and functional attributes added
// in busctl call, need to add actual logic to fetch original values.
bool present = false;
const bool functional = true;
auto health = std::make_shared<HealthPopulate>(aResp);
health->populate();
// Set the default value of state
aResp->res.jsonValue["Status"]["State"] = "Enabled";
aResp->res.jsonValue["Status"]["Health"] = "OK";

for (const auto& interface : cpuInterfacesProperties)
{
for (const auto& property : interface.second)
{
if (property.first == "CoreCount")
if (property.first == "Present")
{
const uint16_t* coresCount =
std::get_if<uint16_t>(&property.second);
if (coresCount == nullptr)
const bool* cpuPresent = std::get_if<bool>(&property.second);
if (cpuPresent == nullptr)
{
// Important property not in desired type
messages::internalError(aResp->res);
return;
}
if (*coresCount == 0)
if (*cpuPresent == false)
{
// Slot is not populated, set status end return
// Slot is not populated
aResp->res.jsonValue["Status"]["State"] = "Absent";
// HTTP Code will be set up automatically, just return
}
}
else if (property.first == "Functional")
{
const bool* cpuFunctional = std::get_if<bool>(&property.second);
if (cpuFunctional == nullptr)
{
messages::internalError(aResp->res);
return;
}
if (*cpuFunctional == false)
{
aResp->res.jsonValue["Status"]["Health"] = "Critical";
}
}
else if (property.first == "CoreCount")
{
const uint16_t* coresCount =
std::get_if<uint16_t>(&property.second);
if (coresCount == nullptr)
{
messages::internalError(aResp->res);
return;
}
aResp->res.jsonValue["Status"]["State"] = "Enabled";
present = true;
aResp->res.jsonValue["TotalCores"] = *coresCount;
}
else if (property.first == "MaxSpeedInMhz")
@@ -122,7 +137,6 @@ inline void
const uint64_t* value = std::get_if<uint64_t>(&property.second);
if (value != nullptr && *value != 0)
{
present = true;
aResp->res
.jsonValue["ProcessorId"]["IdentificationRegisters"] =
boost::lexical_cast<std::string>(*value);
@@ -131,24 +145,6 @@ inline void
}
}

if (present == false)
{
aResp->res.jsonValue["Status"]["State"] = "Absent";
aResp->res.jsonValue["Status"]["Health"] = "OK";
}
else
{
aResp->res.jsonValue["Status"]["State"] = "Enabled";
if (functional)
{
aResp->res.jsonValue["Status"]["Health"] = "OK";
}
else
{
aResp->res.jsonValue["Status"]["Health"] = "Critical";
}
}

return;
}