PEL: Add SRC callouts from message registry
When an SRC is being built for a new PEL, it will now also add callouts
from the message registry JSON for that error.
This commit only adds support for callouts of maintenance procedures or
symbolic FRUs. A future commit will add support for calling out a
regular piece of hardware
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I78c0d3440c748f21145d452742e3aa682f26003b
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 5310947..0899417 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -120,7 +120,7 @@
_asciiString = std::make_unique<src::AsciiString>(regEntry);
- addCallouts(additionalData, dataIface);
+ addCallouts(regEntry, additionalData, dataIface);
_size = baseSRCSize;
_size += _callouts ? _callouts->flattenedSize() : 0;
@@ -502,7 +502,8 @@
return ps;
}
-void SRC::addCallouts(const AdditionalData& additionalData,
+void SRC::addCallouts(const message::Entry& regEntry,
+ const AdditionalData& additionalData,
const DataInterfaceBase& dataIface)
{
auto item = additionalData.getValue("CALLOUT_INVENTORY_PATH");
@@ -512,6 +513,11 @@
}
// TODO: CALLOUT_DEVICE_PATH
+
+ if (regEntry.callouts)
+ {
+ addRegistryCallouts(regEntry, additionalData, dataIface);
+ }
}
void SRC::addInventoryCallout(const std::string& inventoryPath,
@@ -543,8 +549,79 @@
}
_callouts->addCallout(std::move(callout));
+}
-} // namespace pels
+void SRC::addRegistryCallouts(const message::Entry& regEntry,
+ const AdditionalData& additionalData,
+ const DataInterfaceBase& dataIface)
+{
+ try
+ {
+ auto systemType = dataIface.getSystemType();
+
+ auto regCallouts = message::Registry::getCallouts(
+ regEntry.callouts.value(), systemType, additionalData);
+
+ for (const auto& regCallout : regCallouts)
+ {
+ addRegistryCallout(regCallout, dataIface);
+ }
+ }
+ catch (std::exception& e)
+ {
+ log<level::ERR>("Error parsing PEL message registry callout JSON",
+ entry("ERROR=%s", e.what()));
+ }
+}
+
+void SRC::addRegistryCallout(const message::RegistryCallout& regCallout,
+ const DataInterfaceBase& dataIface)
+{
+ std::unique_ptr<src::Callout> callout;
+
+ // TODO: expand this location code.
+ auto locCode = regCallout.locCode;
+
+ // Via the PEL values table, get the priority enum.
+ // The schema will have validated the priority was a valid value.
+ auto priorityIt =
+ pv::findByName(regCallout.priority, pv::calloutPriorityValues);
+ assert(priorityIt != pv::calloutPriorityValues.end());
+ auto priority =
+ static_cast<CalloutPriority>(std::get<pv::fieldValuePos>(*priorityIt));
+
+ if (!regCallout.procedure.empty())
+ {
+ // Procedure callout
+ callout =
+ std::make_unique<src::Callout>(priority, regCallout.procedure);
+ }
+ else if (!regCallout.symbolicFRU.empty())
+ {
+ // Symbolic FRU callout
+ callout = std::make_unique<src::Callout>(
+ priority, regCallout.symbolicFRU, locCode, false);
+ }
+ else if (!regCallout.symbolicFRUTrusted.empty())
+ {
+ // Symbolic FRU with trusted location code callout
+
+ // The registry wants it to be trusted, but that requires a valid
+ // location code for it to actually be.
+ callout = std::make_unique<src::Callout>(
+ priority, regCallout.symbolicFRUTrusted, locCode, !locCode.empty());
+ }
+ else
+ {
+ // TODO: HW callouts
+ }
+
+ if (callout)
+ {
+ createCalloutsObject();
+ _callouts->addCallout(std::move(callout));
+ }
+}
} // namespace pels
} // namespace openpower