1e37f8451SRapkiewicz, Pawel /* 2e37f8451SRapkiewicz, Pawel // Copyright (c) 2018 Intel Corporation 3e37f8451SRapkiewicz, Pawel // 4e37f8451SRapkiewicz, Pawel // Licensed under the Apache License, Version 2.0 (the "License"); 5e37f8451SRapkiewicz, Pawel // you may not use this file except in compliance with the License. 6e37f8451SRapkiewicz, Pawel // You may obtain a copy of the License at 7e37f8451SRapkiewicz, Pawel // 8e37f8451SRapkiewicz, Pawel // http://www.apache.org/licenses/LICENSE-2.0 9e37f8451SRapkiewicz, Pawel // 10e37f8451SRapkiewicz, Pawel // Unless required by applicable law or agreed to in writing, software 11e37f8451SRapkiewicz, Pawel // distributed under the License is distributed on an "AS IS" BASIS, 12e37f8451SRapkiewicz, Pawel // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e37f8451SRapkiewicz, Pawel // See the License for the specific language governing permissions and 14e37f8451SRapkiewicz, Pawel // limitations under the License. 15e37f8451SRapkiewicz, Pawel */ 16e37f8451SRapkiewicz, Pawel #pragma once 17e37f8451SRapkiewicz, Pawel 18*13451e39SWilly Tu #include "bmcweb_config.h" 19*13451e39SWilly Tu 203ccb3adbSEd Tanous #include "app.hpp" 217a1dbc48SGeorge Liu #include "dbus_utility.hpp" 22b49ac873SJames Feist #include "health.hpp" 231c8fba97SJames Feist #include "led.hpp" 243ccb3adbSEd Tanous #include "query.hpp" 253ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 263ccb3adbSEd Tanous #include "utils/collection.hpp" 273ccb3adbSEd Tanous #include "utils/dbus_utils.hpp" 28cf7eba09SNan Zhou #include "utils/json_utils.hpp" 291abe55efSEd Tanous 30e99073f5SGeorge Liu #include <boost/system/error_code.hpp> 31ef4c65b7SEd Tanous #include <boost/url/format.hpp> 321e1e598dSJonathan Doman #include <sdbusplus/asio/property.hpp> 3386d89ed7SKrzysztof Grobelny #include <sdbusplus/unpack_properties.hpp> 341214b7e7SGunnar Mills 357a1dbc48SGeorge Liu #include <array> 367a1dbc48SGeorge Liu #include <string_view> 377a1dbc48SGeorge Liu 381abe55efSEd Tanous namespace redfish 391abe55efSEd Tanous { 40e37f8451SRapkiewicz, Pawel 41e37f8451SRapkiewicz, Pawel /** 42beeca0aeSGunnar Mills * @brief Retrieves chassis state properties over dbus 43beeca0aeSGunnar Mills * 44beeca0aeSGunnar Mills * @param[in] aResp - Shared pointer for completing asynchronous calls. 45beeca0aeSGunnar Mills * 46beeca0aeSGunnar Mills * @return None. 47beeca0aeSGunnar Mills */ 488d1b46d7Szhanghch05 inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> aResp) 49beeca0aeSGunnar Mills { 501e1e598dSJonathan Doman // crow::connections::systemBus->async_method_call( 511e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 521e1e598dSJonathan Doman *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis", 531e1e598dSJonathan Doman "/xyz/openbmc_project/state/chassis0", 541e1e598dSJonathan Doman "xyz.openbmc_project.State.Chassis", "CurrentPowerState", 555e7e2dc5SEd Tanous [aResp{std::move(aResp)}](const boost::system::error_code& ec, 561e1e598dSJonathan Doman const std::string& chassisState) { 57beeca0aeSGunnar Mills if (ec) 58beeca0aeSGunnar Mills { 59a6e5e0abSCarson Labrado if (ec == boost::system::errc::host_unreachable) 60a6e5e0abSCarson Labrado { 61a6e5e0abSCarson Labrado // Service not available, no error, just don't return 62a6e5e0abSCarson Labrado // chassis state info 63a6e5e0abSCarson Labrado BMCWEB_LOG_DEBUG << "Service not available " << ec; 64a6e5e0abSCarson Labrado return; 65a6e5e0abSCarson Labrado } 66beeca0aeSGunnar Mills BMCWEB_LOG_DEBUG << "DBUS response error " << ec; 67beeca0aeSGunnar Mills messages::internalError(aResp->res); 68beeca0aeSGunnar Mills return; 69beeca0aeSGunnar Mills } 70beeca0aeSGunnar Mills 711e1e598dSJonathan Doman BMCWEB_LOG_DEBUG << "Chassis state: " << chassisState; 72beeca0aeSGunnar Mills // Verify Chassis State 73002d39b4SEd Tanous if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On") 74beeca0aeSGunnar Mills { 75beeca0aeSGunnar Mills aResp->res.jsonValue["PowerState"] = "On"; 76beeca0aeSGunnar Mills aResp->res.jsonValue["Status"]["State"] = "Enabled"; 77beeca0aeSGunnar Mills } 781e1e598dSJonathan Doman else if (chassisState == 79beeca0aeSGunnar Mills "xyz.openbmc_project.State.Chassis.PowerState.Off") 80beeca0aeSGunnar Mills { 81beeca0aeSGunnar Mills aResp->res.jsonValue["PowerState"] = "Off"; 82beeca0aeSGunnar Mills aResp->res.jsonValue["Status"]["State"] = "StandbyOffline"; 83beeca0aeSGunnar Mills } 841e1e598dSJonathan Doman }); 85beeca0aeSGunnar Mills } 86beeca0aeSGunnar Mills 878d1b46d7Szhanghch05 inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> aResp, 88c181942fSQiang XU const std::string& service, 89c181942fSQiang XU const std::string& objPath) 90c181942fSQiang XU { 91c181942fSQiang XU BMCWEB_LOG_DEBUG << "Get intrusion status by service \n"; 92c181942fSQiang XU 931e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 941e1e598dSJonathan Doman *crow::connections::systemBus, service, objPath, 951e1e598dSJonathan Doman "xyz.openbmc_project.Chassis.Intrusion", "Status", 965e7e2dc5SEd Tanous [aResp{std::move(aResp)}](const boost::system::error_code& ec, 971e1e598dSJonathan Doman const std::string& value) { 98c181942fSQiang XU if (ec) 99c181942fSQiang XU { 1004e0453b1SGunnar Mills // do not add err msg in redfish response, because this is not 101c181942fSQiang XU // mandatory property 102c181942fSQiang XU BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n"; 103c181942fSQiang XU return; 104c181942fSQiang XU } 105c181942fSQiang XU 106002d39b4SEd Tanous aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] = 1; 1071476687dSEd Tanous aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value; 1081e1e598dSJonathan Doman }); 109c181942fSQiang XU } 110c181942fSQiang XU 111c181942fSQiang XU /** 112c181942fSQiang XU * Retrieves physical security properties over dbus 113c181942fSQiang XU */ 1148d1b46d7Szhanghch05 inline void getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> aResp) 115c181942fSQiang XU { 116e99073f5SGeorge Liu constexpr std::array<std::string_view, 1> interfaces = { 117e99073f5SGeorge Liu "xyz.openbmc_project.Chassis.Intrusion"}; 118e99073f5SGeorge Liu dbus::utility::getSubTree( 119e99073f5SGeorge Liu "/xyz/openbmc_project/Intrusion", 1, interfaces, 120c181942fSQiang XU [aResp{std::move(aResp)}]( 121e99073f5SGeorge Liu const boost::system::error_code& ec, 122b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 123c181942fSQiang XU if (ec) 124c181942fSQiang XU { 1254e0453b1SGunnar Mills // do not add err msg in redfish response, because this is not 126c181942fSQiang XU // mandatory property 127002d39b4SEd Tanous BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec << "\n"; 128c181942fSQiang XU return; 129c181942fSQiang XU } 130c181942fSQiang XU // Iterate over all retrieved ObjectPaths. 131c181942fSQiang XU for (const auto& object : subtree) 132c181942fSQiang XU { 133840a9ffcSPatrick Williams if (!object.second.empty()) 134c181942fSQiang XU { 135840a9ffcSPatrick Williams const auto service = object.second.front(); 136c181942fSQiang XU getIntrusionByService(aResp, service.first, object.first); 137c181942fSQiang XU return; 138c181942fSQiang XU } 139c181942fSQiang XU } 140e99073f5SGeorge Liu }); 141c181942fSQiang XU } 142c181942fSQiang XU 143cf7eba09SNan Zhou inline void handleChassisCollectionGet( 144cf7eba09SNan Zhou App& app, const crow::Request& req, 145cf7eba09SNan Zhou const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1461abe55efSEd Tanous { 1473ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 14845ca1b86SEd Tanous { 14945ca1b86SEd Tanous return; 15045ca1b86SEd Tanous } 1518d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 1528d1b46d7Szhanghch05 "#ChassisCollection.ChassisCollection"; 1538d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis"; 1548d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Chassis Collection"; 155e37f8451SRapkiewicz, Pawel 1567a1dbc48SGeorge Liu constexpr std::array<std::string_view, 2> interfaces{ 1577a1dbc48SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board", 1587a1dbc48SGeorge Liu "xyz.openbmc_project.Inventory.Item.Chassis"}; 15902f6ff19SGunnar Mills collection_util::getCollectionMembers( 1607a1dbc48SGeorge Liu asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces); 161cf7eba09SNan Zhou } 162cf7eba09SNan Zhou 163cf7eba09SNan Zhou /** 164cf7eba09SNan Zhou * ChassisCollection derived class for delivering Chassis Collection Schema 165cf7eba09SNan Zhou * Functions triggers appropriate requests on DBus 166cf7eba09SNan Zhou */ 167cf7eba09SNan Zhou inline void requestRoutesChassisCollection(App& app) 168cf7eba09SNan Zhou { 169cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/") 170cf7eba09SNan Zhou .privileges(redfish::privileges::getChassisCollection) 171cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 172cf7eba09SNan Zhou std::bind_front(handleChassisCollectionGet, std::ref(app))); 17362d5e2e4SEd Tanous } 174e37f8451SRapkiewicz, Pawel 175308f70c7SWilly Tu inline void 176308f70c7SWilly Tu getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 177308f70c7SWilly Tu const std::string& connectionName, 178308f70c7SWilly Tu const std::string& path) 179308f70c7SWilly Tu { 1801e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 1811e1e598dSJonathan Doman *crow::connections::systemBus, connectionName, path, 1821e1e598dSJonathan Doman "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", 1835e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec, 1841e1e598dSJonathan Doman const std::string& property) { 185308f70c7SWilly Tu if (ec) 186308f70c7SWilly Tu { 1870fda0f12SGeorge Liu BMCWEB_LOG_DEBUG << "DBUS response error for Location"; 188308f70c7SWilly Tu messages::internalError(asyncResp->res); 189308f70c7SWilly Tu return; 190308f70c7SWilly Tu } 191308f70c7SWilly Tu 192002d39b4SEd Tanous asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = 1931e1e598dSJonathan Doman property; 1941e1e598dSJonathan Doman }); 195308f70c7SWilly Tu } 196308f70c7SWilly Tu 197308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 198308f70c7SWilly Tu const std::string& connectionName, 199308f70c7SWilly Tu const std::string& path) 200308f70c7SWilly Tu { 2011e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 2021e1e598dSJonathan Doman *crow::connections::systemBus, connectionName, path, 2031e1e598dSJonathan Doman "xyz.openbmc_project.Common.UUID", "UUID", 2045e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec, 2051e1e598dSJonathan Doman const std::string& chassisUUID) { 206308f70c7SWilly Tu if (ec) 207308f70c7SWilly Tu { 2080fda0f12SGeorge Liu BMCWEB_LOG_DEBUG << "DBUS response error for UUID"; 209308f70c7SWilly Tu messages::internalError(asyncResp->res); 210308f70c7SWilly Tu return; 211308f70c7SWilly Tu } 2121e1e598dSJonathan Doman asyncResp->res.jsonValue["UUID"] = chassisUUID; 2131e1e598dSJonathan Doman }); 214308f70c7SWilly Tu } 215308f70c7SWilly Tu 216cf7eba09SNan Zhou inline void 217cf7eba09SNan Zhou handleChassisGet(App& app, const crow::Request& req, 21845ca1b86SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 219cf7eba09SNan Zhou const std::string& chassisId) 220cf7eba09SNan Zhou { 2213ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 22245ca1b86SEd Tanous { 22345ca1b86SEd Tanous return; 22445ca1b86SEd Tanous } 225e99073f5SGeorge Liu constexpr std::array<std::string_view, 2> interfaces = { 226734bfe90SGunnar Mills "xyz.openbmc_project.Inventory.Item.Board", 227adc4f0dbSShawn McCarney "xyz.openbmc_project.Inventory.Item.Chassis"}; 228734bfe90SGunnar Mills 229e99073f5SGeorge Liu dbus::utility::getSubTree( 230e99073f5SGeorge Liu "/xyz/openbmc_project/inventory", 0, interfaces, 23162d5e2e4SEd Tanous [asyncResp, chassisId(std::string(chassisId))]( 232e99073f5SGeorge Liu const boost::system::error_code& ec, 233b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 23462d5e2e4SEd Tanous if (ec) 2351abe55efSEd Tanous { 236f12894f8SJason M. Bills messages::internalError(asyncResp->res); 237daf36e2eSEd Tanous return; 238daf36e2eSEd Tanous } 239daf36e2eSEd Tanous // Iterate over all retrieved ObjectPaths. 240cf7eba09SNan Zhou for (const std::pair< 241cf7eba09SNan Zhou std::string, 242cf7eba09SNan Zhou std::vector<std::pair<std::string, std::vector<std::string>>>>& 2431214b7e7SGunnar Mills object : subtree) 2441abe55efSEd Tanous { 245daf36e2eSEd Tanous const std::string& path = object.first; 246cf7eba09SNan Zhou const std::vector<std::pair<std::string, std::vector<std::string>>>& 2471214b7e7SGunnar Mills connectionNames = object.second; 2487e860f15SJohn Edward Broadbent 249997093ebSGeorge Liu sdbusplus::message::object_path objPath(path); 250997093ebSGeorge Liu if (objPath.filename() != chassisId) 2511abe55efSEd Tanous { 252daf36e2eSEd Tanous continue; 253daf36e2eSEd Tanous } 25426f03899SShawn McCarney 255002d39b4SEd Tanous auto health = std::make_shared<HealthPopulate>(asyncResp); 256b49ac873SJames Feist 257*13451e39SWilly Tu if constexpr (bmcwebEnableHealthPopulate) 258*13451e39SWilly Tu { 2596c3e9451SGeorge Liu dbus::utility::getAssociationEndPoints( 2606c3e9451SGeorge Liu path + "/all_sensors", 2615e7e2dc5SEd Tanous [health](const boost::system::error_code& ec2, 2626c3e9451SGeorge Liu const dbus::utility::MapperEndPoints& resp) { 26323a21a1cSEd Tanous if (ec2) 264b49ac873SJames Feist { 265b49ac873SJames Feist return; // no sensors = no failures 266b49ac873SJames Feist } 2671e1e598dSJonathan Doman health->inventory = resp; 2681e1e598dSJonathan Doman }); 269b49ac873SJames Feist 270b49ac873SJames Feist health->populate(); 271*13451e39SWilly Tu } 272b49ac873SJames Feist 27326f6976fSEd Tanous if (connectionNames.empty()) 2741abe55efSEd Tanous { 2751c8fba97SJames Feist BMCWEB_LOG_ERROR << "Got 0 Connection names"; 276e0d918bcSEd Tanous continue; 277daf36e2eSEd Tanous } 278e0d918bcSEd Tanous 27949c53ac9SJohnathan Mantey asyncResp->res.jsonValue["@odata.type"] = 280523d4868SLogananth Sundararaj "#Chassis.v1_22_0.Chassis"; 28149c53ac9SJohnathan Mantey asyncResp->res.jsonValue["@odata.id"] = 282ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}", chassisId); 28349c53ac9SJohnathan Mantey asyncResp->res.jsonValue["Name"] = "Chassis Collection"; 28449c53ac9SJohnathan Mantey asyncResp->res.jsonValue["ChassisType"] = "RackMount"; 285cf7eba09SNan Zhou asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"]["target"] = 286ef4c65b7SEd Tanous boost::urls::format( 287ef4c65b7SEd Tanous "/redfish/v1/Chassis/{}/Actions/Chassis.Reset", chassisId); 2881476687dSEd Tanous asyncResp->res 289cf7eba09SNan Zhou .jsonValue["Actions"]["#Chassis.Reset"]["@Redfish.ActionInfo"] = 290ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}/ResetActionInfo", 291ef4c65b7SEd Tanous chassisId); 2921476687dSEd Tanous asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] = 293ef4c65b7SEd Tanous "/redfish/v1/Systems/system/PCIeDevices"; 29449c53ac9SJohnathan Mantey 2956c3e9451SGeorge Liu dbus::utility::getAssociationEndPoints( 2966c3e9451SGeorge Liu path + "/drive", 2976c3e9451SGeorge Liu [asyncResp, 2986c3e9451SGeorge Liu chassisId](const boost::system::error_code& ec3, 2996c3e9451SGeorge Liu const dbus::utility::MapperEndPoints& resp) { 30092903bd4SJohn Edward Broadbent if (ec3 || resp.empty()) 30192903bd4SJohn Edward Broadbent { 30292903bd4SJohn Edward Broadbent return; // no drives = no failures 30392903bd4SJohn Edward Broadbent } 30492903bd4SJohn Edward Broadbent 30592903bd4SJohn Edward Broadbent nlohmann::json reference; 306ef4c65b7SEd Tanous reference["@odata.id"] = boost::urls::format( 307ef4c65b7SEd Tanous "/redfish/v1/Chassis/{}/Drives", chassisId); 30892903bd4SJohn Edward Broadbent asyncResp->res.jsonValue["Drives"] = std::move(reference); 30992903bd4SJohn Edward Broadbent }); 31092903bd4SJohn Edward Broadbent 311002d39b4SEd Tanous const std::string& connectionName = connectionNames[0].first; 3121c8fba97SJames Feist 31323a21a1cSEd Tanous const std::vector<std::string>& interfaces2 = 3141c8fba97SJames Feist connectionNames[0].second; 3151c8fba97SJames Feist const std::array<const char*, 2> hasIndicatorLed = { 3161c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Panel", 3170fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board.Motherboard"}; 3181c8fba97SJames Feist 319476b9cc5STejas Patil const std::string assetTagInterface = 3200fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.AssetTag"; 321523d4868SLogananth Sundararaj const std::string replaceableInterface = 322523d4868SLogananth Sundararaj "xyz.openbmc_project.Inventory.Decorator.Replaceable"; 323523d4868SLogananth Sundararaj for (const auto& interface : interfaces2) 324523d4868SLogananth Sundararaj { 325523d4868SLogananth Sundararaj if (interface == assetTagInterface) 326476b9cc5STejas Patil { 3271e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 328002d39b4SEd Tanous *crow::connections::systemBus, connectionName, path, 329002d39b4SEd Tanous assetTagInterface, "AssetTag", 330523d4868SLogananth Sundararaj [asyncResp, 331523d4868SLogananth Sundararaj chassisId](const boost::system::error_code& ec2, 3321e1e598dSJonathan Doman const std::string& property) { 3338a592810SEd Tanous if (ec2) 334476b9cc5STejas Patil { 335523d4868SLogananth Sundararaj BMCWEB_LOG_ERROR 336523d4868SLogananth Sundararaj << "DBus response error for AssetTag: " << ec2; 337476b9cc5STejas Patil messages::internalError(asyncResp->res); 338476b9cc5STejas Patil return; 339476b9cc5STejas Patil } 340002d39b4SEd Tanous asyncResp->res.jsonValue["AssetTag"] = property; 3411e1e598dSJonathan Doman }); 342476b9cc5STejas Patil } 343523d4868SLogananth Sundararaj else if (interface == replaceableInterface) 344523d4868SLogananth Sundararaj { 345523d4868SLogananth Sundararaj sdbusplus::asio::getProperty<bool>( 346523d4868SLogananth Sundararaj *crow::connections::systemBus, connectionName, path, 347523d4868SLogananth Sundararaj replaceableInterface, "HotPluggable", 348523d4868SLogananth Sundararaj [asyncResp, 349523d4868SLogananth Sundararaj chassisId](const boost::system::error_code& ec2, 350523d4868SLogananth Sundararaj const bool property) { 351523d4868SLogananth Sundararaj if (ec2) 352523d4868SLogananth Sundararaj { 353523d4868SLogananth Sundararaj BMCWEB_LOG_ERROR 354523d4868SLogananth Sundararaj << "DBus response error for HotPluggable: " 355523d4868SLogananth Sundararaj << ec2; 356523d4868SLogananth Sundararaj messages::internalError(asyncResp->res); 357523d4868SLogananth Sundararaj return; 358523d4868SLogananth Sundararaj } 359523d4868SLogananth Sundararaj asyncResp->res.jsonValue["HotPluggable"] = property; 360523d4868SLogananth Sundararaj }); 361523d4868SLogananth Sundararaj } 362523d4868SLogananth Sundararaj } 363476b9cc5STejas Patil 3641c8fba97SJames Feist for (const char* interface : hasIndicatorLed) 3651c8fba97SJames Feist { 366002d39b4SEd Tanous if (std::find(interfaces2.begin(), interfaces2.end(), 36723a21a1cSEd Tanous interface) != interfaces2.end()) 3681c8fba97SJames Feist { 3691c8fba97SJames Feist getIndicatorLedState(asyncResp); 3709f8bfa7cSGunnar Mills getLocationIndicatorActive(asyncResp); 3711c8fba97SJames Feist break; 3721c8fba97SJames Feist } 3731c8fba97SJames Feist } 3741c8fba97SJames Feist 37586d89ed7SKrzysztof Grobelny sdbusplus::asio::getAllProperties( 37686d89ed7SKrzysztof Grobelny *crow::connections::systemBus, connectionName, path, 37786d89ed7SKrzysztof Grobelny "xyz.openbmc_project.Inventory.Decorator.Asset", 37862d5e2e4SEd Tanous [asyncResp, chassisId(std::string(chassisId))]( 3795e7e2dc5SEd Tanous const boost::system::error_code& /*ec2*/, 380cf7eba09SNan Zhou const dbus::utility::DBusPropertiesMap& propertiesList) { 38186d89ed7SKrzysztof Grobelny const std::string* partNumber = nullptr; 38286d89ed7SKrzysztof Grobelny const std::string* serialNumber = nullptr; 38386d89ed7SKrzysztof Grobelny const std::string* manufacturer = nullptr; 38486d89ed7SKrzysztof Grobelny const std::string* model = nullptr; 38586d89ed7SKrzysztof Grobelny const std::string* sparePartNumber = nullptr; 38686d89ed7SKrzysztof Grobelny 38786d89ed7SKrzysztof Grobelny const bool success = sdbusplus::unpackPropertiesNoThrow( 38886d89ed7SKrzysztof Grobelny dbus_utils::UnpackErrorPrinter(), propertiesList, 38986d89ed7SKrzysztof Grobelny "PartNumber", partNumber, "SerialNumber", serialNumber, 39086d89ed7SKrzysztof Grobelny "Manufacturer", manufacturer, "Model", model, 39186d89ed7SKrzysztof Grobelny "SparePartNumber", sparePartNumber); 39286d89ed7SKrzysztof Grobelny 39386d89ed7SKrzysztof Grobelny if (!success) 3941abe55efSEd Tanous { 395002d39b4SEd Tanous messages::internalError(asyncResp->res); 396caa11f7aSAlpana Kumari return; 397daf36e2eSEd Tanous } 39886d89ed7SKrzysztof Grobelny 39986d89ed7SKrzysztof Grobelny if (partNumber != nullptr) 40086d89ed7SKrzysztof Grobelny { 40186d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["PartNumber"] = *partNumber; 40286d89ed7SKrzysztof Grobelny } 40386d89ed7SKrzysztof Grobelny 40486d89ed7SKrzysztof Grobelny if (serialNumber != nullptr) 40586d89ed7SKrzysztof Grobelny { 40686d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["SerialNumber"] = *serialNumber; 40786d89ed7SKrzysztof Grobelny } 40886d89ed7SKrzysztof Grobelny 40986d89ed7SKrzysztof Grobelny if (manufacturer != nullptr) 41086d89ed7SKrzysztof Grobelny { 41186d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["Manufacturer"] = *manufacturer; 41286d89ed7SKrzysztof Grobelny } 41386d89ed7SKrzysztof Grobelny 41486d89ed7SKrzysztof Grobelny if (model != nullptr) 41586d89ed7SKrzysztof Grobelny { 41686d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["Model"] = *model; 41786d89ed7SKrzysztof Grobelny } 41886d89ed7SKrzysztof Grobelny 419caa11f7aSAlpana Kumari // SparePartNumber is optional on D-Bus 420caa11f7aSAlpana Kumari // so skip if it is empty 42186d89ed7SKrzysztof Grobelny if (sparePartNumber != nullptr && !sparePartNumber->empty()) 422caa11f7aSAlpana Kumari { 42386d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["SparePartNumber"] = 42486d89ed7SKrzysztof Grobelny *sparePartNumber; 425caa11f7aSAlpana Kumari } 42686d89ed7SKrzysztof Grobelny 42762d5e2e4SEd Tanous asyncResp->res.jsonValue["Name"] = chassisId; 42862d5e2e4SEd Tanous asyncResp->res.jsonValue["Id"] = chassisId; 4290256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL 430002d39b4SEd Tanous asyncResp->res.jsonValue["Thermal"]["@odata.id"] = 431ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}/Thermal", 432ef4c65b7SEd Tanous chassisId); 4332474adfaSEd Tanous // Power object 4341476687dSEd Tanous asyncResp->res.jsonValue["Power"]["@odata.id"] = 435ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}/Power", 436ef4c65b7SEd Tanous chassisId); 4370256b694Szhanghch05 #endif 4382973963eSXiaochao Ma #ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM 4392973963eSXiaochao Ma asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] = 440ef4c65b7SEd Tanous boost::urls::format( 441ef4c65b7SEd Tanous "/redfish/v1/Chassis/{}/ThermalSubsystem", chassisId); 44277b36437SChicago Duan asyncResp->res.jsonValue["PowerSubsystem"]["@odata.id"] = 443ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}/PowerSubsystem", 444ef4c65b7SEd Tanous chassisId); 4454ca3ec3cSAlbert Zhang asyncResp->res.jsonValue["EnvironmentMetrics"]["@odata.id"] = 446ef4c65b7SEd Tanous boost::urls::format( 447ef4c65b7SEd Tanous "/redfish/v1/Chassis/{}/EnvironmentMetrics", chassisId); 4482973963eSXiaochao Ma #endif 44995a3ecadSAnthony Wilson // SensorCollection 450002d39b4SEd Tanous asyncResp->res.jsonValue["Sensors"]["@odata.id"] = 451ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Chassis/{}/Sensors", 452ef4c65b7SEd Tanous chassisId); 453002d39b4SEd Tanous asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; 4541476687dSEd Tanous 4551476687dSEd Tanous nlohmann::json::array_t computerSystems; 4561476687dSEd Tanous nlohmann::json::object_t system; 457002d39b4SEd Tanous system["@odata.id"] = "/redfish/v1/Systems/system"; 458ad539545SPatrick Williams computerSystems.emplace_back(std::move(system)); 459002d39b4SEd Tanous asyncResp->res.jsonValue["Links"]["ComputerSystems"] = 4601476687dSEd Tanous std::move(computerSystems); 4611476687dSEd Tanous 4621476687dSEd Tanous nlohmann::json::array_t managedBy; 4631476687dSEd Tanous nlohmann::json::object_t manager; 464002d39b4SEd Tanous manager["@odata.id"] = "/redfish/v1/Managers/bmc"; 465ad539545SPatrick Williams managedBy.emplace_back(std::move(manager)); 4667e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Links"]["ManagedBy"] = 4671476687dSEd Tanous std::move(managedBy); 468beeca0aeSGunnar Mills getChassisState(asyncResp); 46986d89ed7SKrzysztof Grobelny }); 4702c37b4b0SSharad Yadav 471308f70c7SWilly Tu for (const auto& interface : interfaces2) 4722c37b4b0SSharad Yadav { 473308f70c7SWilly Tu if (interface == "xyz.openbmc_project.Common.UUID") 4742c37b4b0SSharad Yadav { 475308f70c7SWilly Tu getChassisUUID(asyncResp, connectionName, path); 4762c37b4b0SSharad Yadav } 477cf7eba09SNan Zhou else if (interface == 4780fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.LocationCode") 4792c37b4b0SSharad Yadav { 480002d39b4SEd Tanous getChassisLocationCode(asyncResp, connectionName, path); 4812c37b4b0SSharad Yadav } 4822c37b4b0SSharad Yadav } 4832c37b4b0SSharad Yadav 484daf36e2eSEd Tanous return; 485daf36e2eSEd Tanous } 486e0d918bcSEd Tanous 487daf36e2eSEd Tanous // Couldn't find an object with that name. return an error 488d8a5d5d8SJiaqing Zhao messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); 489e99073f5SGeorge Liu }); 490c181942fSQiang XU 491c181942fSQiang XU getPhysicalSecurityData(asyncResp); 492cf7eba09SNan Zhou } 4931c8fba97SJames Feist 494cf7eba09SNan Zhou inline void 495cf7eba09SNan Zhou handleChassisPatch(App& app, const crow::Request& req, 4967e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 497cf7eba09SNan Zhou const std::string& param) 498cf7eba09SNan Zhou { 4993ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 50045ca1b86SEd Tanous { 50145ca1b86SEd Tanous return; 50245ca1b86SEd Tanous } 5039f8bfa7cSGunnar Mills std::optional<bool> locationIndicatorActive; 5041c8fba97SJames Feist std::optional<std::string> indicatorLed; 5051c8fba97SJames Feist 5067e860f15SJohn Edward Broadbent if (param.empty()) 5071c8fba97SJames Feist { 5081c8fba97SJames Feist return; 5091c8fba97SJames Feist } 5101c8fba97SJames Feist 51115ed6780SWilly Tu if (!json_util::readJsonPatch( 5127e860f15SJohn Edward Broadbent req, asyncResp->res, "LocationIndicatorActive", 5137e860f15SJohn Edward Broadbent locationIndicatorActive, "IndicatorLED", indicatorLed)) 5141c8fba97SJames Feist { 5151c8fba97SJames Feist return; 5161c8fba97SJames Feist } 5171c8fba97SJames Feist 5189f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed 5199f8bfa7cSGunnar Mills if (!locationIndicatorActive && !indicatorLed) 5201c8fba97SJames Feist { 5211c8fba97SJames Feist return; // delete this when we support more patch properties 5221c8fba97SJames Feist } 523d6aa0093SGunnar Mills if (indicatorLed) 524d6aa0093SGunnar Mills { 5257e860f15SJohn Edward Broadbent asyncResp->res.addHeader( 5267e860f15SJohn Edward Broadbent boost::beast::http::field::warning, 5270fda0f12SGeorge Liu "299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\""); 528d6aa0093SGunnar Mills } 5291c8fba97SJames Feist 530e99073f5SGeorge Liu constexpr std::array<std::string_view, 2> interfaces = { 5311c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Board", 5321c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Chassis"}; 5331c8fba97SJames Feist 5347e860f15SJohn Edward Broadbent const std::string& chassisId = param; 5351c8fba97SJames Feist 536e99073f5SGeorge Liu dbus::utility::getSubTree( 537e99073f5SGeorge Liu "/xyz/openbmc_project/inventory", 0, interfaces, 538cf7eba09SNan Zhou [asyncResp, chassisId, locationIndicatorActive, 5395e7e2dc5SEd Tanous indicatorLed](const boost::system::error_code& ec, 540b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 5411c8fba97SJames Feist if (ec) 5421c8fba97SJames Feist { 5431c8fba97SJames Feist messages::internalError(asyncResp->res); 5441c8fba97SJames Feist return; 5451c8fba97SJames Feist } 5461c8fba97SJames Feist 5471c8fba97SJames Feist // Iterate over all retrieved ObjectPaths. 548cf7eba09SNan Zhou for (const std::pair< 549cf7eba09SNan Zhou std::string, 550cf7eba09SNan Zhou std::vector<std::pair<std::string, std::vector<std::string>>>>& 5511214b7e7SGunnar Mills object : subtree) 5521c8fba97SJames Feist { 5531c8fba97SJames Feist const std::string& path = object.first; 554cf7eba09SNan Zhou const std::vector<std::pair<std::string, std::vector<std::string>>>& 5551214b7e7SGunnar Mills connectionNames = object.second; 5561c8fba97SJames Feist 557997093ebSGeorge Liu sdbusplus::message::object_path objPath(path); 558997093ebSGeorge Liu if (objPath.filename() != chassisId) 5591c8fba97SJames Feist { 5601c8fba97SJames Feist continue; 5611c8fba97SJames Feist } 5621c8fba97SJames Feist 56326f6976fSEd Tanous if (connectionNames.empty()) 5641c8fba97SJames Feist { 5651c8fba97SJames Feist BMCWEB_LOG_ERROR << "Got 0 Connection names"; 5661c8fba97SJames Feist continue; 5671c8fba97SJames Feist } 5681c8fba97SJames Feist 56923a21a1cSEd Tanous const std::vector<std::string>& interfaces3 = 5701c8fba97SJames Feist connectionNames[0].second; 5711c8fba97SJames Feist 5721c8fba97SJames Feist const std::array<const char*, 2> hasIndicatorLed = { 5731c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Panel", 5740fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board.Motherboard"}; 5751c8fba97SJames Feist bool indicatorChassis = false; 5761c8fba97SJames Feist for (const char* interface : hasIndicatorLed) 5771c8fba97SJames Feist { 578002d39b4SEd Tanous if (std::find(interfaces3.begin(), interfaces3.end(), 57923a21a1cSEd Tanous interface) != interfaces3.end()) 5801c8fba97SJames Feist { 5811c8fba97SJames Feist indicatorChassis = true; 5821c8fba97SJames Feist break; 5831c8fba97SJames Feist } 5841c8fba97SJames Feist } 5859f8bfa7cSGunnar Mills if (locationIndicatorActive) 5869f8bfa7cSGunnar Mills { 5879f8bfa7cSGunnar Mills if (indicatorChassis) 5889f8bfa7cSGunnar Mills { 589002d39b4SEd Tanous setLocationIndicatorActive(asyncResp, 590002d39b4SEd Tanous *locationIndicatorActive); 5919f8bfa7cSGunnar Mills } 5929f8bfa7cSGunnar Mills else 5939f8bfa7cSGunnar Mills { 594002d39b4SEd Tanous messages::propertyUnknown(asyncResp->res, 595002d39b4SEd Tanous "LocationIndicatorActive"); 5969f8bfa7cSGunnar Mills } 5979f8bfa7cSGunnar Mills } 5989f8bfa7cSGunnar Mills if (indicatorLed) 5999f8bfa7cSGunnar Mills { 6001c8fba97SJames Feist if (indicatorChassis) 6011c8fba97SJames Feist { 602f23b7296SEd Tanous setIndicatorLedState(asyncResp, *indicatorLed); 6031c8fba97SJames Feist } 6041c8fba97SJames Feist else 6051c8fba97SJames Feist { 606cf7eba09SNan Zhou messages::propertyUnknown(asyncResp->res, "IndicatorLED"); 6071c8fba97SJames Feist } 6081c8fba97SJames Feist } 6091c8fba97SJames Feist return; 6101c8fba97SJames Feist } 6111c8fba97SJames Feist 612d8a5d5d8SJiaqing Zhao messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); 613e99073f5SGeorge Liu }); 614cf7eba09SNan Zhou } 615cf7eba09SNan Zhou 616cf7eba09SNan Zhou /** 617cf7eba09SNan Zhou * Chassis override class for delivering Chassis Schema 618cf7eba09SNan Zhou * Functions triggers appropriate requests on DBus 619cf7eba09SNan Zhou */ 620cf7eba09SNan Zhou inline void requestRoutesChassis(App& app) 621cf7eba09SNan Zhou { 622cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/") 623cf7eba09SNan Zhou .privileges(redfish::privileges::getChassis) 624cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 625cf7eba09SNan Zhou std::bind_front(handleChassisGet, std::ref(app))); 626cf7eba09SNan Zhou 627cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/") 628cf7eba09SNan Zhou .privileges(redfish::privileges::patchChassis) 629cf7eba09SNan Zhou .methods(boost::beast::http::verb::patch)( 630cf7eba09SNan Zhou std::bind_front(handleChassisPatch, std::ref(app))); 6311c8fba97SJames Feist } 632dd99e04bSP.K. Lee 6338d1b46d7Szhanghch05 inline void 6348d1b46d7Szhanghch05 doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 635dd99e04bSP.K. Lee { 6367a1dbc48SGeorge Liu constexpr std::array<std::string_view, 1> interfaces = { 637c3b3c92aSVijay Khemka "xyz.openbmc_project.State.Chassis"}; 638c3b3c92aSVijay Khemka 639c3b3c92aSVijay Khemka // Use mapper to get subtree paths. 6407a1dbc48SGeorge Liu dbus::utility::getSubTreePaths( 6417a1dbc48SGeorge Liu "/", 0, interfaces, 642b9d36b47SEd Tanous [asyncResp]( 6437a1dbc48SGeorge Liu const boost::system::error_code& ec, 644b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreePathsResponse& chassisList) { 645c3b3c92aSVijay Khemka if (ec) 646c3b3c92aSVijay Khemka { 647c3b3c92aSVijay Khemka BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec; 648c3b3c92aSVijay Khemka messages::internalError(asyncResp->res); 649c3b3c92aSVijay Khemka return; 650c3b3c92aSVijay Khemka } 651c3b3c92aSVijay Khemka 652dd99e04bSP.K. Lee const char* processName = "xyz.openbmc_project.State.Chassis"; 653dd99e04bSP.K. Lee const char* interfaceName = "xyz.openbmc_project.State.Chassis"; 654dd99e04bSP.K. Lee const char* destProperty = "RequestedPowerTransition"; 655dd99e04bSP.K. Lee const std::string propertyValue = 656dd99e04bSP.K. Lee "xyz.openbmc_project.State.Chassis.Transition.PowerCycle"; 657002d39b4SEd Tanous std::string objectPath = "/xyz/openbmc_project/state/chassis_system0"; 658c3b3c92aSVijay Khemka 659c3b3c92aSVijay Khemka /* Look for system reset chassis path */ 660002d39b4SEd Tanous if ((std::find(chassisList.begin(), chassisList.end(), objectPath)) == 661002d39b4SEd Tanous chassisList.end()) 662c3b3c92aSVijay Khemka { 663c3b3c92aSVijay Khemka /* We prefer to reset the full chassis_system, but if it doesn't 664c3b3c92aSVijay Khemka * exist on some platforms, fall back to a host-only power reset 665c3b3c92aSVijay Khemka */ 666c3b3c92aSVijay Khemka objectPath = "/xyz/openbmc_project/state/chassis0"; 667c3b3c92aSVijay Khemka } 668dd99e04bSP.K. Lee 669dd99e04bSP.K. Lee crow::connections::systemBus->async_method_call( 6705e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec2) { 671dd99e04bSP.K. Lee // Use "Set" method to set the property value. 6728a592810SEd Tanous if (ec2) 673dd99e04bSP.K. Lee { 6748a592810SEd Tanous BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec2; 675dd99e04bSP.K. Lee messages::internalError(asyncResp->res); 676dd99e04bSP.K. Lee return; 677dd99e04bSP.K. Lee } 678dd99e04bSP.K. Lee 679dd99e04bSP.K. Lee messages::success(asyncResp->res); 680dd99e04bSP.K. Lee }, 681002d39b4SEd Tanous processName, objectPath, "org.freedesktop.DBus.Properties", "Set", 682002d39b4SEd Tanous interfaceName, destProperty, 683168e20c1SEd Tanous dbus::utility::DbusVariantType{propertyValue}); 6847a1dbc48SGeorge Liu }); 685dd99e04bSP.K. Lee } 686dd99e04bSP.K. Lee 687cf7eba09SNan Zhou inline void handleChassisResetActionInfoPost( 688cf7eba09SNan Zhou App& app, const crow::Request& req, 6897e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 690cf7eba09SNan Zhou const std::string& /*chassisId*/) 691cf7eba09SNan Zhou { 6923ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 69345ca1b86SEd Tanous { 69445ca1b86SEd Tanous return; 69545ca1b86SEd Tanous } 696dd99e04bSP.K. Lee BMCWEB_LOG_DEBUG << "Post Chassis Reset."; 697dd99e04bSP.K. Lee 698dd99e04bSP.K. Lee std::string resetType; 699dd99e04bSP.K. Lee 700cf7eba09SNan Zhou if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType)) 701dd99e04bSP.K. Lee { 702dd99e04bSP.K. Lee return; 703dd99e04bSP.K. Lee } 704dd99e04bSP.K. Lee 705dd99e04bSP.K. Lee if (resetType != "PowerCycle") 706dd99e04bSP.K. Lee { 707dd99e04bSP.K. Lee BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: " 708dd99e04bSP.K. Lee << resetType; 709002d39b4SEd Tanous messages::actionParameterNotSupported(asyncResp->res, resetType, 710002d39b4SEd Tanous "ResetType"); 711dd99e04bSP.K. Lee 712dd99e04bSP.K. Lee return; 713dd99e04bSP.K. Lee } 714dd99e04bSP.K. Lee doChassisPowerCycle(asyncResp); 715dd99e04bSP.K. Lee } 7161cb1a9e6SAppaRao Puli 7171cb1a9e6SAppaRao Puli /** 718cf7eba09SNan Zhou * ChassisResetAction class supports the POST method for the Reset 719cf7eba09SNan Zhou * action. 720cf7eba09SNan Zhou * Function handles POST method request. 721cf7eba09SNan Zhou * Analyzes POST body before sending Reset request data to D-Bus. 7221cb1a9e6SAppaRao Puli */ 723cf7eba09SNan Zhou 724cf7eba09SNan Zhou inline void requestRoutesChassisResetAction(App& app) 7251cb1a9e6SAppaRao Puli { 726cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/") 727cf7eba09SNan Zhou .privileges(redfish::privileges::postChassis) 728cf7eba09SNan Zhou .methods(boost::beast::http::verb::post)( 729cf7eba09SNan Zhou std::bind_front(handleChassisResetActionInfoPost, std::ref(app))); 730cf7eba09SNan Zhou } 731cf7eba09SNan Zhou 732cf7eba09SNan Zhou inline void handleChassisResetActionInfoGet( 733cf7eba09SNan Zhou App& app, const crow::Request& req, 7347e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 735cf7eba09SNan Zhou const std::string& chassisId) 736cf7eba09SNan Zhou { 7373ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 7381cb1a9e6SAppaRao Puli { 73945ca1b86SEd Tanous return; 74045ca1b86SEd Tanous } 741cf7eba09SNan Zhou asyncResp->res.jsonValue["@odata.type"] = "#ActionInfo.v1_1_2.ActionInfo"; 742ef4c65b7SEd Tanous asyncResp->res.jsonValue["@odata.id"] = boost::urls::format( 743ef4c65b7SEd Tanous "/redfish/v1/Chassis/{}/ResetActionInfo", chassisId); 7441476687dSEd Tanous asyncResp->res.jsonValue["Name"] = "Reset Action Info"; 7451476687dSEd Tanous 7461476687dSEd Tanous asyncResp->res.jsonValue["Id"] = "ResetActionInfo"; 7475b9e95a1SNan Zhou nlohmann::json::array_t parameters; 7485b9e95a1SNan Zhou nlohmann::json::object_t parameter; 7495b9e95a1SNan Zhou parameter["Name"] = "ResetType"; 7505b9e95a1SNan Zhou parameter["Required"] = true; 7515b9e95a1SNan Zhou parameter["DataType"] = "String"; 7521476687dSEd Tanous nlohmann::json::array_t allowed; 753ad539545SPatrick Williams allowed.emplace_back("PowerCycle"); 7545b9e95a1SNan Zhou parameter["AllowableValues"] = std::move(allowed); 755ad539545SPatrick Williams parameters.emplace_back(std::move(parameter)); 7565b9e95a1SNan Zhou 7571476687dSEd Tanous asyncResp->res.jsonValue["Parameters"] = std::move(parameters); 758cf7eba09SNan Zhou } 759cf7eba09SNan Zhou 760cf7eba09SNan Zhou /** 761cf7eba09SNan Zhou * ChassisResetActionInfo derived class for delivering Chassis 762cf7eba09SNan Zhou * ResetType AllowableValues using ResetInfo schema. 763cf7eba09SNan Zhou */ 764cf7eba09SNan Zhou inline void requestRoutesChassisResetActionInfo(App& app) 765cf7eba09SNan Zhou { 766cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/") 767cf7eba09SNan Zhou .privileges(redfish::privileges::getActionInfo) 768cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 769cf7eba09SNan Zhou std::bind_front(handleChassisResetActionInfoGet, std::ref(app))); 7701cb1a9e6SAppaRao Puli } 7711cb1a9e6SAppaRao Puli 772e37f8451SRapkiewicz, Pawel } // namespace redfish 773