Implement generic function to get active versions
Current logic to get the Active BMC firmware
version is not synchronizing with bmcweb code.
To get the active firmware version, we are using
functional association endpoints. Endpoints will
provide all the functional firmware objects and
we retrive version information depending on
given version purpose(component). This is the same
logic followed in redfish and with change, both
ipmi and redfish pulls version with same logic.
Tested:
- Get device id command works fine.
- Get OEM Device information commands works fine.
Change-Id: I16ac2c52a4fadbffdc8c870cd738683435d56b1f
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 072a6c5..55f9568 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -295,21 +295,17 @@
return IPMI_CC_OK;
}
-bool getSwVerInfo(uint8_t& bmcMajor, uint8_t& bmcMinor, uint8_t& meMajor,
- uint8_t& meMinor)
+bool getSwVerInfo(ipmi::Context::ptr ctx, uint8_t& bmcMajor, uint8_t& bmcMinor,
+ uint8_t& meMajor, uint8_t& meMinor)
{
// step 1 : get BMC Major and Minor numbers from its DBUS property
- std::optional<MetaRevision> rev{};
- try
- {
- std::string version = getActiveSoftwareVersionInfo();
- rev = convertIntelVersion(version);
- }
- catch (const std::exception& e)
+ std::string bmcVersion;
+ if (getActiveSoftwareVersionInfo(ctx, versionPurposeBMC, bmcVersion))
{
return false;
}
+ std::optional<MetaRevision> rev = convertIntelVersion(bmcVersion);
if (rev.has_value())
{
MetaRevision revision = rev.value();
@@ -347,6 +343,9 @@
}
catch (sdbusplus::exception::SdBusError& e)
{
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Exception caught in ME version conversion",
+ phosphor::logging::entry("MSG=%s", e.what()));
return false;
}
return true;
@@ -358,7 +357,8 @@
std::array<uint8_t, 2>, std::array<uint8_t, 2>,
std::array<uint8_t, 2>, std::array<uint8_t, 2>>,
std::tuple<uint8_t, std::array<uint8_t, 2>>>>
- ipmiOEMGetDeviceInfo(uint8_t entityType, std::optional<uint8_t> countToRead,
+ ipmiOEMGetDeviceInfo(ipmi::Context::ptr ctx, uint8_t entityType,
+ std::optional<uint8_t> countToRead,
std::optional<uint8_t> offset)
{
if (entityType > static_cast<uint8_t>(OEMDevEntityType::sdrVer))
@@ -430,7 +430,7 @@
std::array<uint8_t, verLen> hsc2Buf = {0xff, 0xff};
// data0/1: BMC version number; data6/7: ME version number
// the others: HSC0/1/2 version number, not avaible.
- if (true != getSwVerInfo(bmcBuf[0], bmcBuf[1], meBuf[0], meBuf[1]))
+ if (!getSwVerInfo(ctx, bmcBuf[0], bmcBuf[1], meBuf[0], meBuf[1]))
{
return ipmi::responseUnspecifiedError();
}