summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAppaRao Puli <apparao.puli@linux.intel.com>2020-01-29 02:36:32 +0530
committerAppaRao Puli <apparao.puli@linux.intel.com>2020-02-03 23:27:27 +0530
commit3f8a743a5179eb618518ff04b98202a997342bb0 (patch)
treeaf0a5e1f73db9aead44687fd2c7ec7239ea3a5e7
parentc7a29d366c958bd20509ba88d17c4fb3cb38d7ef (diff)
downloadbmcweb-3f8a743a5179eb618518ff04b98202a997342bb0.tar.gz
bmcweb-3f8a743a5179eb618518ff04b98202a997342bb0.zip
Add support to fetch the 'Updateable' components
Currently 'Updateable' property value in SoftwareInventory schema is hardcoded. Added support to look through the updateable software associations objects and use it for 'Updateable' Redfish property in SoftwareInventory. Tested: - Checked 'Updateable' Property value for both programmable and non-programmable firmware inventory components and it works as expected. - Ran the Redfish validator and no new issues found. Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> Change-Id: Ia24f942f3afe49674ec3628cac0356a5496ef337
-rw-r--r--redfish-core/include/utils/fw_utils.hpp61
-rw-r--r--redfish-core/lib/update_service.hpp4
2 files changed, 58 insertions, 7 deletions
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 2f14358..653b067 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -202,13 +202,13 @@ std::string getRedfishFWState(const std::string &fwState)
{
return "Enabled";
}
- else if (fwState ==
- "xyz.openbmc_project.Software.Activation.Activations.Activating")
+ else if (fwState == "xyz.openbmc_project.Software.Activation."
+ "Activations.Activating")
{
return "Updating";
}
- else if (fwState ==
- "xyz.openbmc_project.Software.Activation.Activations.StandbySpare")
+ else if (fwState == "xyz.openbmc_project.Software.Activation."
+ "Activations.StandbySpare")
{
return "StandbySpare";
}
@@ -232,8 +232,8 @@ std::string getRedfishFWHealth(const std::string &fwState)
{
if ((fwState ==
"xyz.openbmc_project.Software.Activation.Activations.Active") ||
- (fwState ==
- "xyz.openbmc_project.Software.Activation.Activations.Activating") ||
+ (fwState == "xyz.openbmc_project.Software.Activation.Activations."
+ "Activating") ||
(fwState ==
"xyz.openbmc_project.Software.Activation.Activations.Ready"))
{
@@ -302,5 +302,54 @@ void getFwStatus(std::shared_ptr<AsyncResp> asyncResp,
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Software.Activation");
}
+
+/**
+ * @brief Updates programmable status of input swId into json response
+ *
+ * This function checks whether firmware inventory component
+ * can be programable or not and fill's the "Updateable"
+ * Property.
+ *
+ * @param[i,o] asyncResp Async response object
+ * @param[i] fwId The firmware ID
+ */
+void getFwUpdateableStatus(std::shared_ptr<AsyncResp> asyncResp,
+ const std::shared_ptr<std::string> fwId)
+{
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, fwId](const boost::system::error_code ec,
+ const std::variant<std::vector<std::string>> &resp) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << __FUNCTION__ << " error_code = " << ec
+ << " error msg = " << ec.message();
+ // System can exist with no updateable firmware,
+ // so don't throw error here.
+ return;
+ }
+ const std::vector<std::string> *objPaths =
+ std::get_if<std::vector<std::string>>(&resp);
+ if (objPaths)
+ {
+ std::string reqFwObjPath =
+ "/xyz/openbmc_project/software/" + *fwId;
+
+ if (std::find((*objPaths).begin(), (*objPaths).end(),
+ reqFwObjPath) != (*objPaths).end())
+ {
+ asyncResp->res.jsonValue["Updateable"] = true;
+ return;
+ }
+ }
+ return;
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/software/updateable",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.Association", "endpoints");
+
+ return;
+}
+
} // namespace fw_util
} // namespace redfish
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index ec9600e..048430d 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -775,8 +775,10 @@ class SoftwareInventory : public Node
asyncResp->res.jsonValue["@odata.context"] =
"/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory";
asyncResp->res.jsonValue["Name"] = "Software Inventory";
- asyncResp->res.jsonValue["Updateable"] = false;
asyncResp->res.jsonValue["Status"]["HealthRollup"] = "OK";
+
+ asyncResp->res.jsonValue["Updateable"] = false;
+ fw_util::getFwUpdateableStatus(asyncResp, swId);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
OpenPOWER on IntegriCloud