Remove unnecessary error responses for LDAP certs
Currently, /v1/CertificateService/CertificateLocations and
/v1/AccountService/LDAP/Certificates endpoints assume the presence of
xyz.openbmc_project.Certs.Manager.Client.Ldap service, and return an
error on D-Bus failures. But this service can be missing if LDAP support
is removed from the build, so we should just return empty responses
instead of errors.
Tested: Passed Redfish service validator.
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Change-Id: Ib8416e850b52e8ce0f8947017d863cee19f7b2c8
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 81d9d05..d690dcf 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -1029,8 +1029,9 @@
const ManagedObjectType& certs) {
if (ec)
{
- BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_WARNING
+ << "Certificate collection query failed: " << ec
+ << ", skipping " << certURL;
return;
}
nlohmann::json& links =
@@ -1080,14 +1081,17 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
const ManagedObjectType& certs) {
+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
+ nlohmann::json& count =
+ asyncResp->res.jsonValue["Members@odata.count"];
+ members = nlohmann::json::array();
+ count = 0;
if (ec)
{
- BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_WARNING << "LDAP certificate query failed: "
+ << ec;
return;
}
- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- members = nlohmann::json::array();
for (const auto& cert : certs)
{
long id = getIDFromURL(cert.first.str);
@@ -1099,8 +1103,7 @@
std::to_string(id)}});
}
}
- asyncResp->res.jsonValue["Members@odata.count"] =
- members.size();
+ count = members.size();
},
certs::ldapServiceName, certs::ldapObjectPath,
certs::dbusObjManagerIntf, "GetManagedObjects");