summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Redfish.md2
-rw-r--r--redfish-core/lib/cable.hpp46
2 files changed, 37 insertions, 11 deletions
diff --git a/Redfish.md b/Redfish.md
index 0772b8e44d..32e266af21 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -33,6 +33,7 @@ Fields common to all schemas
- AccountService
- AggregationService
+- Cables
- CertificateService
- Chassis
- EventService
@@ -162,6 +163,7 @@ Fields common to all schemas
- CableType
- LengthMeters
+- Status
### /redfish/v1/CertificateService/
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;