summaryrefslogtreecommitdiff
path: root/redfish-core/lib/cable.hpp
diff options
context:
space:
mode:
authorAkshit Shah <shahakshit@google.com>2023-01-24 04:03:26 +0300
committerEd Tanous <edtanous@google.com>2023-07-20 21:29:57 +0300
commit0c2ba59dd0532480970517457fae9f4739790c81 (patch)
tree8514795886fb436de54825b715c1e2774e855f3e /redfish-core/lib/cable.hpp
parentb10d8db03f31b4aee15bdcb10d17975677f01625 (diff)
downloadbmcweb-0c2ba59dd0532480970517457fae9f4739790c81.tar.xz
Report status state field for cable objects
Tested: Added and removed cables to see state field being reflected based on the presence. Change-Id: I0136b1407634ebc9033a7c3ea2da555018fd622b Signed-off-by: Akshit Shah <shahakshit@google.com>
Diffstat (limited to 'redfish-core/lib/cable.hpp')
-rw-r--r--redfish-core/lib/cable.hpp46
1 files changed, 35 insertions, 11 deletions
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index 265a1ea4d5..28031e13b2 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -89,19 +89,42 @@ inline void
{
for (const auto& interface : interfaces)
{
- if (interface != "xyz.openbmc_project.Inventory.Item.Cable")
+ if (interface == "xyz.openbmc_project.Inventory.Item.Cable")
{
- continue;
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, service, cableObjectPath,
+ interface,
+ [asyncResp](
+ const boost::system::error_code& ec,
+ const dbus::utility::DBusPropertiesMap& properties) {
+ fillCableProperties(asyncResp->res, ec, properties);
+ });
+ }
+ else if (interface == "xyz.openbmc_project.Inventory.Item")
+ {
+ sdbusplus::asio::getProperty<bool>(
+ *crow::connections::systemBus, service, cableObjectPath,
+ interface, "Present",
+ [asyncResp, cableObjectPath](
+ const boost::system::error_code& ec, bool present) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG(
+ "get presence failed for Cable {} with error {}",
+ cableObjectPath, ec);
+ if (ec.value() != EBADR)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ return;
+ }
+
+ if (!present)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] = "Absent";
+ }
+ });
}
-
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, service, cableObjectPath,
- interface,
- [asyncResp](
- const boost::system::error_code& ec,
- const dbus::utility::DBusPropertiesMap& properties) {
- fillCableProperties(asyncResp->res, ec, properties);
- });
}
}
}
@@ -155,6 +178,7 @@ inline void requestRoutesCable(App& app)
boost::urls::format("/redfish/v1/Cables/{}", cableId);
asyncResp->res.jsonValue["Id"] = cableId;
asyncResp->res.jsonValue["Name"] = "Cable";
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
getCableProperties(asyncResp, objectPath, serviceMap);
return;