From 071d8fdf75e78f189cf4d670854eb9a22f5e484c Mon Sep 17 00:00:00 2001 From: SunnySrivastava1984 Date: Wed, 28 Oct 2020 02:20:30 -0500 Subject: Add additional Redfish Manager properties This commit adds the following inventory properties for the BMC resource: a) LocationCode, a free form, implementation-defined string to provide the location of the BMC. This is needed so an implementation can identify the BMC via system diagrams and such. b) Model, maps to a CCIN/Card ID for IBM's implementation, is a string for the manufacturer's part model. For IBM's implementation, it is a four-digit value assigned for each possible FRU. c) SparePartNumber, also field-replaceable unit (FRU) Part Number, is a part number that identifies the FRU for replacement specifically ordering of a new part. For some manufacturers the BMC is soldered down, this is not the case for all manufacturers. For our systems, the BMC can be replaced and these properties are essential to locate and replace the BMC. Redfish validator has been executed on this change and no new error was found. Sample Output: { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_11_0.Manager", "Actions": { "#Manager.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Managers/bmc/ResetActionInfo", "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset" }, "#Manager.ResetToDefaults": { "ResetType@Redfish.AllowableValues": [ "ResetAll" ], "target": "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults" } }, "DateTime": "2020-12-18T07:37:34+00:00", "Description": "Baseboard Management Controller", "EthernetInterfaces": { "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces" }, "FirmwareVersion": "fw1020.00-12.1-10-g60fee5936", "GraphicalConsole": { "ConnectTypesSupported": [ "KVMIP" ], "MaxConcurrentSessions": 4, "ServiceEnabled": true }, "Id": "bmc", "LastResetTime": "2020-12-09T17:21:20+00:00", "Links": { "ActiveSoftwareImage": { "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/e7522a84" }, "ManagerForChassis": [ { "@odata.id": "/redfish/v1/Chassis/Nisqually_Backplane" } ], "ManagerForChassis@odata.count": 1, "ManagerForServers": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "ManagerForServers@odata.count": 1, "ManagerInChassis": { "@odata.id": "/redfish/v1/Chassis/Nisqually_Backplane" }, "SoftwareImages": [ { "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/e7522a84" } ], "SoftwareImages@odata.count": 1 }, "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND1.1234567-P0-C5" } }, "LogServices": { "@odata.id": "/redfish/v1/Managers/bmc/LogServices" }, "ManagerType": "BMC", "Manufacturer": "", "Model": "", "Name": "OpenBmc Manager", "NetworkProtocol": { "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol" }, "Oem": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem", "@odata.type": "#OemManager.Oem", "OpenBmc": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc", "@odata.type": "#OemManager.OpenBmc", "Certificates": { "@odata.id": "/redfish/v1/Managers/bmc/Truststore/Certificates" } } }, "PartNumber": "PN12345", "PowerState": "On", "SerialConsole": { "ConnectTypesSupported": [ "IPMI", "SSH" ], "MaxConcurrentSessions": 15, "ServiceEnabled": true }, "SerialNumber": "YL6B58010000", "ServiceEntryPointUUID": "280c3750-fa95-42cd-96aa-7834853bd922", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" }, "UUID": "35d98d20-cf67-4575-8aaa-0c40c398efdf" } Signed-off-by: Sunny Srivastava Change-Id: I53044fb0173be8fce7a13aadc2cf5c2903529486 --- redfish-core/lib/managers.hpp | 130 +++++++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 34 deletions(-) diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index 6347caf661..8953d7a46b 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -1686,6 +1686,49 @@ struct SetPIDValues : std::enable_shared_from_this size_t objectCount = 0; }; +/** + * @brief Retrieves BMC manager location data over DBus + * + * @param[in] aResp Shared pointer for completing asynchronous calls + * @param[in] connectionName - service name + * @param[in] path - object path + * @return none + */ +inline void getLocation(const std::shared_ptr& aResp, + const std::string& connectionName, + const std::string& path) +{ + BMCWEB_LOG_DEBUG << "Get BMC manager Location data."; + + crow::connections::systemBus->async_method_call( + [aResp](const boost::system::error_code ec, + const std::variant& property) { + if (ec) + { + BMCWEB_LOG_DEBUG << "DBUS response error for " + "Location"; + messages::internalError(aResp->res); + return; + } + + const std::string* value = std::get_if(&property); + + if (value == nullptr) + { + // illegal value + messages::internalError(aResp->res); + return; + } + + aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = + *value; + }, + connectionName, path, "org.freedesktop.DBus.Properties", "Get", + "xyz.openbmc_project.Inventory.Decorator." + "LocationCode", + "LocationCode"); +} + class Manager : public Node { public: @@ -1707,7 +1750,7 @@ class Manager : public Node const std::vector&) override { res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc"; - res.jsonValue["@odata.type"] = "#Manager.v1_9_0.Manager"; + res.jsonValue["@odata.type"] = "#Manager.v1_11_0.Manager"; res.jsonValue["Id"] = "bmc"; res.jsonValue["Name"] = "OpenBmc Manager"; res.jsonValue["Description"] = "Baseboard Management Controller"; @@ -1871,41 +1914,60 @@ class Manager : public Node const std::string& path = subtree[0].first; const std::string& connectionName = subtree[0].second[0].first; - crow::connections::systemBus->async_method_call( - [asyncResp]( - const boost::system::error_code ec, - const std::vector< - std::pair>>& - propertiesList) { - if (ec) - { - BMCWEB_LOG_DEBUG << "Can't get bmc asset!"; - return; - } - for (const std::pair>& - property : propertiesList) - { - const std::string& propertyName = property.first; - - if ((propertyName == "PartNumber") || - (propertyName == "SerialNumber") || - (propertyName == "Manufacturer")) - { - const std::string* value = - std::get_if(&property.second); - if (value == nullptr) + for (const auto& interfaceName : subtree[0].second[0].second) + { + if (interfaceName == + "xyz.openbmc_project.Inventory.Decorator.Asset") + { + crow::connections::systemBus->async_method_call( + [asyncResp]( + const boost::system::error_code ec, + const std::vector>>& + propertiesList) { + if (ec) { - // illegal property - messages::internalError(asyncResp->res); - continue; + BMCWEB_LOG_DEBUG << "Can't get bmc asset!"; + return; } - asyncResp->res.jsonValue[propertyName] = *value; - } - } - }, - connectionName, path, "org.freedesktop.DBus.Properties", - "GetAll", "xyz.openbmc_project.Inventory.Decorator.Asset"); + for (const std::pair>& + property : propertiesList) + { + const std::string& propertyName = + property.first; + + if ((propertyName == "PartNumber") || + (propertyName == "SerialNumber") || + (propertyName == "Manufacturer") || + (propertyName == "Model") || + (propertyName == "SparePartNumber")) + { + const std::string* value = + std::get_if( + &property.second); + if (value == nullptr) + { + // illegal property + messages::internalError( + asyncResp->res); + continue; + } + asyncResp->res.jsonValue[propertyName] = + *value; + } + } + }, + connectionName, path, + "org.freedesktop.DBus.Properties", "GetAll", + "xyz.openbmc_project.Inventory.Decorator.Asset"); + } + else if (interfaceName == "xyz.openbmc_project.Inventory." + "Decorator.LocationCode") + { + getLocation(asyncResp, connectionName, path); + } + } }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", -- cgit v1.2.3