19c310685SBorawski.Lukasz /* 29c310685SBorawski.Lukasz // Copyright (c) 2018 Intel Corporation 39c310685SBorawski.Lukasz // 49c310685SBorawski.Lukasz // Licensed under the Apache License, Version 2.0 (the "License"); 59c310685SBorawski.Lukasz // you may not use this file except in compliance with the License. 69c310685SBorawski.Lukasz // You may obtain a copy of the License at 79c310685SBorawski.Lukasz // 89c310685SBorawski.Lukasz // http://www.apache.org/licenses/LICENSE-2.0 99c310685SBorawski.Lukasz // 109c310685SBorawski.Lukasz // Unless required by applicable law or agreed to in writing, software 119c310685SBorawski.Lukasz // distributed under the License is distributed on an "AS IS" BASIS, 129c310685SBorawski.Lukasz // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139c310685SBorawski.Lukasz // See the License for the specific language governing permissions and 149c310685SBorawski.Lukasz // limitations under the License. 159c310685SBorawski.Lukasz */ 169c310685SBorawski.Lukasz #pragma once 179c310685SBorawski.Lukasz 18b49ac873SJames Feist #include "health.hpp" 19c5d03ff4SJennifer Lee #include "redfish_util.hpp" 209c310685SBorawski.Lukasz 217e860f15SJohn Edward Broadbent #include <app.hpp> 225b4aa86bSJames Feist #include <boost/algorithm/string/replace.hpp> 23af5d6058SSantosh Puranik #include <boost/date_time.hpp> 245b4aa86bSJames Feist #include <dbus_utility.hpp> 25*45ca1b86SEd Tanous #include <query.hpp> 26ed398213SEd Tanous #include <registries/privilege_registry.hpp> 27e90c5052SAndrew Geissler #include <utils/fw_utils.hpp> 287bffdb7eSBernard Wong #include <utils/systemd_utils.hpp> 291214b7e7SGunnar Mills 304bfefa74SGunnar Mills #include <cstdint> 311214b7e7SGunnar Mills #include <memory> 321214b7e7SGunnar Mills #include <sstream> 33abf2add6SEd Tanous #include <variant> 345b4aa86bSJames Feist 351abe55efSEd Tanous namespace redfish 361abe55efSEd Tanous { 37ed5befbdSJennifer Lee 38ed5befbdSJennifer Lee /** 392a5c4407SGunnar Mills * Function reboots the BMC. 402a5c4407SGunnar Mills * 412a5c4407SGunnar Mills * @param[in] asyncResp - Shared pointer for completing asynchronous calls 42ed5befbdSJennifer Lee */ 438d1b46d7Szhanghch05 inline void 448d1b46d7Szhanghch05 doBMCGracefulRestart(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 45ed5befbdSJennifer Lee { 46ed5befbdSJennifer Lee const char* processName = "xyz.openbmc_project.State.BMC"; 47ed5befbdSJennifer Lee const char* objectPath = "/xyz/openbmc_project/state/bmc0"; 48ed5befbdSJennifer Lee const char* interfaceName = "xyz.openbmc_project.State.BMC"; 49ed5befbdSJennifer Lee const std::string& propertyValue = 50ed5befbdSJennifer Lee "xyz.openbmc_project.State.BMC.Transition.Reboot"; 51ed5befbdSJennifer Lee const char* destProperty = "RequestedBMCTransition"; 52ed5befbdSJennifer Lee 53ed5befbdSJennifer Lee // Create the D-Bus variant for D-Bus call. 54168e20c1SEd Tanous dbus::utility::DbusVariantType dbusPropertyValue(propertyValue); 55ed5befbdSJennifer Lee 56ed5befbdSJennifer Lee crow::connections::systemBus->async_method_call( 57ed5befbdSJennifer Lee [asyncResp](const boost::system::error_code ec) { 58ed5befbdSJennifer Lee // Use "Set" method to set the property value. 59ed5befbdSJennifer Lee if (ec) 60ed5befbdSJennifer Lee { 612a5c4407SGunnar Mills BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; 62ed5befbdSJennifer Lee messages::internalError(asyncResp->res); 63ed5befbdSJennifer Lee return; 64ed5befbdSJennifer Lee } 65ed5befbdSJennifer Lee 66ed5befbdSJennifer Lee messages::success(asyncResp->res); 67ed5befbdSJennifer Lee }, 68ed5befbdSJennifer Lee processName, objectPath, "org.freedesktop.DBus.Properties", "Set", 69ed5befbdSJennifer Lee interfaceName, destProperty, dbusPropertyValue); 70ed5befbdSJennifer Lee } 712a5c4407SGunnar Mills 728d1b46d7Szhanghch05 inline void 738d1b46d7Szhanghch05 doBMCForceRestart(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 74f92af389SJayaprakash Mutyala { 75f92af389SJayaprakash Mutyala const char* processName = "xyz.openbmc_project.State.BMC"; 76f92af389SJayaprakash Mutyala const char* objectPath = "/xyz/openbmc_project/state/bmc0"; 77f92af389SJayaprakash Mutyala const char* interfaceName = "xyz.openbmc_project.State.BMC"; 78f92af389SJayaprakash Mutyala const std::string& propertyValue = 79f92af389SJayaprakash Mutyala "xyz.openbmc_project.State.BMC.Transition.HardReboot"; 80f92af389SJayaprakash Mutyala const char* destProperty = "RequestedBMCTransition"; 81f92af389SJayaprakash Mutyala 82f92af389SJayaprakash Mutyala // Create the D-Bus variant for D-Bus call. 83168e20c1SEd Tanous dbus::utility::DbusVariantType dbusPropertyValue(propertyValue); 84f92af389SJayaprakash Mutyala 85f92af389SJayaprakash Mutyala crow::connections::systemBus->async_method_call( 86f92af389SJayaprakash Mutyala [asyncResp](const boost::system::error_code ec) { 87f92af389SJayaprakash Mutyala // Use "Set" method to set the property value. 88f92af389SJayaprakash Mutyala if (ec) 89f92af389SJayaprakash Mutyala { 90f92af389SJayaprakash Mutyala BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; 91f92af389SJayaprakash Mutyala messages::internalError(asyncResp->res); 92f92af389SJayaprakash Mutyala return; 93f92af389SJayaprakash Mutyala } 94f92af389SJayaprakash Mutyala 95f92af389SJayaprakash Mutyala messages::success(asyncResp->res); 96f92af389SJayaprakash Mutyala }, 97f92af389SJayaprakash Mutyala processName, objectPath, "org.freedesktop.DBus.Properties", "Set", 98f92af389SJayaprakash Mutyala interfaceName, destProperty, dbusPropertyValue); 99f92af389SJayaprakash Mutyala } 100f92af389SJayaprakash Mutyala 1012a5c4407SGunnar Mills /** 1022a5c4407SGunnar Mills * ManagerResetAction class supports the POST method for the Reset (reboot) 1032a5c4407SGunnar Mills * action. 1042a5c4407SGunnar Mills */ 1057e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetAction(App& app) 1062a5c4407SGunnar Mills { 1072a5c4407SGunnar Mills /** 1082a5c4407SGunnar Mills * Function handles POST method request. 1092a5c4407SGunnar Mills * Analyzes POST body before sending Reset (Reboot) request data to D-Bus. 110f92af389SJayaprakash Mutyala * OpenBMC supports ResetType "GracefulRestart" and "ForceRestart". 1112a5c4407SGunnar Mills */ 1127e860f15SJohn Edward Broadbent 1137e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Actions/Manager.Reset/") 114ed398213SEd Tanous .privileges(redfish::privileges::postManager) 1157e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::post)( 116*45ca1b86SEd Tanous [&app](const crow::Request& req, 1177e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 118*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 119*45ca1b86SEd Tanous { 120*45ca1b86SEd Tanous return; 121*45ca1b86SEd Tanous } 1222a5c4407SGunnar Mills BMCWEB_LOG_DEBUG << "Post Manager Reset."; 1232a5c4407SGunnar Mills 1242a5c4407SGunnar Mills std::string resetType; 1252a5c4407SGunnar Mills 12615ed6780SWilly Tu if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", 1277e860f15SJohn Edward Broadbent resetType)) 1282a5c4407SGunnar Mills { 1292a5c4407SGunnar Mills return; 1302a5c4407SGunnar Mills } 1312a5c4407SGunnar Mills 132f92af389SJayaprakash Mutyala if (resetType == "GracefulRestart") 133f92af389SJayaprakash Mutyala { 134f92af389SJayaprakash Mutyala BMCWEB_LOG_DEBUG << "Proceeding with " << resetType; 135f92af389SJayaprakash Mutyala doBMCGracefulRestart(asyncResp); 136f92af389SJayaprakash Mutyala return; 137f92af389SJayaprakash Mutyala } 1383174e4dfSEd Tanous if (resetType == "ForceRestart") 139f92af389SJayaprakash Mutyala { 140f92af389SJayaprakash Mutyala BMCWEB_LOG_DEBUG << "Proceeding with " << resetType; 141f92af389SJayaprakash Mutyala doBMCForceRestart(asyncResp); 142f92af389SJayaprakash Mutyala return; 143f92af389SJayaprakash Mutyala } 1442a5c4407SGunnar Mills BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: " 1452a5c4407SGunnar Mills << resetType; 1462a5c4407SGunnar Mills messages::actionParameterNotSupported(asyncResp->res, resetType, 1472a5c4407SGunnar Mills "ResetType"); 1482a5c4407SGunnar Mills 1492a5c4407SGunnar Mills return; 1507e860f15SJohn Edward Broadbent }); 1512a5c4407SGunnar Mills } 152ed5befbdSJennifer Lee 1533e40fc74SGunnar Mills /** 1543e40fc74SGunnar Mills * ManagerResetToDefaultsAction class supports POST method for factory reset 1553e40fc74SGunnar Mills * action. 1563e40fc74SGunnar Mills */ 1577e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetToDefaultsAction(App& app) 1583e40fc74SGunnar Mills { 1593e40fc74SGunnar Mills 1603e40fc74SGunnar Mills /** 1613e40fc74SGunnar Mills * Function handles ResetToDefaults POST method request. 1623e40fc74SGunnar Mills * 1633e40fc74SGunnar Mills * Analyzes POST body message and factory resets BMC by calling 1643e40fc74SGunnar Mills * BMC code updater factory reset followed by a BMC reboot. 1653e40fc74SGunnar Mills * 1663e40fc74SGunnar Mills * BMC code updater factory reset wipes the whole BMC read-write 1673e40fc74SGunnar Mills * filesystem which includes things like the network settings. 1683e40fc74SGunnar Mills * 1693e40fc74SGunnar Mills * OpenBMC only supports ResetToDefaultsType "ResetAll". 1703e40fc74SGunnar Mills */ 1717e860f15SJohn Edward Broadbent 1727e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, 1737e860f15SJohn Edward Broadbent "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults/") 174ed398213SEd Tanous .privileges(redfish::privileges::postManager) 1757e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::post)( 176*45ca1b86SEd Tanous [&app](const crow::Request& req, 1777e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 178*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 179*45ca1b86SEd Tanous { 180*45ca1b86SEd Tanous return; 181*45ca1b86SEd Tanous } 1823e40fc74SGunnar Mills BMCWEB_LOG_DEBUG << "Post ResetToDefaults."; 1833e40fc74SGunnar Mills 1843e40fc74SGunnar Mills std::string resetType; 1853e40fc74SGunnar Mills 18615ed6780SWilly Tu if (!json_util::readJsonAction( 18715ed6780SWilly Tu req, asyncResp->res, "ResetToDefaultsType", resetType)) 1883e40fc74SGunnar Mills { 1893e40fc74SGunnar Mills BMCWEB_LOG_DEBUG << "Missing property ResetToDefaultsType."; 1903e40fc74SGunnar Mills 1917e860f15SJohn Edward Broadbent messages::actionParameterMissing(asyncResp->res, 1927e860f15SJohn Edward Broadbent "ResetToDefaults", 1933e40fc74SGunnar Mills "ResetToDefaultsType"); 1943e40fc74SGunnar Mills return; 1953e40fc74SGunnar Mills } 1963e40fc74SGunnar Mills 1973e40fc74SGunnar Mills if (resetType != "ResetAll") 1983e40fc74SGunnar Mills { 1990fda0f12SGeorge Liu BMCWEB_LOG_DEBUG 2000fda0f12SGeorge Liu << "Invalid property value for ResetToDefaultsType: " 2013e40fc74SGunnar Mills << resetType; 2027e860f15SJohn Edward Broadbent messages::actionParameterNotSupported( 2037e860f15SJohn Edward Broadbent asyncResp->res, resetType, "ResetToDefaultsType"); 2043e40fc74SGunnar Mills return; 2053e40fc74SGunnar Mills } 2063e40fc74SGunnar Mills 2073e40fc74SGunnar Mills crow::connections::systemBus->async_method_call( 2083e40fc74SGunnar Mills [asyncResp](const boost::system::error_code ec) { 2093e40fc74SGunnar Mills if (ec) 2103e40fc74SGunnar Mills { 2117e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG << "Failed to ResetToDefaults: " 2127e860f15SJohn Edward Broadbent << ec; 2133e40fc74SGunnar Mills messages::internalError(asyncResp->res); 2143e40fc74SGunnar Mills return; 2153e40fc74SGunnar Mills } 2163e40fc74SGunnar Mills // Factory Reset doesn't actually happen until a reboot 2173e40fc74SGunnar Mills // Can't erase what the BMC is running on 2183e40fc74SGunnar Mills doBMCGracefulRestart(asyncResp); 2193e40fc74SGunnar Mills }, 2203e40fc74SGunnar Mills "xyz.openbmc_project.Software.BMC.Updater", 2213e40fc74SGunnar Mills "/xyz/openbmc_project/software", 2223e40fc74SGunnar Mills "xyz.openbmc_project.Common.FactoryReset", "Reset"); 2237e860f15SJohn Edward Broadbent }); 2243e40fc74SGunnar Mills } 2253e40fc74SGunnar Mills 2261cb1a9e6SAppaRao Puli /** 2271cb1a9e6SAppaRao Puli * ManagerResetActionInfo derived class for delivering Manager 2281cb1a9e6SAppaRao Puli * ResetType AllowableValues using ResetInfo schema. 2291cb1a9e6SAppaRao Puli */ 2307e860f15SJohn Edward Broadbent inline void requestRoutesManagerResetActionInfo(App& app) 2311cb1a9e6SAppaRao Puli { 2321cb1a9e6SAppaRao Puli /** 2331cb1a9e6SAppaRao Puli * Functions triggers appropriate requests on DBus 2341cb1a9e6SAppaRao Puli */ 2357e860f15SJohn Edward Broadbent 2367e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/ResetActionInfo/") 237ed398213SEd Tanous .privileges(redfish::privileges::getActionInfo) 2387e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::get)( 239*45ca1b86SEd Tanous [&app](const crow::Request& req, 2407e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 241*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 242*45ca1b86SEd Tanous { 243*45ca1b86SEd Tanous return; 244*45ca1b86SEd Tanous } 2458d1b46d7Szhanghch05 asyncResp->res.jsonValue = { 2461cb1a9e6SAppaRao Puli {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"}, 2471cb1a9e6SAppaRao Puli {"@odata.id", "/redfish/v1/Managers/bmc/ResetActionInfo"}, 2481cb1a9e6SAppaRao Puli {"Name", "Reset Action Info"}, 2491cb1a9e6SAppaRao Puli {"Id", "ResetActionInfo"}, 2501cb1a9e6SAppaRao Puli {"Parameters", 2511cb1a9e6SAppaRao Puli {{{"Name", "ResetType"}, 2521cb1a9e6SAppaRao Puli {"Required", true}, 2531cb1a9e6SAppaRao Puli {"DataType", "String"}, 2547e860f15SJohn Edward Broadbent {"AllowableValues", 2557e860f15SJohn Edward Broadbent {"GracefulRestart", "ForceRestart"}}}}}}; 2567e860f15SJohn Edward Broadbent }); 2571cb1a9e6SAppaRao Puli } 2581cb1a9e6SAppaRao Puli 2595b4aa86bSJames Feist static constexpr const char* objectManagerIface = 2605b4aa86bSJames Feist "org.freedesktop.DBus.ObjectManager"; 2615b4aa86bSJames Feist static constexpr const char* pidConfigurationIface = 2625b4aa86bSJames Feist "xyz.openbmc_project.Configuration.Pid"; 2635b4aa86bSJames Feist static constexpr const char* pidZoneConfigurationIface = 2645b4aa86bSJames Feist "xyz.openbmc_project.Configuration.Pid.Zone"; 265b7a08d04SJames Feist static constexpr const char* stepwiseConfigurationIface = 266b7a08d04SJames Feist "xyz.openbmc_project.Configuration.Stepwise"; 26773df0db0SJames Feist static constexpr const char* thermalModeIface = 26873df0db0SJames Feist "xyz.openbmc_project.Control.ThermalMode"; 2699c310685SBorawski.Lukasz 2708d1b46d7Szhanghch05 inline void 2718d1b46d7Szhanghch05 asyncPopulatePid(const std::string& connection, const std::string& path, 27273df0db0SJames Feist const std::string& currentProfile, 27373df0db0SJames Feist const std::vector<std::string>& supportedProfiles, 2748d1b46d7Szhanghch05 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 2755b4aa86bSJames Feist { 2765b4aa86bSJames Feist 2775b4aa86bSJames Feist crow::connections::systemBus->async_method_call( 27873df0db0SJames Feist [asyncResp, currentProfile, supportedProfiles]( 27973df0db0SJames Feist const boost::system::error_code ec, 2805b4aa86bSJames Feist const dbus::utility::ManagedObjectType& managedObj) { 2815b4aa86bSJames Feist if (ec) 2825b4aa86bSJames Feist { 2835b4aa86bSJames Feist BMCWEB_LOG_ERROR << ec; 2845b4aa86bSJames Feist asyncResp->res.jsonValue.clear(); 285f12894f8SJason M. Bills messages::internalError(asyncResp->res); 2865b4aa86bSJames Feist return; 2875b4aa86bSJames Feist } 2885b4aa86bSJames Feist nlohmann::json& configRoot = 2895b4aa86bSJames Feist asyncResp->res.jsonValue["Oem"]["OpenBmc"]["Fan"]; 2905b4aa86bSJames Feist nlohmann::json& fans = configRoot["FanControllers"]; 2915b4aa86bSJames Feist fans["@odata.type"] = "#OemManager.FanControllers"; 2920fda0f12SGeorge Liu fans["@odata.id"] = 2930fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers"; 2945b4aa86bSJames Feist 2955b4aa86bSJames Feist nlohmann::json& pids = configRoot["PidControllers"]; 2965b4aa86bSJames Feist pids["@odata.type"] = "#OemManager.PidControllers"; 2975b4aa86bSJames Feist pids["@odata.id"] = 2985b4aa86bSJames Feist "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers"; 2995b4aa86bSJames Feist 300b7a08d04SJames Feist nlohmann::json& stepwise = configRoot["StepwiseControllers"]; 301b7a08d04SJames Feist stepwise["@odata.type"] = "#OemManager.StepwiseControllers"; 302b7a08d04SJames Feist stepwise["@odata.id"] = 303b7a08d04SJames Feist "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers"; 304b7a08d04SJames Feist 3055b4aa86bSJames Feist nlohmann::json& zones = configRoot["FanZones"]; 3065b4aa86bSJames Feist zones["@odata.id"] = 3075b4aa86bSJames Feist "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones"; 3085b4aa86bSJames Feist zones["@odata.type"] = "#OemManager.FanZones"; 3095b4aa86bSJames Feist configRoot["@odata.id"] = 3105b4aa86bSJames Feist "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan"; 3115b4aa86bSJames Feist configRoot["@odata.type"] = "#OemManager.Fan"; 31273df0db0SJames Feist configRoot["Profile@Redfish.AllowableValues"] = supportedProfiles; 31373df0db0SJames Feist 31473df0db0SJames Feist if (!currentProfile.empty()) 31573df0db0SJames Feist { 31673df0db0SJames Feist configRoot["Profile"] = currentProfile; 31773df0db0SJames Feist } 31873df0db0SJames Feist BMCWEB_LOG_ERROR << "profile = " << currentProfile << " !"; 3195b4aa86bSJames Feist 3205b4aa86bSJames Feist for (const auto& pathPair : managedObj) 3215b4aa86bSJames Feist { 3225b4aa86bSJames Feist for (const auto& intfPair : pathPair.second) 3235b4aa86bSJames Feist { 3245b4aa86bSJames Feist if (intfPair.first != pidConfigurationIface && 325b7a08d04SJames Feist intfPair.first != pidZoneConfigurationIface && 326b7a08d04SJames Feist intfPair.first != stepwiseConfigurationIface) 3275b4aa86bSJames Feist { 3285b4aa86bSJames Feist continue; 3295b4aa86bSJames Feist } 33073df0db0SJames Feist 331711ac7a9SEd Tanous std::string name; 332711ac7a9SEd Tanous 333711ac7a9SEd Tanous for (const std::pair<std::string, 334711ac7a9SEd Tanous dbus::utility::DbusVariantType>& 335711ac7a9SEd Tanous propPair : intfPair.second) 336711ac7a9SEd Tanous { 337711ac7a9SEd Tanous if (propPair.first == "Name") 338711ac7a9SEd Tanous { 3395b4aa86bSJames Feist const std::string* namePtr = 340711ac7a9SEd Tanous std::get_if<std::string>(&propPair.second); 3415b4aa86bSJames Feist if (namePtr == nullptr) 3425b4aa86bSJames Feist { 3435b4aa86bSJames Feist BMCWEB_LOG_ERROR << "Pid Name Field illegal"; 344b7a08d04SJames Feist messages::internalError(asyncResp->res); 3455b4aa86bSJames Feist return; 3465b4aa86bSJames Feist } 347db697703SWilly Tu name = *namePtr; 3485b4aa86bSJames Feist dbus::utility::escapePathForDbus(name); 349711ac7a9SEd Tanous } 350711ac7a9SEd Tanous else if (propPair.first == "Profiles") 35173df0db0SJames Feist { 35273df0db0SJames Feist const std::vector<std::string>* profiles = 35373df0db0SJames Feist std::get_if<std::vector<std::string>>( 354711ac7a9SEd Tanous &propPair.second); 35573df0db0SJames Feist if (profiles == nullptr) 35673df0db0SJames Feist { 357711ac7a9SEd Tanous BMCWEB_LOG_ERROR 358711ac7a9SEd Tanous << "Pid Profiles Field illegal"; 35973df0db0SJames Feist messages::internalError(asyncResp->res); 36073df0db0SJames Feist return; 36173df0db0SJames Feist } 36273df0db0SJames Feist if (std::find(profiles->begin(), profiles->end(), 36373df0db0SJames Feist currentProfile) == profiles->end()) 36473df0db0SJames Feist { 36573df0db0SJames Feist BMCWEB_LOG_INFO 366711ac7a9SEd Tanous << name 367711ac7a9SEd Tanous << " not supported in current profile"; 36873df0db0SJames Feist continue; 36973df0db0SJames Feist } 37073df0db0SJames Feist } 371711ac7a9SEd Tanous } 372b7a08d04SJames Feist nlohmann::json* config = nullptr; 373c33a90ecSJames Feist const std::string* classPtr = nullptr; 374711ac7a9SEd Tanous 375711ac7a9SEd Tanous for (const std::pair<std::string, 376711ac7a9SEd Tanous dbus::utility::DbusVariantType>& 377711ac7a9SEd Tanous propPair : intfPair.second) 378c33a90ecSJames Feist { 379727dc83fSLei YU if (propPair.first == "Class") 380711ac7a9SEd Tanous { 381711ac7a9SEd Tanous classPtr = 382711ac7a9SEd Tanous std::get_if<std::string>(&propPair.second); 383711ac7a9SEd Tanous } 384c33a90ecSJames Feist } 385c33a90ecSJames Feist 3865b4aa86bSJames Feist if (intfPair.first == pidZoneConfigurationIface) 3875b4aa86bSJames Feist { 3885b4aa86bSJames Feist std::string chassis; 3895b4aa86bSJames Feist if (!dbus::utility::getNthStringFromPath( 3905b4aa86bSJames Feist pathPair.first.str, 5, chassis)) 3915b4aa86bSJames Feist { 3925b4aa86bSJames Feist chassis = "#IllegalValue"; 3935b4aa86bSJames Feist } 3945b4aa86bSJames Feist nlohmann::json& zone = zones[name]; 3955b4aa86bSJames Feist zone["Chassis"] = { 3965b4aa86bSJames Feist {"@odata.id", "/redfish/v1/Chassis/" + chassis}}; 3970fda0f12SGeorge Liu zone["@odata.id"] = 3980fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" + 3995b4aa86bSJames Feist name; 4005b4aa86bSJames Feist zone["@odata.type"] = "#OemManager.FanZone"; 401b7a08d04SJames Feist config = &zone; 4025b4aa86bSJames Feist } 4035b4aa86bSJames Feist 404b7a08d04SJames Feist else if (intfPair.first == stepwiseConfigurationIface) 4055b4aa86bSJames Feist { 406c33a90ecSJames Feist if (classPtr == nullptr) 407c33a90ecSJames Feist { 408c33a90ecSJames Feist BMCWEB_LOG_ERROR << "Pid Class Field illegal"; 409c33a90ecSJames Feist messages::internalError(asyncResp->res); 410c33a90ecSJames Feist return; 411c33a90ecSJames Feist } 412c33a90ecSJames Feist 413b7a08d04SJames Feist nlohmann::json& controller = stepwise[name]; 414b7a08d04SJames Feist config = &controller; 4155b4aa86bSJames Feist 416b7a08d04SJames Feist controller["@odata.id"] = 4170fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/" + 418271584abSEd Tanous name; 419b7a08d04SJames Feist controller["@odata.type"] = 420b7a08d04SJames Feist "#OemManager.StepwiseController"; 421b7a08d04SJames Feist 422c33a90ecSJames Feist controller["Direction"] = *classPtr; 4235b4aa86bSJames Feist } 4245b4aa86bSJames Feist 4255b4aa86bSJames Feist // pid and fans are off the same configuration 426b7a08d04SJames Feist else if (intfPair.first == pidConfigurationIface) 4275b4aa86bSJames Feist { 428c33a90ecSJames Feist 4295b4aa86bSJames Feist if (classPtr == nullptr) 4305b4aa86bSJames Feist { 4315b4aa86bSJames Feist BMCWEB_LOG_ERROR << "Pid Class Field illegal"; 432a08b46ccSJason M. Bills messages::internalError(asyncResp->res); 4335b4aa86bSJames Feist return; 4345b4aa86bSJames Feist } 4355b4aa86bSJames Feist bool isFan = *classPtr == "fan"; 4365b4aa86bSJames Feist nlohmann::json& element = 4375b4aa86bSJames Feist isFan ? fans[name] : pids[name]; 438b7a08d04SJames Feist config = &element; 4395b4aa86bSJames Feist if (isFan) 4405b4aa86bSJames Feist { 4415b4aa86bSJames Feist element["@odata.id"] = 4420fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers/" + 443271584abSEd Tanous name; 4445b4aa86bSJames Feist element["@odata.type"] = 4455b4aa86bSJames Feist "#OemManager.FanController"; 4465b4aa86bSJames Feist } 4475b4aa86bSJames Feist else 4485b4aa86bSJames Feist { 4495b4aa86bSJames Feist element["@odata.id"] = 4500fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers/" + 451271584abSEd Tanous name; 4525b4aa86bSJames Feist element["@odata.type"] = 4535b4aa86bSJames Feist "#OemManager.PidController"; 4545b4aa86bSJames Feist } 455b7a08d04SJames Feist } 456b7a08d04SJames Feist else 457b7a08d04SJames Feist { 458b7a08d04SJames Feist BMCWEB_LOG_ERROR << "Unexpected configuration"; 459b7a08d04SJames Feist messages::internalError(asyncResp->res); 460b7a08d04SJames Feist return; 461b7a08d04SJames Feist } 462b7a08d04SJames Feist 463b7a08d04SJames Feist // used for making maps out of 2 vectors 464b7a08d04SJames Feist const std::vector<double>* keys = nullptr; 465b7a08d04SJames Feist const std::vector<double>* values = nullptr; 466b7a08d04SJames Feist 467b7a08d04SJames Feist for (const auto& propertyPair : intfPair.second) 468b7a08d04SJames Feist { 469b7a08d04SJames Feist if (propertyPair.first == "Type" || 470b7a08d04SJames Feist propertyPair.first == "Class" || 471b7a08d04SJames Feist propertyPair.first == "Name") 472b7a08d04SJames Feist { 473b7a08d04SJames Feist continue; 474b7a08d04SJames Feist } 475b7a08d04SJames Feist 476b7a08d04SJames Feist // zones 477b7a08d04SJames Feist if (intfPair.first == pidZoneConfigurationIface) 478b7a08d04SJames Feist { 479b7a08d04SJames Feist const double* ptr = 480abf2add6SEd Tanous std::get_if<double>(&propertyPair.second); 481b7a08d04SJames Feist if (ptr == nullptr) 482b7a08d04SJames Feist { 483b7a08d04SJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 484b7a08d04SJames Feist << propertyPair.first; 485b7a08d04SJames Feist messages::internalError(asyncResp->res); 486b7a08d04SJames Feist return; 487b7a08d04SJames Feist } 488b7a08d04SJames Feist (*config)[propertyPair.first] = *ptr; 489b7a08d04SJames Feist } 490b7a08d04SJames Feist 491b7a08d04SJames Feist if (intfPair.first == stepwiseConfigurationIface) 492b7a08d04SJames Feist { 493b7a08d04SJames Feist if (propertyPair.first == "Reading" || 494b7a08d04SJames Feist propertyPair.first == "Output") 495b7a08d04SJames Feist { 496b7a08d04SJames Feist const std::vector<double>* ptr = 497abf2add6SEd Tanous std::get_if<std::vector<double>>( 498b7a08d04SJames Feist &propertyPair.second); 499b7a08d04SJames Feist 500b7a08d04SJames Feist if (ptr == nullptr) 501b7a08d04SJames Feist { 502b7a08d04SJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 503b7a08d04SJames Feist << propertyPair.first; 504b7a08d04SJames Feist messages::internalError(asyncResp->res); 505b7a08d04SJames Feist return; 506b7a08d04SJames Feist } 507b7a08d04SJames Feist 508b7a08d04SJames Feist if (propertyPair.first == "Reading") 509b7a08d04SJames Feist { 510b7a08d04SJames Feist keys = ptr; 511b7a08d04SJames Feist } 512b7a08d04SJames Feist else 513b7a08d04SJames Feist { 514b7a08d04SJames Feist values = ptr; 515b7a08d04SJames Feist } 516e662eae8SEd Tanous if (keys != nullptr && values != nullptr) 517b7a08d04SJames Feist { 518b7a08d04SJames Feist if (keys->size() != values->size()) 519b7a08d04SJames Feist { 520b7a08d04SJames Feist BMCWEB_LOG_ERROR 5210fda0f12SGeorge Liu << "Reading and Output size don't match "; 522b7a08d04SJames Feist messages::internalError(asyncResp->res); 523b7a08d04SJames Feist return; 524b7a08d04SJames Feist } 525b7a08d04SJames Feist nlohmann::json& steps = (*config)["Steps"]; 526b7a08d04SJames Feist steps = nlohmann::json::array(); 527b7a08d04SJames Feist for (size_t ii = 0; ii < keys->size(); ii++) 528b7a08d04SJames Feist { 529b7a08d04SJames Feist steps.push_back( 530b7a08d04SJames Feist {{"Target", (*keys)[ii]}, 531b7a08d04SJames Feist {"Output", (*values)[ii]}}); 532b7a08d04SJames Feist } 533b7a08d04SJames Feist } 534b7a08d04SJames Feist } 535b7a08d04SJames Feist if (propertyPair.first == "NegativeHysteresis" || 536b7a08d04SJames Feist propertyPair.first == "PositiveHysteresis") 537b7a08d04SJames Feist { 538b7a08d04SJames Feist const double* ptr = 539abf2add6SEd Tanous std::get_if<double>(&propertyPair.second); 540b7a08d04SJames Feist if (ptr == nullptr) 541b7a08d04SJames Feist { 542b7a08d04SJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 543b7a08d04SJames Feist << propertyPair.first; 544b7a08d04SJames Feist messages::internalError(asyncResp->res); 545b7a08d04SJames Feist return; 546b7a08d04SJames Feist } 547b7a08d04SJames Feist (*config)[propertyPair.first] = *ptr; 548b7a08d04SJames Feist } 549b7a08d04SJames Feist } 550b7a08d04SJames Feist 551b7a08d04SJames Feist // pid and fans are off the same configuration 552b7a08d04SJames Feist if (intfPair.first == pidConfigurationIface || 553b7a08d04SJames Feist intfPair.first == stepwiseConfigurationIface) 554b7a08d04SJames Feist { 5555b4aa86bSJames Feist 5565b4aa86bSJames Feist if (propertyPair.first == "Zones") 5575b4aa86bSJames Feist { 5585b4aa86bSJames Feist const std::vector<std::string>* inputs = 559abf2add6SEd Tanous std::get_if<std::vector<std::string>>( 5601b6b96c5SEd Tanous &propertyPair.second); 5615b4aa86bSJames Feist 5625b4aa86bSJames Feist if (inputs == nullptr) 5635b4aa86bSJames Feist { 5645b4aa86bSJames Feist BMCWEB_LOG_ERROR 5655b4aa86bSJames Feist << "Zones Pid Field Illegal"; 566a08b46ccSJason M. Bills messages::internalError(asyncResp->res); 5675b4aa86bSJames Feist return; 5685b4aa86bSJames Feist } 569b7a08d04SJames Feist auto& data = (*config)[propertyPair.first]; 5705b4aa86bSJames Feist data = nlohmann::json::array(); 5715b4aa86bSJames Feist for (std::string itemCopy : *inputs) 5725b4aa86bSJames Feist { 5735b4aa86bSJames Feist dbus::utility::escapePathForDbus(itemCopy); 5745b4aa86bSJames Feist data.push_back( 5755b4aa86bSJames Feist {{"@odata.id", 5760fda0f12SGeorge Liu "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" + 5775b4aa86bSJames Feist itemCopy}}); 5785b4aa86bSJames Feist } 5795b4aa86bSJames Feist } 5805b4aa86bSJames Feist // todo(james): may never happen, but this 5815b4aa86bSJames Feist // assumes configuration data referenced in the 5825b4aa86bSJames Feist // PID config is provided by the same daemon, we 5835b4aa86bSJames Feist // could add another loop to cover all cases, 5845b4aa86bSJames Feist // but I'm okay kicking this can down the road a 5855b4aa86bSJames Feist // bit 5865b4aa86bSJames Feist 5875b4aa86bSJames Feist else if (propertyPair.first == "Inputs" || 5885b4aa86bSJames Feist propertyPair.first == "Outputs") 5895b4aa86bSJames Feist { 590b7a08d04SJames Feist auto& data = (*config)[propertyPair.first]; 5915b4aa86bSJames Feist const std::vector<std::string>* inputs = 592abf2add6SEd Tanous std::get_if<std::vector<std::string>>( 5931b6b96c5SEd Tanous &propertyPair.second); 5945b4aa86bSJames Feist 5955b4aa86bSJames Feist if (inputs == nullptr) 5965b4aa86bSJames Feist { 5975b4aa86bSJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 5985b4aa86bSJames Feist << propertyPair.first; 599f12894f8SJason M. Bills messages::internalError(asyncResp->res); 6005b4aa86bSJames Feist return; 6015b4aa86bSJames Feist } 6025b4aa86bSJames Feist data = *inputs; 603b943aaefSJames Feist } 604b943aaefSJames Feist else if (propertyPair.first == "SetPointOffset") 605b943aaefSJames Feist { 606b943aaefSJames Feist const std::string* ptr = 607b943aaefSJames Feist std::get_if<std::string>( 608b943aaefSJames Feist &propertyPair.second); 609b943aaefSJames Feist 610b943aaefSJames Feist if (ptr == nullptr) 611b943aaefSJames Feist { 612b943aaefSJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 613b943aaefSJames Feist << propertyPair.first; 614b943aaefSJames Feist messages::internalError(asyncResp->res); 615b943aaefSJames Feist return; 616b943aaefSJames Feist } 617b943aaefSJames Feist // translate from dbus to redfish 618b943aaefSJames Feist if (*ptr == "WarningHigh") 619b943aaefSJames Feist { 620b943aaefSJames Feist (*config)["SetPointOffset"] = 621b943aaefSJames Feist "UpperThresholdNonCritical"; 622b943aaefSJames Feist } 623b943aaefSJames Feist else if (*ptr == "WarningLow") 624b943aaefSJames Feist { 625b943aaefSJames Feist (*config)["SetPointOffset"] = 626b943aaefSJames Feist "LowerThresholdNonCritical"; 627b943aaefSJames Feist } 628b943aaefSJames Feist else if (*ptr == "CriticalHigh") 629b943aaefSJames Feist { 630b943aaefSJames Feist (*config)["SetPointOffset"] = 631b943aaefSJames Feist "UpperThresholdCritical"; 632b943aaefSJames Feist } 633b943aaefSJames Feist else if (*ptr == "CriticalLow") 634b943aaefSJames Feist { 635b943aaefSJames Feist (*config)["SetPointOffset"] = 636b943aaefSJames Feist "LowerThresholdCritical"; 637b943aaefSJames Feist } 638b943aaefSJames Feist else 639b943aaefSJames Feist { 640b943aaefSJames Feist BMCWEB_LOG_ERROR << "Value Illegal " 641b943aaefSJames Feist << *ptr; 642b943aaefSJames Feist messages::internalError(asyncResp->res); 643b943aaefSJames Feist return; 644b943aaefSJames Feist } 645b943aaefSJames Feist } 646b943aaefSJames Feist // doubles 6475b4aa86bSJames Feist else if (propertyPair.first == 6485b4aa86bSJames Feist "FFGainCoefficient" || 6495b4aa86bSJames Feist propertyPair.first == "FFOffCoefficient" || 6505b4aa86bSJames Feist propertyPair.first == "ICoefficient" || 6515b4aa86bSJames Feist propertyPair.first == "ILimitMax" || 6525b4aa86bSJames Feist propertyPair.first == "ILimitMin" || 653aad1a257SJames Feist propertyPair.first == 654aad1a257SJames Feist "PositiveHysteresis" || 655aad1a257SJames Feist propertyPair.first == 656aad1a257SJames Feist "NegativeHysteresis" || 6575b4aa86bSJames Feist propertyPair.first == "OutLimitMax" || 6585b4aa86bSJames Feist propertyPair.first == "OutLimitMin" || 6595b4aa86bSJames Feist propertyPair.first == "PCoefficient" || 6607625cb81SJames Feist propertyPair.first == "SetPoint" || 6615b4aa86bSJames Feist propertyPair.first == "SlewNeg" || 6625b4aa86bSJames Feist propertyPair.first == "SlewPos") 6635b4aa86bSJames Feist { 6645b4aa86bSJames Feist const double* ptr = 665abf2add6SEd Tanous std::get_if<double>(&propertyPair.second); 6665b4aa86bSJames Feist if (ptr == nullptr) 6675b4aa86bSJames Feist { 6685b4aa86bSJames Feist BMCWEB_LOG_ERROR << "Field Illegal " 6695b4aa86bSJames Feist << propertyPair.first; 670f12894f8SJason M. Bills messages::internalError(asyncResp->res); 6715b4aa86bSJames Feist return; 6725b4aa86bSJames Feist } 673b7a08d04SJames Feist (*config)[propertyPair.first] = *ptr; 6745b4aa86bSJames Feist } 6755b4aa86bSJames Feist } 6765b4aa86bSJames Feist } 6775b4aa86bSJames Feist } 6785b4aa86bSJames Feist } 6795b4aa86bSJames Feist }, 6805b4aa86bSJames Feist connection, path, objectManagerIface, "GetManagedObjects"); 6815b4aa86bSJames Feist } 682ca537928SJennifer Lee 68383ff9ab6SJames Feist enum class CreatePIDRet 68483ff9ab6SJames Feist { 68583ff9ab6SJames Feist fail, 68683ff9ab6SJames Feist del, 68783ff9ab6SJames Feist patch 68883ff9ab6SJames Feist }; 68983ff9ab6SJames Feist 6908d1b46d7Szhanghch05 inline bool 6918d1b46d7Szhanghch05 getZonesFromJsonReq(const std::shared_ptr<bmcweb::AsyncResp>& response, 6925f2caaefSJames Feist std::vector<nlohmann::json>& config, 6935f2caaefSJames Feist std::vector<std::string>& zones) 6945f2caaefSJames Feist { 695b6baeaa4SJames Feist if (config.empty()) 696b6baeaa4SJames Feist { 697b6baeaa4SJames Feist BMCWEB_LOG_ERROR << "Empty Zones"; 6981668ce6dSEd Tanous messages::propertyValueFormatError(response->res, "[]", "Zones"); 699b6baeaa4SJames Feist return false; 700b6baeaa4SJames Feist } 7015f2caaefSJames Feist for (auto& odata : config) 7025f2caaefSJames Feist { 7035f2caaefSJames Feist std::string path; 7045f2caaefSJames Feist if (!redfish::json_util::readJson(odata, response->res, "@odata.id", 7055f2caaefSJames Feist path)) 7065f2caaefSJames Feist { 7075f2caaefSJames Feist return false; 7085f2caaefSJames Feist } 7095f2caaefSJames Feist std::string input; 71061adbda3SJames Feist 71161adbda3SJames Feist // 8 below comes from 71261adbda3SJames Feist // /redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Left 71361adbda3SJames Feist // 0 1 2 3 4 5 6 7 8 71461adbda3SJames Feist if (!dbus::utility::getNthStringFromPath(path, 8, input)) 7155f2caaefSJames Feist { 7165f2caaefSJames Feist BMCWEB_LOG_ERROR << "Got invalid path " << path; 7175f2caaefSJames Feist BMCWEB_LOG_ERROR << "Illegal Type Zones"; 7185f2caaefSJames Feist messages::propertyValueFormatError(response->res, odata.dump(), 7195f2caaefSJames Feist "Zones"); 7205f2caaefSJames Feist return false; 7215f2caaefSJames Feist } 7225f2caaefSJames Feist boost::replace_all(input, "_", " "); 7235f2caaefSJames Feist zones.emplace_back(std::move(input)); 7245f2caaefSJames Feist } 7255f2caaefSJames Feist return true; 7265f2caaefSJames Feist } 7275f2caaefSJames Feist 728711ac7a9SEd Tanous inline const dbus::utility::ManagedObjectType::value_type* 72973df0db0SJames Feist findChassis(const dbus::utility::ManagedObjectType& managedObj, 730b6baeaa4SJames Feist const std::string& value, std::string& chassis) 731b6baeaa4SJames Feist { 732b6baeaa4SJames Feist BMCWEB_LOG_DEBUG << "Find Chassis: " << value << "\n"; 733b6baeaa4SJames Feist 734b6baeaa4SJames Feist std::string escaped = boost::replace_all_copy(value, " ", "_"); 735b6baeaa4SJames Feist escaped = "/" + escaped; 736b6baeaa4SJames Feist auto it = std::find_if( 737b6baeaa4SJames Feist managedObj.begin(), managedObj.end(), [&escaped](const auto& obj) { 738b6baeaa4SJames Feist if (boost::algorithm::ends_with(obj.first.str, escaped)) 739b6baeaa4SJames Feist { 740b6baeaa4SJames Feist BMCWEB_LOG_DEBUG << "Matched " << obj.first.str << "\n"; 741b6baeaa4SJames Feist return true; 742b6baeaa4SJames Feist } 743b6baeaa4SJames Feist return false; 744b6baeaa4SJames Feist }); 745b6baeaa4SJames Feist 746b6baeaa4SJames Feist if (it == managedObj.end()) 747b6baeaa4SJames Feist { 74873df0db0SJames Feist return nullptr; 749b6baeaa4SJames Feist } 750b6baeaa4SJames Feist // 5 comes from <chassis-name> being the 5th element 751b6baeaa4SJames Feist // /xyz/openbmc_project/inventory/system/chassis/<chassis-name> 75273df0db0SJames Feist if (dbus::utility::getNthStringFromPath(it->first.str, 5, chassis)) 75373df0db0SJames Feist { 75473df0db0SJames Feist return &(*it); 75573df0db0SJames Feist } 75673df0db0SJames Feist 75773df0db0SJames Feist return nullptr; 758b6baeaa4SJames Feist } 759b6baeaa4SJames Feist 76023a21a1cSEd Tanous inline CreatePIDRet createPidInterface( 7618d1b46d7Szhanghch05 const std::shared_ptr<bmcweb::AsyncResp>& response, const std::string& type, 762b5a76932SEd Tanous const nlohmann::json::iterator& it, const std::string& path, 76383ff9ab6SJames Feist const dbus::utility::ManagedObjectType& managedObj, bool createNewObject, 764b9d36b47SEd Tanous dbus::utility::DBusPropertiesMap& output, std::string& chassis, 765b9d36b47SEd Tanous const std::string& profile) 76683ff9ab6SJames Feist { 76783ff9ab6SJames Feist 7685f2caaefSJames Feist // common deleter 769b6baeaa4SJames Feist if (it.value() == nullptr) 7705f2caaefSJames Feist { 7715f2caaefSJames Feist std::string iface; 7725f2caaefSJames Feist if (type == "PidControllers" || type == "FanControllers") 7735f2caaefSJames Feist { 7745f2caaefSJames Feist iface = pidConfigurationIface; 7755f2caaefSJames Feist } 7765f2caaefSJames Feist else if (type == "FanZones") 7775f2caaefSJames Feist { 7785f2caaefSJames Feist iface = pidZoneConfigurationIface; 7795f2caaefSJames Feist } 7805f2caaefSJames Feist else if (type == "StepwiseControllers") 7815f2caaefSJames Feist { 7825f2caaefSJames Feist iface = stepwiseConfigurationIface; 7835f2caaefSJames Feist } 7845f2caaefSJames Feist else 7855f2caaefSJames Feist { 786a0744d38SGunnar Mills BMCWEB_LOG_ERROR << "Illegal Type " << type; 7875f2caaefSJames Feist messages::propertyUnknown(response->res, type); 7885f2caaefSJames Feist return CreatePIDRet::fail; 7895f2caaefSJames Feist } 7906ee7f774SJames Feist 7916ee7f774SJames Feist BMCWEB_LOG_DEBUG << "del " << path << " " << iface << "\n"; 7925f2caaefSJames Feist // delete interface 7935f2caaefSJames Feist crow::connections::systemBus->async_method_call( 7945f2caaefSJames Feist [response, path](const boost::system::error_code ec) { 7955f2caaefSJames Feist if (ec) 7965f2caaefSJames Feist { 7975f2caaefSJames Feist BMCWEB_LOG_ERROR << "Error patching " << path << ": " << ec; 7985f2caaefSJames Feist messages::internalError(response->res); 799b6baeaa4SJames Feist return; 8005f2caaefSJames Feist } 801b6baeaa4SJames Feist messages::success(response->res); 8025f2caaefSJames Feist }, 8035f2caaefSJames Feist "xyz.openbmc_project.EntityManager", path, iface, "Delete"); 8045f2caaefSJames Feist return CreatePIDRet::del; 8055f2caaefSJames Feist } 8065f2caaefSJames Feist 807711ac7a9SEd Tanous const dbus::utility::ManagedObjectType::value_type* managedItem = nullptr; 808b6baeaa4SJames Feist if (!createNewObject) 809b6baeaa4SJames Feist { 810b6baeaa4SJames Feist // if we aren't creating a new object, we should be able to find it on 811b6baeaa4SJames Feist // d-bus 81273df0db0SJames Feist managedItem = findChassis(managedObj, it.key(), chassis); 81373df0db0SJames Feist if (managedItem == nullptr) 814b6baeaa4SJames Feist { 815b6baeaa4SJames Feist BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; 816ace85d60SEd Tanous messages::invalidObject(response->res, 817ace85d60SEd Tanous crow::utility::urlFromPieces( 818ace85d60SEd Tanous "redfish", "v1", "Chassis", chassis)); 819b6baeaa4SJames Feist return CreatePIDRet::fail; 820b6baeaa4SJames Feist } 821b6baeaa4SJames Feist } 822b6baeaa4SJames Feist 82326f6976fSEd Tanous if (!profile.empty() && 82473df0db0SJames Feist (type == "PidControllers" || type == "FanControllers" || 82573df0db0SJames Feist type == "StepwiseControllers")) 82673df0db0SJames Feist { 82773df0db0SJames Feist if (managedItem == nullptr) 82873df0db0SJames Feist { 829b9d36b47SEd Tanous output.emplace_back("Profiles", std::vector<std::string>{profile}); 83073df0db0SJames Feist } 83173df0db0SJames Feist else 83273df0db0SJames Feist { 83373df0db0SJames Feist std::string interface; 83473df0db0SJames Feist if (type == "StepwiseControllers") 83573df0db0SJames Feist { 83673df0db0SJames Feist interface = stepwiseConfigurationIface; 83773df0db0SJames Feist } 83873df0db0SJames Feist else 83973df0db0SJames Feist { 84073df0db0SJames Feist interface = pidConfigurationIface; 84173df0db0SJames Feist } 842711ac7a9SEd Tanous bool ifaceFound = false; 843711ac7a9SEd Tanous for (const auto& iface : managedItem->second) 844711ac7a9SEd Tanous { 845711ac7a9SEd Tanous if (iface.first == interface) 846711ac7a9SEd Tanous { 847711ac7a9SEd Tanous ifaceFound = true; 848711ac7a9SEd Tanous for (const auto& prop : iface.second) 849711ac7a9SEd Tanous { 850711ac7a9SEd Tanous if (prop.first == "Profiles") 851711ac7a9SEd Tanous { 852711ac7a9SEd Tanous const std::vector<std::string>* curProfiles = 853711ac7a9SEd Tanous std::get_if<std::vector<std::string>>( 854711ac7a9SEd Tanous &(prop.second)); 855711ac7a9SEd Tanous if (curProfiles == nullptr) 856711ac7a9SEd Tanous { 857711ac7a9SEd Tanous BMCWEB_LOG_ERROR 858711ac7a9SEd Tanous << "Illegal profiles in managed object"; 859711ac7a9SEd Tanous messages::internalError(response->res); 860711ac7a9SEd Tanous return CreatePIDRet::fail; 861711ac7a9SEd Tanous } 862711ac7a9SEd Tanous if (std::find(curProfiles->begin(), 863711ac7a9SEd Tanous curProfiles->end(), 864711ac7a9SEd Tanous profile) == curProfiles->end()) 865711ac7a9SEd Tanous { 866711ac7a9SEd Tanous std::vector<std::string> newProfiles = 867711ac7a9SEd Tanous *curProfiles; 868711ac7a9SEd Tanous newProfiles.push_back(profile); 869b9d36b47SEd Tanous output.emplace_back("Profiles", newProfiles); 870711ac7a9SEd Tanous } 871711ac7a9SEd Tanous } 872711ac7a9SEd Tanous } 873711ac7a9SEd Tanous } 874711ac7a9SEd Tanous } 875711ac7a9SEd Tanous 876711ac7a9SEd Tanous if (!ifaceFound) 87773df0db0SJames Feist { 87873df0db0SJames Feist BMCWEB_LOG_ERROR 87973df0db0SJames Feist << "Failed to find interface in managed object"; 88073df0db0SJames Feist messages::internalError(response->res); 88173df0db0SJames Feist return CreatePIDRet::fail; 88273df0db0SJames Feist } 88373df0db0SJames Feist } 88473df0db0SJames Feist } 88573df0db0SJames Feist 88683ff9ab6SJames Feist if (type == "PidControllers" || type == "FanControllers") 88783ff9ab6SJames Feist { 88883ff9ab6SJames Feist if (createNewObject) 88983ff9ab6SJames Feist { 890b9d36b47SEd Tanous output.emplace_back("Class", 891b9d36b47SEd Tanous type == "PidControllers" ? "temp" : "fan"); 892b9d36b47SEd Tanous output.emplace_back("Type", "Pid"); 89383ff9ab6SJames Feist } 8945f2caaefSJames Feist 8955f2caaefSJames Feist std::optional<std::vector<nlohmann::json>> zones; 8965f2caaefSJames Feist std::optional<std::vector<std::string>> inputs; 8975f2caaefSJames Feist std::optional<std::vector<std::string>> outputs; 8985f2caaefSJames Feist std::map<std::string, std::optional<double>> doubles; 899b943aaefSJames Feist std::optional<std::string> setpointOffset; 9005f2caaefSJames Feist if (!redfish::json_util::readJson( 901b6baeaa4SJames Feist it.value(), response->res, "Inputs", inputs, "Outputs", outputs, 9025f2caaefSJames Feist "Zones", zones, "FFGainCoefficient", 9035f2caaefSJames Feist doubles["FFGainCoefficient"], "FFOffCoefficient", 9045f2caaefSJames Feist doubles["FFOffCoefficient"], "ICoefficient", 9055f2caaefSJames Feist doubles["ICoefficient"], "ILimitMax", doubles["ILimitMax"], 9065f2caaefSJames Feist "ILimitMin", doubles["ILimitMin"], "OutLimitMax", 9075f2caaefSJames Feist doubles["OutLimitMax"], "OutLimitMin", doubles["OutLimitMin"], 9085f2caaefSJames Feist "PCoefficient", doubles["PCoefficient"], "SetPoint", 909b943aaefSJames Feist doubles["SetPoint"], "SetPointOffset", setpointOffset, 910b943aaefSJames Feist "SlewNeg", doubles["SlewNeg"], "SlewPos", doubles["SlewPos"], 911b943aaefSJames Feist "PositiveHysteresis", doubles["PositiveHysteresis"], 912b943aaefSJames Feist "NegativeHysteresis", doubles["NegativeHysteresis"])) 91383ff9ab6SJames Feist { 91471f52d96SEd Tanous BMCWEB_LOG_ERROR 91571f52d96SEd Tanous << "Illegal Property " 91671f52d96SEd Tanous << it.value().dump(2, ' ', true, 91771f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 9185f2caaefSJames Feist return CreatePIDRet::fail; 91983ff9ab6SJames Feist } 9205f2caaefSJames Feist if (zones) 9215f2caaefSJames Feist { 9225f2caaefSJames Feist std::vector<std::string> zonesStr; 9235f2caaefSJames Feist if (!getZonesFromJsonReq(response, *zones, zonesStr)) 9245f2caaefSJames Feist { 925a0744d38SGunnar Mills BMCWEB_LOG_ERROR << "Illegal Zones"; 9265f2caaefSJames Feist return CreatePIDRet::fail; 9275f2caaefSJames Feist } 928b6baeaa4SJames Feist if (chassis.empty() && 929e662eae8SEd Tanous findChassis(managedObj, zonesStr[0], chassis) == nullptr) 930b6baeaa4SJames Feist { 931b6baeaa4SJames Feist BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; 932ace85d60SEd Tanous messages::invalidObject( 933ace85d60SEd Tanous response->res, crow::utility::urlFromPieces( 934ace85d60SEd Tanous "redfish", "v1", "Chassis", chassis)); 935b6baeaa4SJames Feist return CreatePIDRet::fail; 936b6baeaa4SJames Feist } 937b9d36b47SEd Tanous output.emplace_back("Zones", std::move(zonesStr)); 9385f2caaefSJames Feist } 9395f2caaefSJames Feist if (inputs || outputs) 9405f2caaefSJames Feist { 9415f2caaefSJames Feist std::array<std::optional<std::vector<std::string>>*, 2> containers = 9425f2caaefSJames Feist {&inputs, &outputs}; 9435f2caaefSJames Feist size_t index = 0; 9445f2caaefSJames Feist for (const auto& containerPtr : containers) 9455f2caaefSJames Feist { 9465f2caaefSJames Feist std::optional<std::vector<std::string>>& container = 9475f2caaefSJames Feist *containerPtr; 9485f2caaefSJames Feist if (!container) 9495f2caaefSJames Feist { 9505f2caaefSJames Feist index++; 9515f2caaefSJames Feist continue; 95283ff9ab6SJames Feist } 95383ff9ab6SJames Feist 9545f2caaefSJames Feist for (std::string& value : *container) 95583ff9ab6SJames Feist { 9565f2caaefSJames Feist boost::replace_all(value, "_", " "); 95783ff9ab6SJames Feist } 9585f2caaefSJames Feist std::string key; 9595f2caaefSJames Feist if (index == 0) 9605f2caaefSJames Feist { 9615f2caaefSJames Feist key = "Inputs"; 9625f2caaefSJames Feist } 9635f2caaefSJames Feist else 9645f2caaefSJames Feist { 9655f2caaefSJames Feist key = "Outputs"; 9665f2caaefSJames Feist } 967b9d36b47SEd Tanous output.emplace_back(key, *container); 9685f2caaefSJames Feist index++; 9695f2caaefSJames Feist } 97083ff9ab6SJames Feist } 97183ff9ab6SJames Feist 972b943aaefSJames Feist if (setpointOffset) 973b943aaefSJames Feist { 974b943aaefSJames Feist // translate between redfish and dbus names 975b943aaefSJames Feist if (*setpointOffset == "UpperThresholdNonCritical") 976b943aaefSJames Feist { 977b9d36b47SEd Tanous output.emplace_back("SetPointOffset", "WarningLow"); 978b943aaefSJames Feist } 979b943aaefSJames Feist else if (*setpointOffset == "LowerThresholdNonCritical") 980b943aaefSJames Feist { 981b9d36b47SEd Tanous output.emplace_back("SetPointOffset", "WarningHigh"); 982b943aaefSJames Feist } 983b943aaefSJames Feist else if (*setpointOffset == "LowerThresholdCritical") 984b943aaefSJames Feist { 985b9d36b47SEd Tanous output.emplace_back("SetPointOffset", "CriticalLow"); 986b943aaefSJames Feist } 987b943aaefSJames Feist else if (*setpointOffset == "UpperThresholdCritical") 988b943aaefSJames Feist { 989b9d36b47SEd Tanous output.emplace_back("SetPointOffset", "CriticalHigh"); 990b943aaefSJames Feist } 991b943aaefSJames Feist else 992b943aaefSJames Feist { 993b943aaefSJames Feist BMCWEB_LOG_ERROR << "Invalid setpointoffset " 994b943aaefSJames Feist << *setpointOffset; 995ace85d60SEd Tanous messages::propertyValueNotInList(response->res, it.key(), 996ace85d60SEd Tanous "SetPointOffset"); 997b943aaefSJames Feist return CreatePIDRet::fail; 998b943aaefSJames Feist } 999b943aaefSJames Feist } 1000b943aaefSJames Feist 100183ff9ab6SJames Feist // doubles 10025f2caaefSJames Feist for (const auto& pairs : doubles) 100383ff9ab6SJames Feist { 10045f2caaefSJames Feist if (!pairs.second) 100583ff9ab6SJames Feist { 10065f2caaefSJames Feist continue; 100783ff9ab6SJames Feist } 10085f2caaefSJames Feist BMCWEB_LOG_DEBUG << pairs.first << " = " << *pairs.second; 1009b9d36b47SEd Tanous output.emplace_back(pairs.first, *pairs.second); 10105f2caaefSJames Feist } 101183ff9ab6SJames Feist } 101283ff9ab6SJames Feist 101383ff9ab6SJames Feist else if (type == "FanZones") 101483ff9ab6SJames Feist { 1015b9d36b47SEd Tanous output.emplace_back("Type", "Pid.Zone"); 101683ff9ab6SJames Feist 10175f2caaefSJames Feist std::optional<nlohmann::json> chassisContainer; 10185f2caaefSJames Feist std::optional<double> failSafePercent; 1019d3ec07f8SJames Feist std::optional<double> minThermalOutput; 1020b6baeaa4SJames Feist if (!redfish::json_util::readJson(it.value(), response->res, "Chassis", 10215f2caaefSJames Feist chassisContainer, "FailSafePercent", 1022d3ec07f8SJames Feist failSafePercent, "MinThermalOutput", 1023d3ec07f8SJames Feist minThermalOutput)) 102483ff9ab6SJames Feist { 102571f52d96SEd Tanous BMCWEB_LOG_ERROR 102671f52d96SEd Tanous << "Illegal Property " 102771f52d96SEd Tanous << it.value().dump(2, ' ', true, 102871f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 102983ff9ab6SJames Feist return CreatePIDRet::fail; 103083ff9ab6SJames Feist } 10315f2caaefSJames Feist 10325f2caaefSJames Feist if (chassisContainer) 103383ff9ab6SJames Feist { 10345f2caaefSJames Feist 10355f2caaefSJames Feist std::string chassisId; 10365f2caaefSJames Feist if (!redfish::json_util::readJson(*chassisContainer, response->res, 10375f2caaefSJames Feist "@odata.id", chassisId)) 10385f2caaefSJames Feist { 103971f52d96SEd Tanous BMCWEB_LOG_ERROR 104071f52d96SEd Tanous << "Illegal Property " 104171f52d96SEd Tanous << chassisContainer->dump( 104271f52d96SEd Tanous 2, ' ', true, 104371f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 104483ff9ab6SJames Feist return CreatePIDRet::fail; 104583ff9ab6SJames Feist } 104683ff9ab6SJames Feist 1047717794d5SAppaRao Puli // /redfish/v1/chassis/chassis_name/ 10485f2caaefSJames Feist if (!dbus::utility::getNthStringFromPath(chassisId, 3, chassis)) 104983ff9ab6SJames Feist { 10505f2caaefSJames Feist BMCWEB_LOG_ERROR << "Got invalid path " << chassisId; 1051ace85d60SEd Tanous messages::invalidObject( 1052ace85d60SEd Tanous response->res, crow::utility::urlFromPieces( 1053ace85d60SEd Tanous "redfish", "v1", "Chassis", chassisId)); 105483ff9ab6SJames Feist return CreatePIDRet::fail; 105583ff9ab6SJames Feist } 105683ff9ab6SJames Feist } 1057d3ec07f8SJames Feist if (minThermalOutput) 105883ff9ab6SJames Feist { 1059b9d36b47SEd Tanous output.emplace_back("MinThermalOutput", *minThermalOutput); 10605f2caaefSJames Feist } 10615f2caaefSJames Feist if (failSafePercent) 106283ff9ab6SJames Feist { 1063b9d36b47SEd Tanous output.emplace_back("FailSafePercent", *failSafePercent); 10645f2caaefSJames Feist } 10655f2caaefSJames Feist } 10665f2caaefSJames Feist else if (type == "StepwiseControllers") 10675f2caaefSJames Feist { 1068b9d36b47SEd Tanous output.emplace_back("Type", "Stepwise"); 10695f2caaefSJames Feist 10705f2caaefSJames Feist std::optional<std::vector<nlohmann::json>> zones; 10715f2caaefSJames Feist std::optional<std::vector<nlohmann::json>> steps; 10725f2caaefSJames Feist std::optional<std::vector<std::string>> inputs; 10735f2caaefSJames Feist std::optional<double> positiveHysteresis; 10745f2caaefSJames Feist std::optional<double> negativeHysteresis; 1075c33a90ecSJames Feist std::optional<std::string> direction; // upper clipping curve vs lower 10765f2caaefSJames Feist if (!redfish::json_util::readJson( 1077b6baeaa4SJames Feist it.value(), response->res, "Zones", zones, "Steps", steps, 1078b6baeaa4SJames Feist "Inputs", inputs, "PositiveHysteresis", positiveHysteresis, 1079c33a90ecSJames Feist "NegativeHysteresis", negativeHysteresis, "Direction", 1080c33a90ecSJames Feist direction)) 10815f2caaefSJames Feist { 108271f52d96SEd Tanous BMCWEB_LOG_ERROR 108371f52d96SEd Tanous << "Illegal Property " 108471f52d96SEd Tanous << it.value().dump(2, ' ', true, 108571f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 108683ff9ab6SJames Feist return CreatePIDRet::fail; 108783ff9ab6SJames Feist } 10885f2caaefSJames Feist 10895f2caaefSJames Feist if (zones) 109083ff9ab6SJames Feist { 1091b6baeaa4SJames Feist std::vector<std::string> zonesStrs; 1092b6baeaa4SJames Feist if (!getZonesFromJsonReq(response, *zones, zonesStrs)) 10935f2caaefSJames Feist { 1094a0744d38SGunnar Mills BMCWEB_LOG_ERROR << "Illegal Zones"; 109583ff9ab6SJames Feist return CreatePIDRet::fail; 109683ff9ab6SJames Feist } 1097b6baeaa4SJames Feist if (chassis.empty() && 1098e662eae8SEd Tanous findChassis(managedObj, zonesStrs[0], chassis) == nullptr) 1099b6baeaa4SJames Feist { 1100b6baeaa4SJames Feist BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; 1101ace85d60SEd Tanous messages::invalidObject( 1102ace85d60SEd Tanous response->res, crow::utility::urlFromPieces( 1103ace85d60SEd Tanous "redfish", "v1", "Chassis", chassis)); 1104b6baeaa4SJames Feist return CreatePIDRet::fail; 1105b6baeaa4SJames Feist } 1106b9d36b47SEd Tanous output.emplace_back("Zones", std::move(zonesStrs)); 11075f2caaefSJames Feist } 11085f2caaefSJames Feist if (steps) 11095f2caaefSJames Feist { 11105f2caaefSJames Feist std::vector<double> readings; 11115f2caaefSJames Feist std::vector<double> outputs; 11125f2caaefSJames Feist for (auto& step : *steps) 11135f2caaefSJames Feist { 1114543f4400SEd Tanous double target = 0.0; 1115543f4400SEd Tanous double out = 0.0; 11165f2caaefSJames Feist 11175f2caaefSJames Feist if (!redfish::json_util::readJson(step, response->res, "Target", 111823a21a1cSEd Tanous target, "Output", out)) 11195f2caaefSJames Feist { 112071f52d96SEd Tanous BMCWEB_LOG_ERROR 112171f52d96SEd Tanous << "Illegal Property " 112271f52d96SEd Tanous << it.value().dump( 112371f52d96SEd Tanous 2, ' ', true, 112471f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 11255f2caaefSJames Feist return CreatePIDRet::fail; 11265f2caaefSJames Feist } 11275f2caaefSJames Feist readings.emplace_back(target); 112823a21a1cSEd Tanous outputs.emplace_back(out); 11295f2caaefSJames Feist } 1130b9d36b47SEd Tanous output.emplace_back("Reading", std::move(readings)); 1131b9d36b47SEd Tanous output.emplace_back("Output", std::move(outputs)); 11325f2caaefSJames Feist } 11335f2caaefSJames Feist if (inputs) 11345f2caaefSJames Feist { 11355f2caaefSJames Feist for (std::string& value : *inputs) 11365f2caaefSJames Feist { 11375f2caaefSJames Feist boost::replace_all(value, "_", " "); 11385f2caaefSJames Feist } 1139b9d36b47SEd Tanous output.emplace_back("Inputs", std::move(*inputs)); 11405f2caaefSJames Feist } 11415f2caaefSJames Feist if (negativeHysteresis) 11425f2caaefSJames Feist { 1143b9d36b47SEd Tanous output.emplace_back("NegativeHysteresis", *negativeHysteresis); 11445f2caaefSJames Feist } 11455f2caaefSJames Feist if (positiveHysteresis) 11465f2caaefSJames Feist { 1147b9d36b47SEd Tanous output.emplace_back("PositiveHysteresis", *positiveHysteresis); 114883ff9ab6SJames Feist } 1149c33a90ecSJames Feist if (direction) 1150c33a90ecSJames Feist { 1151c33a90ecSJames Feist constexpr const std::array<const char*, 2> allowedDirections = { 1152c33a90ecSJames Feist "Ceiling", "Floor"}; 1153c33a90ecSJames Feist if (std::find(allowedDirections.begin(), allowedDirections.end(), 1154c33a90ecSJames Feist *direction) == allowedDirections.end()) 1155c33a90ecSJames Feist { 1156c33a90ecSJames Feist messages::propertyValueTypeError(response->res, "Direction", 1157c33a90ecSJames Feist *direction); 1158c33a90ecSJames Feist return CreatePIDRet::fail; 1159c33a90ecSJames Feist } 1160b9d36b47SEd Tanous output.emplace_back("Class", *direction); 1161c33a90ecSJames Feist } 116283ff9ab6SJames Feist } 116383ff9ab6SJames Feist else 116483ff9ab6SJames Feist { 1165a0744d38SGunnar Mills BMCWEB_LOG_ERROR << "Illegal Type " << type; 116635a62c7cSJason M. Bills messages::propertyUnknown(response->res, type); 116783ff9ab6SJames Feist return CreatePIDRet::fail; 116883ff9ab6SJames Feist } 116983ff9ab6SJames Feist return CreatePIDRet::patch; 117083ff9ab6SJames Feist } 117173df0db0SJames Feist struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> 117273df0db0SJames Feist { 117383ff9ab6SJames Feist 11748d1b46d7Szhanghch05 GetPIDValues(const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) : 117523a21a1cSEd Tanous asyncResp(asyncRespIn) 117673df0db0SJames Feist 11771214b7e7SGunnar Mills {} 11789c310685SBorawski.Lukasz 117973df0db0SJames Feist void run() 11805b4aa86bSJames Feist { 118173df0db0SJames Feist std::shared_ptr<GetPIDValues> self = shared_from_this(); 118273df0db0SJames Feist 118373df0db0SJames Feist // get all configurations 11845b4aa86bSJames Feist crow::connections::systemBus->async_method_call( 1185b9d36b47SEd Tanous [self]( 1186b9d36b47SEd Tanous const boost::system::error_code ec, 1187b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) { 11885b4aa86bSJames Feist if (ec) 11895b4aa86bSJames Feist { 11905b4aa86bSJames Feist BMCWEB_LOG_ERROR << ec; 119173df0db0SJames Feist messages::internalError(self->asyncResp->res); 119273df0db0SJames Feist return; 119373df0db0SJames Feist } 119423a21a1cSEd Tanous self->subtree = subtreeLocal; 119573df0db0SJames Feist }, 119673df0db0SJames Feist "xyz.openbmc_project.ObjectMapper", 119773df0db0SJames Feist "/xyz/openbmc_project/object_mapper", 119873df0db0SJames Feist "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0, 119973df0db0SJames Feist std::array<const char*, 4>{ 120073df0db0SJames Feist pidConfigurationIface, pidZoneConfigurationIface, 120173df0db0SJames Feist objectManagerIface, stepwiseConfigurationIface}); 120273df0db0SJames Feist 120373df0db0SJames Feist // at the same time get the selected profile 120473df0db0SJames Feist crow::connections::systemBus->async_method_call( 1205b9d36b47SEd Tanous [self]( 1206b9d36b47SEd Tanous const boost::system::error_code ec, 1207b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) { 120823a21a1cSEd Tanous if (ec || subtreeLocal.empty()) 120973df0db0SJames Feist { 121073df0db0SJames Feist return; 121173df0db0SJames Feist } 121223a21a1cSEd Tanous if (subtreeLocal[0].second.size() != 1) 121373df0db0SJames Feist { 121473df0db0SJames Feist // invalid mapper response, should never happen 121573df0db0SJames Feist BMCWEB_LOG_ERROR << "GetPIDValues: Mapper Error"; 121673df0db0SJames Feist messages::internalError(self->asyncResp->res); 12175b4aa86bSJames Feist return; 12185b4aa86bSJames Feist } 12195b4aa86bSJames Feist 122023a21a1cSEd Tanous const std::string& path = subtreeLocal[0].first; 122123a21a1cSEd Tanous const std::string& owner = subtreeLocal[0].second[0].first; 122273df0db0SJames Feist crow::connections::systemBus->async_method_call( 1223168e20c1SEd Tanous [path, owner, 1224168e20c1SEd Tanous self](const boost::system::error_code ec2, 1225b9d36b47SEd Tanous const dbus::utility::DBusPropertiesMap& resp) { 122623a21a1cSEd Tanous if (ec2) 122773df0db0SJames Feist { 12280fda0f12SGeorge Liu BMCWEB_LOG_ERROR 12290fda0f12SGeorge Liu << "GetPIDValues: Can't get thermalModeIface " 123073df0db0SJames Feist << path; 123173df0db0SJames Feist messages::internalError(self->asyncResp->res); 123273df0db0SJames Feist return; 123373df0db0SJames Feist } 1234271584abSEd Tanous const std::string* current = nullptr; 1235271584abSEd Tanous const std::vector<std::string>* supported = nullptr; 12369eb808c1SEd Tanous for (const auto& [key, value] : resp) 123773df0db0SJames Feist { 123873df0db0SJames Feist if (key == "Current") 123973df0db0SJames Feist { 124073df0db0SJames Feist current = std::get_if<std::string>(&value); 124173df0db0SJames Feist if (current == nullptr) 124273df0db0SJames Feist { 124373df0db0SJames Feist BMCWEB_LOG_ERROR 12440fda0f12SGeorge Liu << "GetPIDValues: thermal mode iface invalid " 124573df0db0SJames Feist << path; 124673df0db0SJames Feist messages::internalError( 124773df0db0SJames Feist self->asyncResp->res); 124873df0db0SJames Feist return; 124973df0db0SJames Feist } 125073df0db0SJames Feist } 125173df0db0SJames Feist if (key == "Supported") 125273df0db0SJames Feist { 125373df0db0SJames Feist supported = 125473df0db0SJames Feist std::get_if<std::vector<std::string>>( 125573df0db0SJames Feist &value); 125673df0db0SJames Feist if (supported == nullptr) 125773df0db0SJames Feist { 125873df0db0SJames Feist BMCWEB_LOG_ERROR 12590fda0f12SGeorge Liu << "GetPIDValues: thermal mode iface invalid" 126073df0db0SJames Feist << path; 126173df0db0SJames Feist messages::internalError( 126273df0db0SJames Feist self->asyncResp->res); 126373df0db0SJames Feist return; 126473df0db0SJames Feist } 126573df0db0SJames Feist } 126673df0db0SJames Feist } 126773df0db0SJames Feist if (current == nullptr || supported == nullptr) 126873df0db0SJames Feist { 12690fda0f12SGeorge Liu BMCWEB_LOG_ERROR 12700fda0f12SGeorge Liu << "GetPIDValues: thermal mode iface invalid " 127173df0db0SJames Feist << path; 127273df0db0SJames Feist messages::internalError(self->asyncResp->res); 127373df0db0SJames Feist return; 127473df0db0SJames Feist } 127573df0db0SJames Feist self->currentProfile = *current; 127673df0db0SJames Feist self->supportedProfiles = *supported; 127773df0db0SJames Feist }, 127873df0db0SJames Feist owner, path, "org.freedesktop.DBus.Properties", "GetAll", 127973df0db0SJames Feist thermalModeIface); 128073df0db0SJames Feist }, 128173df0db0SJames Feist "xyz.openbmc_project.ObjectMapper", 128273df0db0SJames Feist "/xyz/openbmc_project/object_mapper", 128373df0db0SJames Feist "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0, 128473df0db0SJames Feist std::array<const char*, 1>{thermalModeIface}); 128573df0db0SJames Feist } 128673df0db0SJames Feist 128773df0db0SJames Feist ~GetPIDValues() 128873df0db0SJames Feist { 128973df0db0SJames Feist if (asyncResp->res.result() != boost::beast::http::status::ok) 129073df0db0SJames Feist { 129173df0db0SJames Feist return; 129273df0db0SJames Feist } 12935b4aa86bSJames Feist // create map of <connection, path to objMgr>> 129473df0db0SJames Feist boost::container::flat_map<std::string, std::string> objectMgrPaths; 12956bce33bcSJames Feist boost::container::flat_set<std::string> calledConnections; 12965b4aa86bSJames Feist for (const auto& pathGroup : subtree) 12975b4aa86bSJames Feist { 12985b4aa86bSJames Feist for (const auto& connectionGroup : pathGroup.second) 12995b4aa86bSJames Feist { 13006bce33bcSJames Feist auto findConnection = 13016bce33bcSJames Feist calledConnections.find(connectionGroup.first); 13026bce33bcSJames Feist if (findConnection != calledConnections.end()) 13036bce33bcSJames Feist { 13046bce33bcSJames Feist break; 13056bce33bcSJames Feist } 130673df0db0SJames Feist for (const std::string& interface : connectionGroup.second) 13075b4aa86bSJames Feist { 13085b4aa86bSJames Feist if (interface == objectManagerIface) 13095b4aa86bSJames Feist { 131073df0db0SJames Feist objectMgrPaths[connectionGroup.first] = pathGroup.first; 13115b4aa86bSJames Feist } 13125b4aa86bSJames Feist // this list is alphabetical, so we 13135b4aa86bSJames Feist // should have found the objMgr by now 13145b4aa86bSJames Feist if (interface == pidConfigurationIface || 1315b7a08d04SJames Feist interface == pidZoneConfigurationIface || 1316b7a08d04SJames Feist interface == stepwiseConfigurationIface) 13175b4aa86bSJames Feist { 13185b4aa86bSJames Feist auto findObjMgr = 13195b4aa86bSJames Feist objectMgrPaths.find(connectionGroup.first); 13205b4aa86bSJames Feist if (findObjMgr == objectMgrPaths.end()) 13215b4aa86bSJames Feist { 13225b4aa86bSJames Feist BMCWEB_LOG_DEBUG << connectionGroup.first 13235b4aa86bSJames Feist << "Has no Object Manager"; 13245b4aa86bSJames Feist continue; 13255b4aa86bSJames Feist } 13266bce33bcSJames Feist 13276bce33bcSJames Feist calledConnections.insert(connectionGroup.first); 13286bce33bcSJames Feist 132973df0db0SJames Feist asyncPopulatePid(findObjMgr->first, findObjMgr->second, 133073df0db0SJames Feist currentProfile, supportedProfiles, 133173df0db0SJames Feist asyncResp); 13325b4aa86bSJames Feist break; 13335b4aa86bSJames Feist } 13345b4aa86bSJames Feist } 13355b4aa86bSJames Feist } 13365b4aa86bSJames Feist } 133773df0db0SJames Feist } 133873df0db0SJames Feist 1339ecd6a3a2SEd Tanous GetPIDValues(const GetPIDValues&) = delete; 1340ecd6a3a2SEd Tanous GetPIDValues(GetPIDValues&&) = delete; 1341ecd6a3a2SEd Tanous GetPIDValues& operator=(const GetPIDValues&) = delete; 1342ecd6a3a2SEd Tanous GetPIDValues& operator=(GetPIDValues&&) = delete; 1343ecd6a3a2SEd Tanous 134473df0db0SJames Feist std::vector<std::string> supportedProfiles; 134573df0db0SJames Feist std::string currentProfile; 1346b9d36b47SEd Tanous dbus::utility::MapperGetSubTreeResponse subtree; 13478d1b46d7Szhanghch05 std::shared_ptr<bmcweb::AsyncResp> asyncResp; 134873df0db0SJames Feist }; 134973df0db0SJames Feist 135073df0db0SJames Feist struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> 135173df0db0SJames Feist { 135273df0db0SJames Feist 13538d1b46d7Szhanghch05 SetPIDValues(const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn, 135473df0db0SJames Feist nlohmann::json& data) : 1355271584abSEd Tanous asyncResp(asyncRespIn) 135673df0db0SJames Feist { 135773df0db0SJames Feist 135873df0db0SJames Feist std::optional<nlohmann::json> pidControllers; 135973df0db0SJames Feist std::optional<nlohmann::json> fanControllers; 136073df0db0SJames Feist std::optional<nlohmann::json> fanZones; 136173df0db0SJames Feist std::optional<nlohmann::json> stepwiseControllers; 136273df0db0SJames Feist 136373df0db0SJames Feist if (!redfish::json_util::readJson( 136473df0db0SJames Feist data, asyncResp->res, "PidControllers", pidControllers, 136573df0db0SJames Feist "FanControllers", fanControllers, "FanZones", fanZones, 136673df0db0SJames Feist "StepwiseControllers", stepwiseControllers, "Profile", profile)) 136773df0db0SJames Feist { 136871f52d96SEd Tanous BMCWEB_LOG_ERROR 136971f52d96SEd Tanous << "Illegal Property " 137071f52d96SEd Tanous << data.dump(2, ' ', true, 137171f52d96SEd Tanous nlohmann::json::error_handler_t::replace); 137273df0db0SJames Feist return; 137373df0db0SJames Feist } 137473df0db0SJames Feist configuration.emplace_back("PidControllers", std::move(pidControllers)); 137573df0db0SJames Feist configuration.emplace_back("FanControllers", std::move(fanControllers)); 137673df0db0SJames Feist configuration.emplace_back("FanZones", std::move(fanZones)); 137773df0db0SJames Feist configuration.emplace_back("StepwiseControllers", 137873df0db0SJames Feist std::move(stepwiseControllers)); 137973df0db0SJames Feist } 1380ecd6a3a2SEd Tanous 1381ecd6a3a2SEd Tanous SetPIDValues(const SetPIDValues&) = delete; 1382ecd6a3a2SEd Tanous SetPIDValues(SetPIDValues&&) = delete; 1383ecd6a3a2SEd Tanous SetPIDValues& operator=(const SetPIDValues&) = delete; 1384ecd6a3a2SEd Tanous SetPIDValues& operator=(SetPIDValues&&) = delete; 1385ecd6a3a2SEd Tanous 138673df0db0SJames Feist void run() 138773df0db0SJames Feist { 138873df0db0SJames Feist if (asyncResp->res.result() != boost::beast::http::status::ok) 138973df0db0SJames Feist { 139073df0db0SJames Feist return; 139173df0db0SJames Feist } 139273df0db0SJames Feist 139373df0db0SJames Feist std::shared_ptr<SetPIDValues> self = shared_from_this(); 139473df0db0SJames Feist 139573df0db0SJames Feist // todo(james): might make sense to do a mapper call here if this 139673df0db0SJames Feist // interface gets more traction 139773df0db0SJames Feist crow::connections::systemBus->async_method_call( 139873df0db0SJames Feist [self](const boost::system::error_code ec, 1399914e2d5dSEd Tanous const dbus::utility::ManagedObjectType& mObj) { 140073df0db0SJames Feist if (ec) 140173df0db0SJames Feist { 140273df0db0SJames Feist BMCWEB_LOG_ERROR << "Error communicating to Entity Manager"; 140373df0db0SJames Feist messages::internalError(self->asyncResp->res); 140473df0db0SJames Feist return; 140573df0db0SJames Feist } 1406e69d9de2SJames Feist const std::array<const char*, 3> configurations = { 1407e69d9de2SJames Feist pidConfigurationIface, pidZoneConfigurationIface, 1408e69d9de2SJames Feist stepwiseConfigurationIface}; 1409e69d9de2SJames Feist 141014b0b8d5SJames Feist for (const auto& [path, object] : mObj) 1411e69d9de2SJames Feist { 141214b0b8d5SJames Feist for (const auto& [interface, _] : object) 1413e69d9de2SJames Feist { 1414e69d9de2SJames Feist if (std::find(configurations.begin(), 1415e69d9de2SJames Feist configurations.end(), 1416e69d9de2SJames Feist interface) != configurations.end()) 1417e69d9de2SJames Feist { 141814b0b8d5SJames Feist self->objectCount++; 1419e69d9de2SJames Feist break; 1420e69d9de2SJames Feist } 1421e69d9de2SJames Feist } 1422e69d9de2SJames Feist } 1423914e2d5dSEd Tanous self->managedObj = mObj; 142473df0db0SJames Feist }, 142573df0db0SJames Feist "xyz.openbmc_project.EntityManager", "/", objectManagerIface, 142673df0db0SJames Feist "GetManagedObjects"); 142773df0db0SJames Feist 142873df0db0SJames Feist // at the same time get the profile information 142973df0db0SJames Feist crow::connections::systemBus->async_method_call( 143073df0db0SJames Feist [self](const boost::system::error_code ec, 1431b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 143273df0db0SJames Feist if (ec || subtree.empty()) 143373df0db0SJames Feist { 143473df0db0SJames Feist return; 143573df0db0SJames Feist } 143673df0db0SJames Feist if (subtree[0].second.empty()) 143773df0db0SJames Feist { 143873df0db0SJames Feist // invalid mapper response, should never happen 143973df0db0SJames Feist BMCWEB_LOG_ERROR << "SetPIDValues: Mapper Error"; 144073df0db0SJames Feist messages::internalError(self->asyncResp->res); 144173df0db0SJames Feist return; 144273df0db0SJames Feist } 144373df0db0SJames Feist 144473df0db0SJames Feist const std::string& path = subtree[0].first; 144573df0db0SJames Feist const std::string& owner = subtree[0].second[0].first; 144673df0db0SJames Feist crow::connections::systemBus->async_method_call( 1447b9d36b47SEd Tanous [self, path, 1448b9d36b47SEd Tanous owner](const boost::system::error_code ec2, 1449b9d36b47SEd Tanous const dbus::utility::DBusPropertiesMap& r) { 1450cb13a392SEd Tanous if (ec2) 145173df0db0SJames Feist { 14520fda0f12SGeorge Liu BMCWEB_LOG_ERROR 14530fda0f12SGeorge Liu << "SetPIDValues: Can't get thermalModeIface " 145473df0db0SJames Feist << path; 145573df0db0SJames Feist messages::internalError(self->asyncResp->res); 145673df0db0SJames Feist return; 145773df0db0SJames Feist } 1458271584abSEd Tanous const std::string* current = nullptr; 1459271584abSEd Tanous const std::vector<std::string>* supported = nullptr; 14609eb808c1SEd Tanous for (const auto& [key, value] : r) 146173df0db0SJames Feist { 146273df0db0SJames Feist if (key == "Current") 146373df0db0SJames Feist { 146473df0db0SJames Feist current = std::get_if<std::string>(&value); 146573df0db0SJames Feist if (current == nullptr) 146673df0db0SJames Feist { 146773df0db0SJames Feist BMCWEB_LOG_ERROR 14680fda0f12SGeorge Liu << "SetPIDValues: thermal mode iface invalid " 146973df0db0SJames Feist << path; 147073df0db0SJames Feist messages::internalError( 147173df0db0SJames Feist self->asyncResp->res); 147273df0db0SJames Feist return; 147373df0db0SJames Feist } 147473df0db0SJames Feist } 147573df0db0SJames Feist if (key == "Supported") 147673df0db0SJames Feist { 147773df0db0SJames Feist supported = 147873df0db0SJames Feist std::get_if<std::vector<std::string>>( 147973df0db0SJames Feist &value); 148073df0db0SJames Feist if (supported == nullptr) 148173df0db0SJames Feist { 148273df0db0SJames Feist BMCWEB_LOG_ERROR 14830fda0f12SGeorge Liu << "SetPIDValues: thermal mode iface invalid" 148473df0db0SJames Feist << path; 148573df0db0SJames Feist messages::internalError( 148673df0db0SJames Feist self->asyncResp->res); 148773df0db0SJames Feist return; 148873df0db0SJames Feist } 148973df0db0SJames Feist } 149073df0db0SJames Feist } 149173df0db0SJames Feist if (current == nullptr || supported == nullptr) 149273df0db0SJames Feist { 14930fda0f12SGeorge Liu BMCWEB_LOG_ERROR 14940fda0f12SGeorge Liu << "SetPIDValues: thermal mode iface invalid " 149573df0db0SJames Feist << path; 149673df0db0SJames Feist messages::internalError(self->asyncResp->res); 149773df0db0SJames Feist return; 149873df0db0SJames Feist } 149973df0db0SJames Feist self->currentProfile = *current; 150073df0db0SJames Feist self->supportedProfiles = *supported; 150173df0db0SJames Feist self->profileConnection = owner; 150273df0db0SJames Feist self->profilePath = path; 150373df0db0SJames Feist }, 150473df0db0SJames Feist owner, path, "org.freedesktop.DBus.Properties", "GetAll", 150573df0db0SJames Feist thermalModeIface); 15065b4aa86bSJames Feist }, 15075b4aa86bSJames Feist "xyz.openbmc_project.ObjectMapper", 15085b4aa86bSJames Feist "/xyz/openbmc_project/object_mapper", 15095b4aa86bSJames Feist "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0, 151073df0db0SJames Feist std::array<const char*, 1>{thermalModeIface}); 151173df0db0SJames Feist } 151224b2fe81SEd Tanous void pidSetDone() 151373df0db0SJames Feist { 151473df0db0SJames Feist if (asyncResp->res.result() != boost::beast::http::status::ok) 151573df0db0SJames Feist { 151673df0db0SJames Feist return; 15175b4aa86bSJames Feist } 15188d1b46d7Szhanghch05 std::shared_ptr<bmcweb::AsyncResp> response = asyncResp; 151973df0db0SJames Feist if (profile) 152073df0db0SJames Feist { 152173df0db0SJames Feist if (std::find(supportedProfiles.begin(), supportedProfiles.end(), 152273df0db0SJames Feist *profile) == supportedProfiles.end()) 152373df0db0SJames Feist { 152473df0db0SJames Feist messages::actionParameterUnknown(response->res, "Profile", 152573df0db0SJames Feist *profile); 152673df0db0SJames Feist return; 152773df0db0SJames Feist } 152873df0db0SJames Feist currentProfile = *profile; 152973df0db0SJames Feist crow::connections::systemBus->async_method_call( 153073df0db0SJames Feist [response](const boost::system::error_code ec) { 153173df0db0SJames Feist if (ec) 153273df0db0SJames Feist { 153373df0db0SJames Feist BMCWEB_LOG_ERROR << "Error patching profile" << ec; 153473df0db0SJames Feist messages::internalError(response->res); 153573df0db0SJames Feist } 153673df0db0SJames Feist }, 153773df0db0SJames Feist profileConnection, profilePath, 153873df0db0SJames Feist "org.freedesktop.DBus.Properties", "Set", thermalModeIface, 1539168e20c1SEd Tanous "Current", dbus::utility::DbusVariantType(*profile)); 154073df0db0SJames Feist } 154173df0db0SJames Feist 154273df0db0SJames Feist for (auto& containerPair : configuration) 154373df0db0SJames Feist { 154473df0db0SJames Feist auto& container = containerPair.second; 154573df0db0SJames Feist if (!container) 154673df0db0SJames Feist { 154773df0db0SJames Feist continue; 154873df0db0SJames Feist } 15496ee7f774SJames Feist BMCWEB_LOG_DEBUG << *container; 15506ee7f774SJames Feist 155173df0db0SJames Feist std::string& type = containerPair.first; 155273df0db0SJames Feist 155373df0db0SJames Feist for (nlohmann::json::iterator it = container->begin(); 155417a897dfSManojkiran Eda it != container->end(); ++it) 155573df0db0SJames Feist { 155673df0db0SJames Feist const auto& name = it.key(); 15576ee7f774SJames Feist BMCWEB_LOG_DEBUG << "looking for " << name; 15586ee7f774SJames Feist 155973df0db0SJames Feist auto pathItr = 156073df0db0SJames Feist std::find_if(managedObj.begin(), managedObj.end(), 156173df0db0SJames Feist [&name](const auto& obj) { 156273df0db0SJames Feist return boost::algorithm::ends_with( 156373df0db0SJames Feist obj.first.str, "/" + name); 156473df0db0SJames Feist }); 1565b9d36b47SEd Tanous dbus::utility::DBusPropertiesMap output; 156673df0db0SJames Feist 156773df0db0SJames Feist output.reserve(16); // The pid interface length 156873df0db0SJames Feist 156973df0db0SJames Feist // determines if we're patching entity-manager or 157073df0db0SJames Feist // creating a new object 157173df0db0SJames Feist bool createNewObject = (pathItr == managedObj.end()); 15726ee7f774SJames Feist BMCWEB_LOG_DEBUG << "Found = " << !createNewObject; 15736ee7f774SJames Feist 157473df0db0SJames Feist std::string iface; 1575711ac7a9SEd Tanous /* 157673df0db0SJames Feist if (type == "PidControllers" || type == "FanControllers") 157773df0db0SJames Feist { 157873df0db0SJames Feist iface = pidConfigurationIface; 157973df0db0SJames Feist if (!createNewObject && 158073df0db0SJames Feist pathItr->second.find(pidConfigurationIface) == 158173df0db0SJames Feist pathItr->second.end()) 158273df0db0SJames Feist { 158373df0db0SJames Feist createNewObject = true; 158473df0db0SJames Feist } 158573df0db0SJames Feist } 158673df0db0SJames Feist else if (type == "FanZones") 158773df0db0SJames Feist { 158873df0db0SJames Feist iface = pidZoneConfigurationIface; 158973df0db0SJames Feist if (!createNewObject && 159073df0db0SJames Feist pathItr->second.find(pidZoneConfigurationIface) == 159173df0db0SJames Feist pathItr->second.end()) 159273df0db0SJames Feist { 159373df0db0SJames Feist 159473df0db0SJames Feist createNewObject = true; 159573df0db0SJames Feist } 159673df0db0SJames Feist } 159773df0db0SJames Feist else if (type == "StepwiseControllers") 159873df0db0SJames Feist { 159973df0db0SJames Feist iface = stepwiseConfigurationIface; 160073df0db0SJames Feist if (!createNewObject && 160173df0db0SJames Feist pathItr->second.find(stepwiseConfigurationIface) == 160273df0db0SJames Feist pathItr->second.end()) 160373df0db0SJames Feist { 160473df0db0SJames Feist createNewObject = true; 160573df0db0SJames Feist } 1606711ac7a9SEd Tanous }*/ 16076ee7f774SJames Feist 16086ee7f774SJames Feist if (createNewObject && it.value() == nullptr) 16096ee7f774SJames Feist { 16104e0453b1SGunnar Mills // can't delete a non-existent object 16111668ce6dSEd Tanous messages::propertyValueNotInList(response->res, 16121668ce6dSEd Tanous it.value().dump(), name); 16136ee7f774SJames Feist continue; 16146ee7f774SJames Feist } 16156ee7f774SJames Feist 16166ee7f774SJames Feist std::string path; 16176ee7f774SJames Feist if (pathItr != managedObj.end()) 16186ee7f774SJames Feist { 16196ee7f774SJames Feist path = pathItr->first.str; 16206ee7f774SJames Feist } 16216ee7f774SJames Feist 162273df0db0SJames Feist BMCWEB_LOG_DEBUG << "Create new = " << createNewObject << "\n"; 1623e69d9de2SJames Feist 1624e69d9de2SJames Feist // arbitrary limit to avoid attacks 1625e69d9de2SJames Feist constexpr const size_t controllerLimit = 500; 162614b0b8d5SJames Feist if (createNewObject && objectCount >= controllerLimit) 1627e69d9de2SJames Feist { 1628e69d9de2SJames Feist messages::resourceExhaustion(response->res, type); 1629e69d9de2SJames Feist continue; 1630e69d9de2SJames Feist } 1631b9d36b47SEd Tanous output.emplace_back("Name", 1632b9d36b47SEd Tanous boost::replace_all_copy(name, "_", " ")); 163373df0db0SJames Feist 163473df0db0SJames Feist std::string chassis; 163573df0db0SJames Feist CreatePIDRet ret = createPidInterface( 16366ee7f774SJames Feist response, type, it, path, managedObj, createNewObject, 16376ee7f774SJames Feist output, chassis, currentProfile); 163873df0db0SJames Feist if (ret == CreatePIDRet::fail) 163973df0db0SJames Feist { 164073df0db0SJames Feist return; 164173df0db0SJames Feist } 16423174e4dfSEd Tanous if (ret == CreatePIDRet::del) 164373df0db0SJames Feist { 164473df0db0SJames Feist continue; 164573df0db0SJames Feist } 164673df0db0SJames Feist 164773df0db0SJames Feist if (!createNewObject) 164873df0db0SJames Feist { 164973df0db0SJames Feist for (const auto& property : output) 165073df0db0SJames Feist { 165173df0db0SJames Feist crow::connections::systemBus->async_method_call( 165273df0db0SJames Feist [response, 165373df0db0SJames Feist propertyName{std::string(property.first)}]( 165473df0db0SJames Feist const boost::system::error_code ec) { 165573df0db0SJames Feist if (ec) 165673df0db0SJames Feist { 165773df0db0SJames Feist BMCWEB_LOG_ERROR << "Error patching " 165873df0db0SJames Feist << propertyName << ": " 165973df0db0SJames Feist << ec; 166073df0db0SJames Feist messages::internalError(response->res); 166173df0db0SJames Feist return; 166273df0db0SJames Feist } 166373df0db0SJames Feist messages::success(response->res); 166473df0db0SJames Feist }, 16656ee7f774SJames Feist "xyz.openbmc_project.EntityManager", path, 166673df0db0SJames Feist "org.freedesktop.DBus.Properties", "Set", iface, 166773df0db0SJames Feist property.first, property.second); 166873df0db0SJames Feist } 166973df0db0SJames Feist } 167073df0db0SJames Feist else 167173df0db0SJames Feist { 167273df0db0SJames Feist if (chassis.empty()) 167373df0db0SJames Feist { 167473df0db0SJames Feist BMCWEB_LOG_ERROR << "Failed to get chassis from config"; 1675ace85d60SEd Tanous messages::internalError(response->res); 167673df0db0SJames Feist return; 167773df0db0SJames Feist } 167873df0db0SJames Feist 167973df0db0SJames Feist bool foundChassis = false; 168073df0db0SJames Feist for (const auto& obj : managedObj) 168173df0db0SJames Feist { 168273df0db0SJames Feist if (boost::algorithm::ends_with(obj.first.str, chassis)) 168373df0db0SJames Feist { 168473df0db0SJames Feist chassis = obj.first.str; 168573df0db0SJames Feist foundChassis = true; 168673df0db0SJames Feist break; 168773df0db0SJames Feist } 168873df0db0SJames Feist } 168973df0db0SJames Feist if (!foundChassis) 169073df0db0SJames Feist { 169173df0db0SJames Feist BMCWEB_LOG_ERROR << "Failed to find chassis on dbus"; 169273df0db0SJames Feist messages::resourceMissingAtURI( 1693ace85d60SEd Tanous response->res, 1694ace85d60SEd Tanous crow::utility::urlFromPieces("redfish", "v1", 1695ace85d60SEd Tanous "Chassis", chassis)); 169673df0db0SJames Feist return; 169773df0db0SJames Feist } 169873df0db0SJames Feist 169973df0db0SJames Feist crow::connections::systemBus->async_method_call( 170073df0db0SJames Feist [response](const boost::system::error_code ec) { 170173df0db0SJames Feist if (ec) 170273df0db0SJames Feist { 170373df0db0SJames Feist BMCWEB_LOG_ERROR << "Error Adding Pid Object " 170473df0db0SJames Feist << ec; 170573df0db0SJames Feist messages::internalError(response->res); 170673df0db0SJames Feist return; 170773df0db0SJames Feist } 170873df0db0SJames Feist messages::success(response->res); 170973df0db0SJames Feist }, 171073df0db0SJames Feist "xyz.openbmc_project.EntityManager", chassis, 171173df0db0SJames Feist "xyz.openbmc_project.AddObject", "AddObject", output); 171273df0db0SJames Feist } 171373df0db0SJames Feist } 171473df0db0SJames Feist } 171573df0db0SJames Feist } 171624b2fe81SEd Tanous 171724b2fe81SEd Tanous ~SetPIDValues() 171824b2fe81SEd Tanous { 171924b2fe81SEd Tanous try 172024b2fe81SEd Tanous { 172124b2fe81SEd Tanous pidSetDone(); 172224b2fe81SEd Tanous } 172324b2fe81SEd Tanous catch (...) 172424b2fe81SEd Tanous { 172524b2fe81SEd Tanous BMCWEB_LOG_CRITICAL << "pidSetDone threw exception"; 172624b2fe81SEd Tanous } 172724b2fe81SEd Tanous } 172824b2fe81SEd Tanous 17298d1b46d7Szhanghch05 std::shared_ptr<bmcweb::AsyncResp> asyncResp; 173073df0db0SJames Feist std::vector<std::pair<std::string, std::optional<nlohmann::json>>> 173173df0db0SJames Feist configuration; 173273df0db0SJames Feist std::optional<std::string> profile; 173373df0db0SJames Feist dbus::utility::ManagedObjectType managedObj; 173473df0db0SJames Feist std::vector<std::string> supportedProfiles; 173573df0db0SJames Feist std::string currentProfile; 173673df0db0SJames Feist std::string profileConnection; 173773df0db0SJames Feist std::string profilePath; 173814b0b8d5SJames Feist size_t objectCount = 0; 173973df0db0SJames Feist }; 174073df0db0SJames Feist 1741071d8fdfSSunnySrivastava1984 /** 1742071d8fdfSSunnySrivastava1984 * @brief Retrieves BMC manager location data over DBus 1743071d8fdfSSunnySrivastava1984 * 1744071d8fdfSSunnySrivastava1984 * @param[in] aResp Shared pointer for completing asynchronous calls 1745071d8fdfSSunnySrivastava1984 * @param[in] connectionName - service name 1746071d8fdfSSunnySrivastava1984 * @param[in] path - object path 1747071d8fdfSSunnySrivastava1984 * @return none 1748071d8fdfSSunnySrivastava1984 */ 17498d1b46d7Szhanghch05 inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& aResp, 1750071d8fdfSSunnySrivastava1984 const std::string& connectionName, 1751071d8fdfSSunnySrivastava1984 const std::string& path) 1752071d8fdfSSunnySrivastava1984 { 1753071d8fdfSSunnySrivastava1984 BMCWEB_LOG_DEBUG << "Get BMC manager Location data."; 1754071d8fdfSSunnySrivastava1984 17551e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 17561e1e598dSJonathan Doman *crow::connections::systemBus, connectionName, path, 17571e1e598dSJonathan Doman "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", 1758071d8fdfSSunnySrivastava1984 [aResp](const boost::system::error_code ec, 17591e1e598dSJonathan Doman const std::string& property) { 1760071d8fdfSSunnySrivastava1984 if (ec) 1761071d8fdfSSunnySrivastava1984 { 1762071d8fdfSSunnySrivastava1984 BMCWEB_LOG_DEBUG << "DBUS response error for " 1763071d8fdfSSunnySrivastava1984 "Location"; 1764071d8fdfSSunnySrivastava1984 messages::internalError(aResp->res); 1765071d8fdfSSunnySrivastava1984 return; 1766071d8fdfSSunnySrivastava1984 } 1767071d8fdfSSunnySrivastava1984 1768071d8fdfSSunnySrivastava1984 aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = 17691e1e598dSJonathan Doman property; 17701e1e598dSJonathan Doman }); 1771071d8fdfSSunnySrivastava1984 } 17727e860f15SJohn Edward Broadbent // avoid name collision systems.hpp 17737e860f15SJohn Edward Broadbent inline void 17747e860f15SJohn Edward Broadbent managerGetLastResetTime(const std::shared_ptr<bmcweb::AsyncResp>& aResp) 17754bf2b033SGunnar Mills { 17764bf2b033SGunnar Mills BMCWEB_LOG_DEBUG << "Getting Manager Last Reset Time"; 17774bf2b033SGunnar Mills 17781e1e598dSJonathan Doman sdbusplus::asio::getProperty<uint64_t>( 17791e1e598dSJonathan Doman *crow::connections::systemBus, "xyz.openbmc_project.State.BMC", 17801e1e598dSJonathan Doman "/xyz/openbmc_project/state/bmc0", "xyz.openbmc_project.State.BMC", 17811e1e598dSJonathan Doman "LastRebootTime", 17824bf2b033SGunnar Mills [aResp](const boost::system::error_code ec, 17831e1e598dSJonathan Doman const uint64_t lastResetTime) { 17844bf2b033SGunnar Mills if (ec) 17854bf2b033SGunnar Mills { 17864bf2b033SGunnar Mills BMCWEB_LOG_DEBUG << "D-BUS response error " << ec; 17874bf2b033SGunnar Mills return; 17884bf2b033SGunnar Mills } 17894bf2b033SGunnar Mills 17904bf2b033SGunnar Mills // LastRebootTime is epoch time, in milliseconds 17914bf2b033SGunnar Mills // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19 17921e1e598dSJonathan Doman uint64_t lastResetTimeStamp = lastResetTime / 1000; 17934bf2b033SGunnar Mills 17944bf2b033SGunnar Mills // Convert to ISO 8601 standard 17954bf2b033SGunnar Mills aResp->res.jsonValue["LastResetTime"] = 17961d8782e7SNan Zhou crow::utility::getDateTimeUint(lastResetTimeStamp); 17971e1e598dSJonathan Doman }); 17984bf2b033SGunnar Mills } 17994bf2b033SGunnar Mills 18004bfefa74SGunnar Mills /** 18014bfefa74SGunnar Mills * @brief Set the running firmware image 18024bfefa74SGunnar Mills * 18034bfefa74SGunnar Mills * @param[i,o] aResp - Async response object 18044bfefa74SGunnar Mills * @param[i] runningFirmwareTarget - Image to make the running image 18054bfefa74SGunnar Mills * 18064bfefa74SGunnar Mills * @return void 18074bfefa74SGunnar Mills */ 18087e860f15SJohn Edward Broadbent inline void 18097e860f15SJohn Edward Broadbent setActiveFirmwareImage(const std::shared_ptr<bmcweb::AsyncResp>& aResp, 1810f23b7296SEd Tanous const std::string& runningFirmwareTarget) 18114bfefa74SGunnar Mills { 18124bfefa74SGunnar Mills // Get the Id from /redfish/v1/UpdateService/FirmwareInventory/<Id> 1813f23b7296SEd Tanous std::string::size_type idPos = runningFirmwareTarget.rfind('/'); 18144bfefa74SGunnar Mills if (idPos == std::string::npos) 18154bfefa74SGunnar Mills { 18164bfefa74SGunnar Mills messages::propertyValueNotInList(aResp->res, runningFirmwareTarget, 18174bfefa74SGunnar Mills "@odata.id"); 18184bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "Can't parse firmware ID!"; 18194bfefa74SGunnar Mills return; 18204bfefa74SGunnar Mills } 18214bfefa74SGunnar Mills idPos++; 18224bfefa74SGunnar Mills if (idPos >= runningFirmwareTarget.size()) 18234bfefa74SGunnar Mills { 18244bfefa74SGunnar Mills messages::propertyValueNotInList(aResp->res, runningFirmwareTarget, 18254bfefa74SGunnar Mills "@odata.id"); 18264bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "Invalid firmware ID."; 18274bfefa74SGunnar Mills return; 18284bfefa74SGunnar Mills } 18294bfefa74SGunnar Mills std::string firmwareId = runningFirmwareTarget.substr(idPos); 18304bfefa74SGunnar Mills 18314bfefa74SGunnar Mills // Make sure the image is valid before setting priority 18324bfefa74SGunnar Mills crow::connections::systemBus->async_method_call( 1833711ac7a9SEd Tanous [aResp, firmwareId, 1834711ac7a9SEd Tanous runningFirmwareTarget](const boost::system::error_code ec, 1835711ac7a9SEd Tanous dbus::utility::ManagedObjectType& subtree) { 18364bfefa74SGunnar Mills if (ec) 18374bfefa74SGunnar Mills { 18384bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "D-Bus response error getting objects."; 18394bfefa74SGunnar Mills messages::internalError(aResp->res); 18404bfefa74SGunnar Mills return; 18414bfefa74SGunnar Mills } 18424bfefa74SGunnar Mills 184326f6976fSEd Tanous if (subtree.empty()) 18444bfefa74SGunnar Mills { 18454bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "Can't find image!"; 18464bfefa74SGunnar Mills messages::internalError(aResp->res); 18474bfefa74SGunnar Mills return; 18484bfefa74SGunnar Mills } 18494bfefa74SGunnar Mills 18504bfefa74SGunnar Mills bool foundImage = false; 18514bfefa74SGunnar Mills for (auto& object : subtree) 18524bfefa74SGunnar Mills { 18534bfefa74SGunnar Mills const std::string& path = 18544bfefa74SGunnar Mills static_cast<const std::string&>(object.first); 1855f23b7296SEd Tanous std::size_t idPos2 = path.rfind('/'); 18564bfefa74SGunnar Mills 18574bfefa74SGunnar Mills if (idPos2 == std::string::npos) 18584bfefa74SGunnar Mills { 18594bfefa74SGunnar Mills continue; 18604bfefa74SGunnar Mills } 18614bfefa74SGunnar Mills 18624bfefa74SGunnar Mills idPos2++; 18634bfefa74SGunnar Mills if (idPos2 >= path.size()) 18644bfefa74SGunnar Mills { 18654bfefa74SGunnar Mills continue; 18664bfefa74SGunnar Mills } 18674bfefa74SGunnar Mills 18684bfefa74SGunnar Mills if (path.substr(idPos2) == firmwareId) 18694bfefa74SGunnar Mills { 18704bfefa74SGunnar Mills foundImage = true; 18714bfefa74SGunnar Mills break; 18724bfefa74SGunnar Mills } 18734bfefa74SGunnar Mills } 18744bfefa74SGunnar Mills 18754bfefa74SGunnar Mills if (!foundImage) 18764bfefa74SGunnar Mills { 18774bfefa74SGunnar Mills messages::propertyValueNotInList( 18784bfefa74SGunnar Mills aResp->res, runningFirmwareTarget, "@odata.id"); 18794bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "Invalid firmware ID."; 18804bfefa74SGunnar Mills return; 18814bfefa74SGunnar Mills } 18824bfefa74SGunnar Mills 18838cc8edecSEd Tanous BMCWEB_LOG_DEBUG << "Setting firmware version " << firmwareId 18848cc8edecSEd Tanous << " to priority 0."; 18854bfefa74SGunnar Mills 18864bfefa74SGunnar Mills // Only support Immediate 18874bfefa74SGunnar Mills // An addition could be a Redfish Setting like 18884bfefa74SGunnar Mills // ActiveSoftwareImageApplyTime and support OnReset 18894bfefa74SGunnar Mills crow::connections::systemBus->async_method_call( 18904bfefa74SGunnar Mills [aResp](const boost::system::error_code ec) { 18914bfefa74SGunnar Mills if (ec) 18924bfefa74SGunnar Mills { 18934bfefa74SGunnar Mills BMCWEB_LOG_DEBUG << "D-Bus response error setting."; 18944bfefa74SGunnar Mills messages::internalError(aResp->res); 18954bfefa74SGunnar Mills return; 18964bfefa74SGunnar Mills } 18974bfefa74SGunnar Mills doBMCGracefulRestart(aResp); 18984bfefa74SGunnar Mills }, 18994bfefa74SGunnar Mills 19004bfefa74SGunnar Mills "xyz.openbmc_project.Software.BMC.Updater", 19014bfefa74SGunnar Mills "/xyz/openbmc_project/software/" + firmwareId, 19024bfefa74SGunnar Mills "org.freedesktop.DBus.Properties", "Set", 19037e860f15SJohn Edward Broadbent "xyz.openbmc_project.Software.RedundancyPriority", "Priority", 1904168e20c1SEd Tanous dbus::utility::DbusVariantType(static_cast<uint8_t>(0))); 19054bfefa74SGunnar Mills }, 19064bfefa74SGunnar Mills "xyz.openbmc_project.Software.BMC.Updater", 19077e860f15SJohn Edward Broadbent "/xyz/openbmc_project/software", "org.freedesktop.DBus.ObjectManager", 19087e860f15SJohn Edward Broadbent "GetManagedObjects"); 19094bfefa74SGunnar Mills } 19104bfefa74SGunnar Mills 19117e860f15SJohn Edward Broadbent inline void setDateTime(std::shared_ptr<bmcweb::AsyncResp> aResp, 19127e860f15SJohn Edward Broadbent std::string datetime) 1913af5d6058SSantosh Puranik { 1914af5d6058SSantosh Puranik BMCWEB_LOG_DEBUG << "Set date time: " << datetime; 1915af5d6058SSantosh Puranik 1916af5d6058SSantosh Puranik std::stringstream stream(datetime); 1917af5d6058SSantosh Puranik // Convert from ISO 8601 to boost local_time 1918af5d6058SSantosh Puranik // (BMC only has time in UTC) 1919af5d6058SSantosh Puranik boost::posix_time::ptime posixTime; 1920af5d6058SSantosh Puranik boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1)); 1921af5d6058SSantosh Puranik // Facet gets deleted with the stringsteam 1922af5d6058SSantosh Puranik auto ifc = std::make_unique<boost::local_time::local_time_input_facet>( 1923af5d6058SSantosh Puranik "%Y-%m-%d %H:%M:%S%F %ZP"); 1924af5d6058SSantosh Puranik stream.imbue(std::locale(stream.getloc(), ifc.release())); 1925af5d6058SSantosh Puranik 19267e860f15SJohn Edward Broadbent boost::local_time::local_date_time ldt(boost::local_time::not_a_date_time); 1927af5d6058SSantosh Puranik 1928af5d6058SSantosh Puranik if (stream >> ldt) 1929af5d6058SSantosh Puranik { 1930af5d6058SSantosh Puranik posixTime = ldt.utc_time(); 1931af5d6058SSantosh Puranik boost::posix_time::time_duration dur = posixTime - epoch; 19327e860f15SJohn Edward Broadbent uint64_t durMicroSecs = static_cast<uint64_t>(dur.total_microseconds()); 1933af5d6058SSantosh Puranik crow::connections::systemBus->async_method_call( 1934af5d6058SSantosh Puranik [aResp{std::move(aResp)}, datetime{std::move(datetime)}]( 1935af5d6058SSantosh Puranik const boost::system::error_code ec) { 1936af5d6058SSantosh Puranik if (ec) 1937af5d6058SSantosh Puranik { 1938af5d6058SSantosh Puranik BMCWEB_LOG_DEBUG << "Failed to set elapsed time. " 1939af5d6058SSantosh Puranik "DBUS response error " 1940af5d6058SSantosh Puranik << ec; 1941af5d6058SSantosh Puranik messages::internalError(aResp->res); 1942af5d6058SSantosh Puranik return; 1943af5d6058SSantosh Puranik } 1944af5d6058SSantosh Puranik aResp->res.jsonValue["DateTime"] = datetime; 1945af5d6058SSantosh Puranik }, 19467e860f15SJohn Edward Broadbent "xyz.openbmc_project.Time.Manager", "/xyz/openbmc_project/time/bmc", 1947af5d6058SSantosh Puranik "org.freedesktop.DBus.Properties", "Set", 1948af5d6058SSantosh Puranik "xyz.openbmc_project.Time.EpochTime", "Elapsed", 1949168e20c1SEd Tanous dbus::utility::DbusVariantType(durMicroSecs)); 1950af5d6058SSantosh Puranik } 1951af5d6058SSantosh Puranik else 1952af5d6058SSantosh Puranik { 19537e860f15SJohn Edward Broadbent messages::propertyValueFormatError(aResp->res, datetime, "DateTime"); 1954af5d6058SSantosh Puranik return; 1955af5d6058SSantosh Puranik } 195683ff9ab6SJames Feist } 19579c310685SBorawski.Lukasz 19587e860f15SJohn Edward Broadbent inline void requestRoutesManager(App& app) 19597e860f15SJohn Edward Broadbent { 19607e860f15SJohn Edward Broadbent std::string uuid = persistent_data::getConfig().systemUuid; 19619c310685SBorawski.Lukasz 19627e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/") 1963ed398213SEd Tanous .privileges(redfish::privileges::getManager) 1964*45ca1b86SEd Tanous .methods( 1965*45ca1b86SEd Tanous boost::beast::http::verb:: 1966*45ca1b86SEd Tanous get)([&app, uuid]( 1967*45ca1b86SEd Tanous const crow::Request& req, 1968*45ca1b86SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 1969*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 1970*45ca1b86SEd Tanous { 1971*45ca1b86SEd Tanous return; 1972*45ca1b86SEd Tanous } 19737e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc"; 19747e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["@odata.type"] = 19757e860f15SJohn Edward Broadbent "#Manager.v1_11_0.Manager"; 19767e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Id"] = "bmc"; 19777e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Name"] = "OpenBmc Manager"; 19787e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Description"] = 19797e860f15SJohn Edward Broadbent "Baseboard Management Controller"; 19807e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["PowerState"] = "On"; 19817e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Status"] = {{"State", "Enabled"}, 19827e860f15SJohn Edward Broadbent {"Health", "OK"}}; 19837e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["ManagerType"] = "BMC"; 19847e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid(); 19857e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid; 19867e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Model"] = 19877e860f15SJohn Edward Broadbent "OpenBmc"; // TODO(ed), get model 19887e860f15SJohn Edward Broadbent 19897e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["LogServices"] = { 19907e860f15SJohn Edward Broadbent {"@odata.id", "/redfish/v1/Managers/bmc/LogServices"}}; 19917e860f15SJohn Edward Broadbent 19927e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["NetworkProtocol"] = { 19937e860f15SJohn Edward Broadbent {"@odata.id", "/redfish/v1/Managers/bmc/NetworkProtocol"}}; 19947e860f15SJohn Edward Broadbent 19957e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["EthernetInterfaces"] = { 19967e860f15SJohn Edward Broadbent {"@odata.id", "/redfish/v1/Managers/bmc/EthernetInterfaces"}}; 19977e860f15SJohn Edward Broadbent 19987e860f15SJohn Edward Broadbent #ifdef BMCWEB_ENABLE_VM_NBDPROXY 19997e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["VirtualMedia"] = { 20007e860f15SJohn Edward Broadbent {"@odata.id", "/redfish/v1/Managers/bmc/VirtualMedia"}}; 20017e860f15SJohn Edward Broadbent #endif // BMCWEB_ENABLE_VM_NBDPROXY 20027e860f15SJohn Edward Broadbent 20037e860f15SJohn Edward Broadbent // default oem data 20047e860f15SJohn Edward Broadbent nlohmann::json& oem = asyncResp->res.jsonValue["Oem"]; 20057e860f15SJohn Edward Broadbent nlohmann::json& oemOpenbmc = oem["OpenBmc"]; 20067e860f15SJohn Edward Broadbent oem["@odata.type"] = "#OemManager.Oem"; 20077e860f15SJohn Edward Broadbent oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem"; 20087e860f15SJohn Edward Broadbent oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc"; 20097e860f15SJohn Edward Broadbent oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc"; 20107e860f15SJohn Edward Broadbent oemOpenbmc["Certificates"] = { 20117e860f15SJohn Edward Broadbent {"@odata.id", 20127e860f15SJohn Edward Broadbent "/redfish/v1/Managers/bmc/Truststore/Certificates"}}; 20137e860f15SJohn Edward Broadbent 20147e860f15SJohn Edward Broadbent // Manager.Reset (an action) can be many values, OpenBMC only 20157e860f15SJohn Edward Broadbent // supports BMC reboot. 20167e860f15SJohn Edward Broadbent nlohmann::json& managerReset = 20177e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Actions"]["#Manager.Reset"]; 20187e860f15SJohn Edward Broadbent managerReset["target"] = 20197e860f15SJohn Edward Broadbent "/redfish/v1/Managers/bmc/Actions/Manager.Reset"; 20207e860f15SJohn Edward Broadbent managerReset["@Redfish.ActionInfo"] = 20217e860f15SJohn Edward Broadbent "/redfish/v1/Managers/bmc/ResetActionInfo"; 20227e860f15SJohn Edward Broadbent 20237e860f15SJohn Edward Broadbent // ResetToDefaults (Factory Reset) has values like 20247e860f15SJohn Edward Broadbent // PreserveNetworkAndUsers and PreserveNetwork that aren't supported 20257e860f15SJohn Edward Broadbent // on OpenBMC 20267e860f15SJohn Edward Broadbent nlohmann::json& resetToDefaults = 20277e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"]; 20287e860f15SJohn Edward Broadbent resetToDefaults["target"] = 20297e860f15SJohn Edward Broadbent "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults"; 20307e860f15SJohn Edward Broadbent resetToDefaults["ResetType@Redfish.AllowableValues"] = {"ResetAll"}; 20317e860f15SJohn Edward Broadbent 20327c8c4058STejas Patil std::pair<std::string, std::string> redfishDateTimeOffset = 20337c8c4058STejas Patil crow::utility::getDateTimeOffsetNow(); 20347c8c4058STejas Patil 20357c8c4058STejas Patil asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first; 20367c8c4058STejas Patil asyncResp->res.jsonValue["DateTimeLocalOffset"] = 20377c8c4058STejas Patil redfishDateTimeOffset.second; 20387e860f15SJohn Edward Broadbent 20390e8ac5e7SGunnar Mills // TODO (Gunnar): Remove these one day since moved to ComputerSystem 20400e8ac5e7SGunnar Mills // Still used by OCP profiles 20410e8ac5e7SGunnar Mills // https://github.com/opencomputeproject/OCP-Profiles/issues/23 20427e860f15SJohn Edward Broadbent // Fill in SerialConsole info 20437e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["SerialConsole"]["ServiceEnabled"] = true; 20447e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] = 20457e860f15SJohn Edward Broadbent 15; 20467e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["SerialConsole"]["ConnectTypesSupported"] = 20477e860f15SJohn Edward Broadbent {"IPMI", "SSH"}; 20487e860f15SJohn Edward Broadbent #ifdef BMCWEB_ENABLE_KVM 20497e860f15SJohn Edward Broadbent // Fill in GraphicalConsole info 20507e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] = 20517e860f15SJohn Edward Broadbent true; 20527e860f15SJohn Edward Broadbent asyncResp->res 20537e860f15SJohn Edward Broadbent .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4; 20547e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["GraphicalConsole"] 20557e860f15SJohn Edward Broadbent ["ConnectTypesSupported"] = {"KVMIP"}; 20567e860f15SJohn Edward Broadbent #endif // BMCWEB_ENABLE_KVM 20577e860f15SJohn Edward Broadbent 20587e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Links"]["ManagerForServers@odata.count"] = 20597e860f15SJohn Edward Broadbent 1; 20607e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Links"]["ManagerForServers"] = { 20617e860f15SJohn Edward Broadbent {{"@odata.id", "/redfish/v1/Systems/system"}}}; 20627e860f15SJohn Edward Broadbent 20637e860f15SJohn Edward Broadbent auto health = std::make_shared<HealthPopulate>(asyncResp); 20647e860f15SJohn Edward Broadbent health->isManagersHealth = true; 20657e860f15SJohn Edward Broadbent health->populate(); 20667e860f15SJohn Edward Broadbent 20677e860f15SJohn Edward Broadbent fw_util::populateFirmwareInformation(asyncResp, fw_util::bmcPurpose, 20687e860f15SJohn Edward Broadbent "FirmwareVersion", true); 20697e860f15SJohn Edward Broadbent 20707e860f15SJohn Edward Broadbent managerGetLastResetTime(asyncResp); 20717e860f15SJohn Edward Broadbent 20727e860f15SJohn Edward Broadbent auto pids = std::make_shared<GetPIDValues>(asyncResp); 20737e860f15SJohn Edward Broadbent pids->run(); 20747e860f15SJohn Edward Broadbent 20757e860f15SJohn Edward Broadbent getMainChassisId( 20767e860f15SJohn Edward Broadbent asyncResp, [](const std::string& chassisId, 20777e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& aRsp) { 20787e860f15SJohn Edward Broadbent aRsp->res 20797e860f15SJohn Edward Broadbent .jsonValue["Links"]["ManagerForChassis@odata.count"] = 20807e860f15SJohn Edward Broadbent 1; 20817e860f15SJohn Edward Broadbent aRsp->res.jsonValue["Links"]["ManagerForChassis"] = { 20827e860f15SJohn Edward Broadbent {{"@odata.id", "/redfish/v1/Chassis/" + chassisId}}}; 20837e860f15SJohn Edward Broadbent aRsp->res.jsonValue["Links"]["ManagerInChassis"] = { 20847e860f15SJohn Edward Broadbent {"@odata.id", "/redfish/v1/Chassis/" + chassisId}}; 20857e860f15SJohn Edward Broadbent }); 20867e860f15SJohn Edward Broadbent 20877e860f15SJohn Edward Broadbent static bool started = false; 20887e860f15SJohn Edward Broadbent 20897e860f15SJohn Edward Broadbent if (!started) 20901abe55efSEd Tanous { 20911e1e598dSJonathan Doman sdbusplus::asio::getProperty<double>( 20921e1e598dSJonathan Doman *crow::connections::systemBus, "org.freedesktop.systemd1", 20931e1e598dSJonathan Doman "/org/freedesktop/systemd1", 20941e1e598dSJonathan Doman "org.freedesktop.systemd1.Manager", "Progress", 20957e860f15SJohn Edward Broadbent [asyncResp](const boost::system::error_code ec, 20961e1e598dSJonathan Doman const double& val) { 20977e860f15SJohn Edward Broadbent if (ec) 20981abe55efSEd Tanous { 20997e860f15SJohn Edward Broadbent BMCWEB_LOG_ERROR << "Error while getting progress"; 21007e860f15SJohn Edward Broadbent messages::internalError(asyncResp->res); 21017e860f15SJohn Edward Broadbent return; 21027e860f15SJohn Edward Broadbent } 21031e1e598dSJonathan Doman if (val < 1.0) 21047e860f15SJohn Edward Broadbent { 21057e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Status"]["State"] = 21067e860f15SJohn Edward Broadbent "Starting"; 21077e860f15SJohn Edward Broadbent started = true; 21087e860f15SJohn Edward Broadbent } 21091e1e598dSJonathan Doman }); 21109c310685SBorawski.Lukasz } 21119c310685SBorawski.Lukasz 21127e860f15SJohn Edward Broadbent crow::connections::systemBus->async_method_call( 21137e860f15SJohn Edward Broadbent [asyncResp]( 21147e860f15SJohn Edward Broadbent const boost::system::error_code ec, 2115b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 21167e860f15SJohn Edward Broadbent if (ec) 21171abe55efSEd Tanous { 21187e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG 21197e860f15SJohn Edward Broadbent << "D-Bus response error on GetSubTree " << ec; 21207e860f15SJohn Edward Broadbent return; 21217e860f15SJohn Edward Broadbent } 212226f6976fSEd Tanous if (subtree.empty()) 21237e860f15SJohn Edward Broadbent { 21247e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!"; 21257e860f15SJohn Edward Broadbent return; 21267e860f15SJohn Edward Broadbent } 21277e860f15SJohn Edward Broadbent // Assume only 1 bmc D-Bus object 21287e860f15SJohn Edward Broadbent // Throw an error if there is more than 1 21297e860f15SJohn Edward Broadbent if (subtree.size() > 1) 21307e860f15SJohn Edward Broadbent { 21317e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG 21327e860f15SJohn Edward Broadbent << "Found more than 1 bmc D-Bus object!"; 21337e860f15SJohn Edward Broadbent messages::internalError(asyncResp->res); 21347e860f15SJohn Edward Broadbent return; 21357e860f15SJohn Edward Broadbent } 21367e860f15SJohn Edward Broadbent 21377e860f15SJohn Edward Broadbent if (subtree[0].first.empty() || 21387e860f15SJohn Edward Broadbent subtree[0].second.size() != 1) 21397e860f15SJohn Edward Broadbent { 21407e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG << "Error getting bmc D-Bus object!"; 21417e860f15SJohn Edward Broadbent messages::internalError(asyncResp->res); 21427e860f15SJohn Edward Broadbent return; 21437e860f15SJohn Edward Broadbent } 21447e860f15SJohn Edward Broadbent 21457e860f15SJohn Edward Broadbent const std::string& path = subtree[0].first; 21467e860f15SJohn Edward Broadbent const std::string& connectionName = 21477e860f15SJohn Edward Broadbent subtree[0].second[0].first; 21487e860f15SJohn Edward Broadbent 21497e860f15SJohn Edward Broadbent for (const auto& interfaceName : 21507e860f15SJohn Edward Broadbent subtree[0].second[0].second) 21517e860f15SJohn Edward Broadbent { 21527e860f15SJohn Edward Broadbent if (interfaceName == 21537e860f15SJohn Edward Broadbent "xyz.openbmc_project.Inventory.Decorator.Asset") 21547e860f15SJohn Edward Broadbent { 21557e860f15SJohn Edward Broadbent crow::connections::systemBus->async_method_call( 21567e860f15SJohn Edward Broadbent [asyncResp]( 21577e860f15SJohn Edward Broadbent const boost::system::error_code ec, 2158b9d36b47SEd Tanous const dbus::utility::DBusPropertiesMap& 21597e860f15SJohn Edward Broadbent propertiesList) { 21607e860f15SJohn Edward Broadbent if (ec) 21617e860f15SJohn Edward Broadbent { 21627e860f15SJohn Edward Broadbent BMCWEB_LOG_DEBUG 21637e860f15SJohn Edward Broadbent << "Can't get bmc asset!"; 21647e860f15SJohn Edward Broadbent return; 21657e860f15SJohn Edward Broadbent } 21667e860f15SJohn Edward Broadbent for (const std::pair< 21677e860f15SJohn Edward Broadbent std::string, 2168168e20c1SEd Tanous dbus::utility::DbusVariantType>& 21697e860f15SJohn Edward Broadbent property : propertiesList) 21707e860f15SJohn Edward Broadbent { 21717e860f15SJohn Edward Broadbent const std::string& propertyName = 21727e860f15SJohn Edward Broadbent property.first; 21737e860f15SJohn Edward Broadbent 21747e860f15SJohn Edward Broadbent if ((propertyName == "PartNumber") || 21757e860f15SJohn Edward Broadbent (propertyName == "SerialNumber") || 21767e860f15SJohn Edward Broadbent (propertyName == "Manufacturer") || 21777e860f15SJohn Edward Broadbent (propertyName == "Model") || 21787e860f15SJohn Edward Broadbent (propertyName == "SparePartNumber")) 21797e860f15SJohn Edward Broadbent { 21807e860f15SJohn Edward Broadbent const std::string* value = 21817e860f15SJohn Edward Broadbent std::get_if<std::string>( 21827e860f15SJohn Edward Broadbent &property.second); 21837e860f15SJohn Edward Broadbent if (value == nullptr) 21847e860f15SJohn Edward Broadbent { 21857e860f15SJohn Edward Broadbent // illegal property 21867e860f15SJohn Edward Broadbent messages::internalError( 21877e860f15SJohn Edward Broadbent asyncResp->res); 21887e860f15SJohn Edward Broadbent return; 21897e860f15SJohn Edward Broadbent } 21907e860f15SJohn Edward Broadbent asyncResp->res 21917e860f15SJohn Edward Broadbent .jsonValue[propertyName] = 21927e860f15SJohn Edward Broadbent *value; 21937e860f15SJohn Edward Broadbent } 21947e860f15SJohn Edward Broadbent } 21957e860f15SJohn Edward Broadbent }, 21967e860f15SJohn Edward Broadbent connectionName, path, 21977e860f15SJohn Edward Broadbent "org.freedesktop.DBus.Properties", "GetAll", 21980fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.Asset"); 21997e860f15SJohn Edward Broadbent } 22000fda0f12SGeorge Liu else if ( 22010fda0f12SGeorge Liu interfaceName == 22020fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.LocationCode") 22037e860f15SJohn Edward Broadbent { 22047e860f15SJohn Edward Broadbent getLocation(asyncResp, connectionName, path); 22057e860f15SJohn Edward Broadbent } 22067e860f15SJohn Edward Broadbent } 22077e860f15SJohn Edward Broadbent }, 22087e860f15SJohn Edward Broadbent "xyz.openbmc_project.ObjectMapper", 22097e860f15SJohn Edward Broadbent "/xyz/openbmc_project/object_mapper", 22107e860f15SJohn Edward Broadbent "xyz.openbmc_project.ObjectMapper", "GetSubTree", 22117e860f15SJohn Edward Broadbent "/xyz/openbmc_project/inventory", int32_t(0), 22127e860f15SJohn Edward Broadbent std::array<const char*, 1>{ 22137e860f15SJohn Edward Broadbent "xyz.openbmc_project.Inventory.Item.Bmc"}); 22147e860f15SJohn Edward Broadbent }); 22157e860f15SJohn Edward Broadbent 22167e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/") 2217ed398213SEd Tanous .privileges(redfish::privileges::patchManager) 2218*45ca1b86SEd Tanous .methods(boost::beast::http::verb::patch)( 2219*45ca1b86SEd Tanous [&app](const crow::Request& req, 22207e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 2221*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 2222*45ca1b86SEd Tanous { 2223*45ca1b86SEd Tanous return; 2224*45ca1b86SEd Tanous } 22257e860f15SJohn Edward Broadbent std::optional<nlohmann::json> oem; 22267e860f15SJohn Edward Broadbent std::optional<nlohmann::json> links; 22277e860f15SJohn Edward Broadbent std::optional<std::string> datetime; 22287e860f15SJohn Edward Broadbent 222915ed6780SWilly Tu if (!json_util::readJsonPatch(req, asyncResp->res, "Oem", oem, 2230*45ca1b86SEd Tanous "DateTime", datetime, "Links", 2231*45ca1b86SEd Tanous links)) 22327e860f15SJohn Edward Broadbent { 22337e860f15SJohn Edward Broadbent return; 22347e860f15SJohn Edward Broadbent } 22357e860f15SJohn Edward Broadbent 22367e860f15SJohn Edward Broadbent if (oem) 22377e860f15SJohn Edward Broadbent { 22387e860f15SJohn Edward Broadbent std::optional<nlohmann::json> openbmc; 22397e860f15SJohn Edward Broadbent if (!redfish::json_util::readJson(*oem, asyncResp->res, 22407e860f15SJohn Edward Broadbent "OpenBmc", openbmc)) 22417e860f15SJohn Edward Broadbent { 22427e860f15SJohn Edward Broadbent BMCWEB_LOG_ERROR 22437e860f15SJohn Edward Broadbent << "Illegal Property " 2244*45ca1b86SEd Tanous << oem->dump( 2245*45ca1b86SEd Tanous 2, ' ', true, 22467e860f15SJohn Edward Broadbent nlohmann::json::error_handler_t::replace); 22477e860f15SJohn Edward Broadbent return; 22487e860f15SJohn Edward Broadbent } 22497e860f15SJohn Edward Broadbent if (openbmc) 22507e860f15SJohn Edward Broadbent { 22517e860f15SJohn Edward Broadbent std::optional<nlohmann::json> fan; 2252*45ca1b86SEd Tanous if (!redfish::json_util::readJson( 2253*45ca1b86SEd Tanous *openbmc, asyncResp->res, "Fan", fan)) 22547e860f15SJohn Edward Broadbent { 22557e860f15SJohn Edward Broadbent BMCWEB_LOG_ERROR 22567e860f15SJohn Edward Broadbent << "Illegal Property " 2257*45ca1b86SEd Tanous << openbmc->dump(2, ' ', true, 2258*45ca1b86SEd Tanous nlohmann::json:: 2259*45ca1b86SEd Tanous error_handler_t::replace); 22607e860f15SJohn Edward Broadbent return; 22617e860f15SJohn Edward Broadbent } 22627e860f15SJohn Edward Broadbent if (fan) 22637e860f15SJohn Edward Broadbent { 22647e860f15SJohn Edward Broadbent auto pid = 22657e860f15SJohn Edward Broadbent std::make_shared<SetPIDValues>(asyncResp, *fan); 22667e860f15SJohn Edward Broadbent pid->run(); 22677e860f15SJohn Edward Broadbent } 22687e860f15SJohn Edward Broadbent } 22697e860f15SJohn Edward Broadbent } 22707e860f15SJohn Edward Broadbent if (links) 22717e860f15SJohn Edward Broadbent { 22727e860f15SJohn Edward Broadbent std::optional<nlohmann::json> activeSoftwareImage; 22737e860f15SJohn Edward Broadbent if (!redfish::json_util::readJson(*links, asyncResp->res, 22747e860f15SJohn Edward Broadbent "ActiveSoftwareImage", 22757e860f15SJohn Edward Broadbent activeSoftwareImage)) 22767e860f15SJohn Edward Broadbent { 22777e860f15SJohn Edward Broadbent return; 22787e860f15SJohn Edward Broadbent } 22797e860f15SJohn Edward Broadbent if (activeSoftwareImage) 22807e860f15SJohn Edward Broadbent { 22817e860f15SJohn Edward Broadbent std::optional<std::string> odataId; 22827e860f15SJohn Edward Broadbent if (!json_util::readJson(*activeSoftwareImage, 22837e860f15SJohn Edward Broadbent asyncResp->res, "@odata.id", 22847e860f15SJohn Edward Broadbent odataId)) 22857e860f15SJohn Edward Broadbent { 22867e860f15SJohn Edward Broadbent return; 22877e860f15SJohn Edward Broadbent } 22887e860f15SJohn Edward Broadbent 22897e860f15SJohn Edward Broadbent if (odataId) 22907e860f15SJohn Edward Broadbent { 22917e860f15SJohn Edward Broadbent setActiveFirmwareImage(asyncResp, *odataId); 22927e860f15SJohn Edward Broadbent } 22937e860f15SJohn Edward Broadbent } 22947e860f15SJohn Edward Broadbent } 22957e860f15SJohn Edward Broadbent if (datetime) 22967e860f15SJohn Edward Broadbent { 22977e860f15SJohn Edward Broadbent setDateTime(asyncResp, std::move(*datetime)); 22987e860f15SJohn Edward Broadbent } 22997e860f15SJohn Edward Broadbent }); 23007e860f15SJohn Edward Broadbent } 23017e860f15SJohn Edward Broadbent 23027e860f15SJohn Edward Broadbent inline void requestRoutesManagerCollection(App& app) 23037e860f15SJohn Edward Broadbent { 23047e860f15SJohn Edward Broadbent BMCWEB_ROUTE(app, "/redfish/v1/Managers/") 2305ed398213SEd Tanous .privileges(redfish::privileges::getManagerCollection) 23067e860f15SJohn Edward Broadbent .methods(boost::beast::http::verb::get)( 2307*45ca1b86SEd Tanous [&app](const crow::Request& req, 23087e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { 2309*45ca1b86SEd Tanous if (!redfish::setUpRedfishRoute(app, req, asyncResp->res)) 2310*45ca1b86SEd Tanous { 2311*45ca1b86SEd Tanous return; 2312*45ca1b86SEd Tanous } 231383ff9ab6SJames Feist // Collections don't include the static data added by SubRoute 231483ff9ab6SJames Feist // because it has a duplicate entry for members 23158d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers"; 23168d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 23178d1b46d7Szhanghch05 "#ManagerCollection.ManagerCollection"; 23188d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Manager Collection"; 23198d1b46d7Szhanghch05 asyncResp->res.jsonValue["Members@odata.count"] = 1; 23208d1b46d7Szhanghch05 asyncResp->res.jsonValue["Members"] = { 23215b4aa86bSJames Feist {{"@odata.id", "/redfish/v1/Managers/bmc"}}}; 23227e860f15SJohn Edward Broadbent }); 23239c310685SBorawski.Lukasz } 23249c310685SBorawski.Lukasz } // namespace redfish 2325