update service: path change for D-Bus interface
Update the path to get software info because of D-Bus interface changes.
For more details refer to design -
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/65738
https://gerrit.openbmc.org/c/openbmc/docs/+/65739
Tested:
```
> curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc
...
"Links": {
"ActiveSoftwareImage": {
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/3c956be0"
},
...
"SoftwareImages": [
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/3c956be0"
}
],
"SoftwareImages@odata.count": 1
},
...
```
Redfish service validator passing:
```
Elapsed time: 0:04:33
metadataNamespaces: 3727
pass: 5184
passAction: 16
passGet: 213
passRedfishUri: 205
skipNoSchema: 3
skipOptional: 3535
unvalidated: 1
warnDeprecated: 5
warningPresent: 6
```
Change-Id: Ifc41c0ca54c6f5dfae5a9245ab756c21155e816d
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp
index f5c4f0f..f871d66 100644
--- a/redfish-core/include/utils/sw_utils.hpp
+++ b/redfish-core/include/utils/sw_utils.hpp
@@ -13,6 +13,7 @@
#include <algorithm>
#include <array>
+#include <optional>
#include <ranges>
#include <string>
#include <string_view>
@@ -30,6 +31,42 @@
constexpr const char* bmcPurpose =
"xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
+inline std::optional<sdbusplus::message::object_path>
+ getFunctionalSoftwarePath(const std::string& swType)
+{
+ if (swType == bmcPurpose)
+ {
+ if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS)
+ {
+ return sdbusplus::message::object_path(
+ "/xyz/openbmc_project/software/bmc/functional");
+ }
+ else
+ {
+ return sdbusplus::message::object_path(
+ "/xyz/openbmc_project/software/functional");
+ }
+ }
+ else if (swType == biosPurpose)
+ {
+ if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS)
+ {
+ return sdbusplus::message::object_path(
+ "/xyz/openbmc_project/software/bios/functional");
+ }
+ else
+ {
+ return sdbusplus::message::object_path(
+ "/xyz/openbmc_project/software/functional");
+ }
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR("No valid software path");
+ return std::nullopt;
+ }
+}
+
/**
* @brief Populate the running software version and image links
*
@@ -48,9 +85,16 @@
const std::string& swVersionPurpose,
const std::string& activeVersionPropName, const bool populateLinkToImages)
{
+ auto swPath = getFunctionalSoftwarePath(swVersionPurpose);
+ if (!swPath)
+ {
+ BMCWEB_LOG_ERROR("Invalid software type");
+ messages::internalError(asyncResp->res);
+ return;
+ }
// Used later to determine running (known on Redfish as active) Sw images
dbus::utility::getAssociationEndPoints(
- "/xyz/openbmc_project/software/functional",
+ swPath.value().str,
[asyncResp, swVersionPurpose, activeVersionPropName,
populateLinkToImages](
const boost::system::error_code& ec,