Return active bmc fw version
Utilize the new utility interface to return the actively running BMC
firmware image. The current code just returns the first instance it
finds which is incorrect.
Tested:
cat /etc/os-release
ID="openbmc-phosphor"
NAME="Phosphor OpenBMC (Phosphor OpenBMC Project Reference Distro)"
VERSION="2.7.0-dev"
VERSION_ID="2.7.0-dev-1010-gb417d47"
Before Change:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/Managers/bmc | grep Firmware
"FirmwareVersion": "2.7.0-dev-999-gfbdb73f"
After Change:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/Managers/bmc | grep Firmware
"FirmwareVersion": "2.7.0-dev-1010-gb417d47",
Resolves openbmc/bmcweb#38
Change-Id: I50388c7adfaed8938e3a927becbebd801f0f7673
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 60f8856..2e2dbf1 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -24,6 +24,7 @@
#include <dbus_utility.hpp>
#include <memory>
#include <sstream>
+#include <utils/fw_utils.hpp>
#include <utils/systemd_utils.hpp>
#include <variant>
@@ -1527,49 +1528,8 @@
health->isManagersHealth = true;
health->populate();
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec,
- const dbus::utility::ManagedObjectType& resp) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error while getting Software Version";
- messages::internalError(asyncResp->res);
- return;
- }
-
- for (auto& objpath : resp)
- {
- for (auto& interface : objpath.second)
- {
- // If interface is
- // xyz.openbmc_project.Software.Version, this is
- // what we're looking for.
- if (interface.first ==
- "xyz.openbmc_project.Software.Version")
- {
- // Cut out everyting until last "/", ...
- for (auto& property : interface.second)
- {
- if (property.first == "Version")
- {
- const std::string* value =
- std::get_if<std::string>(
- &property.second);
- if (value == nullptr)
- {
- continue;
- }
- asyncResp->res
- .jsonValue["FirmwareVersion"] = *value;
- }
- }
- }
- }
- }
- },
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ fw_util::getActiveFwVersion(asyncResp, fw_util::bmcPurpose,
+ "FirmwareVersion");
auto pids = std::make_shared<GetPIDValues>(asyncResp);
pids->run();