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 183ccb3adbSEd Tanous #include "app.hpp" 197a1dbc48SGeorge Liu #include "dbus_utility.hpp" 20b49ac873SJames Feist #include "health.hpp" 211c8fba97SJames Feist #include "led.hpp" 223ccb3adbSEd Tanous #include "query.hpp" 233ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 243ccb3adbSEd Tanous #include "utils/collection.hpp" 253ccb3adbSEd Tanous #include "utils/dbus_utils.hpp" 26cf7eba09SNan Zhou #include "utils/json_utils.hpp" 271abe55efSEd Tanous 28e99073f5SGeorge Liu #include <boost/system/error_code.hpp> 291e1e598dSJonathan Doman #include <sdbusplus/asio/property.hpp> 3086d89ed7SKrzysztof Grobelny #include <sdbusplus/unpack_properties.hpp> 311214b7e7SGunnar Mills 327a1dbc48SGeorge Liu #include <array> 337a1dbc48SGeorge Liu #include <string_view> 347a1dbc48SGeorge Liu 351abe55efSEd Tanous namespace redfish 361abe55efSEd Tanous { 37e37f8451SRapkiewicz, Pawel 38e37f8451SRapkiewicz, Pawel /** 39beeca0aeSGunnar Mills * @brief Retrieves chassis state properties over dbus 40beeca0aeSGunnar Mills * 41beeca0aeSGunnar Mills * @param[in] aResp - Shared pointer for completing asynchronous calls. 42beeca0aeSGunnar Mills * 43beeca0aeSGunnar Mills * @return None. 44beeca0aeSGunnar Mills */ 458d1b46d7Szhanghch05 inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> aResp) 46beeca0aeSGunnar Mills { 471e1e598dSJonathan Doman // crow::connections::systemBus->async_method_call( 481e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 491e1e598dSJonathan Doman *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis", 501e1e598dSJonathan Doman "/xyz/openbmc_project/state/chassis0", 511e1e598dSJonathan Doman "xyz.openbmc_project.State.Chassis", "CurrentPowerState", 525e7e2dc5SEd Tanous [aResp{std::move(aResp)}](const boost::system::error_code& ec, 531e1e598dSJonathan Doman const std::string& chassisState) { 54beeca0aeSGunnar Mills if (ec) 55beeca0aeSGunnar Mills { 56a6e5e0abSCarson Labrado if (ec == boost::system::errc::host_unreachable) 57a6e5e0abSCarson Labrado { 58a6e5e0abSCarson Labrado // Service not available, no error, just don't return 59a6e5e0abSCarson Labrado // chassis state info 60a6e5e0abSCarson Labrado BMCWEB_LOG_DEBUG << "Service not available " << ec; 61a6e5e0abSCarson Labrado return; 62a6e5e0abSCarson Labrado } 63beeca0aeSGunnar Mills BMCWEB_LOG_DEBUG << "DBUS response error " << ec; 64beeca0aeSGunnar Mills messages::internalError(aResp->res); 65beeca0aeSGunnar Mills return; 66beeca0aeSGunnar Mills } 67beeca0aeSGunnar Mills 681e1e598dSJonathan Doman BMCWEB_LOG_DEBUG << "Chassis state: " << chassisState; 69beeca0aeSGunnar Mills // Verify Chassis State 70002d39b4SEd Tanous if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On") 71beeca0aeSGunnar Mills { 72beeca0aeSGunnar Mills aResp->res.jsonValue["PowerState"] = "On"; 73beeca0aeSGunnar Mills aResp->res.jsonValue["Status"]["State"] = "Enabled"; 74beeca0aeSGunnar Mills } 751e1e598dSJonathan Doman else if (chassisState == 76beeca0aeSGunnar Mills "xyz.openbmc_project.State.Chassis.PowerState.Off") 77beeca0aeSGunnar Mills { 78beeca0aeSGunnar Mills aResp->res.jsonValue["PowerState"] = "Off"; 79beeca0aeSGunnar Mills aResp->res.jsonValue["Status"]["State"] = "StandbyOffline"; 80beeca0aeSGunnar Mills } 811e1e598dSJonathan Doman }); 82beeca0aeSGunnar Mills } 83beeca0aeSGunnar Mills 848d1b46d7Szhanghch05 inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> aResp, 85c181942fSQiang XU const std::string& service, 86c181942fSQiang XU const std::string& objPath) 87c181942fSQiang XU { 88c181942fSQiang XU BMCWEB_LOG_DEBUG << "Get intrusion status by service \n"; 89c181942fSQiang XU 901e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 911e1e598dSJonathan Doman *crow::connections::systemBus, service, objPath, 921e1e598dSJonathan Doman "xyz.openbmc_project.Chassis.Intrusion", "Status", 935e7e2dc5SEd Tanous [aResp{std::move(aResp)}](const boost::system::error_code& ec, 941e1e598dSJonathan Doman const std::string& value) { 95c181942fSQiang XU if (ec) 96c181942fSQiang XU { 974e0453b1SGunnar Mills // do not add err msg in redfish response, because this is not 98c181942fSQiang XU // mandatory property 99c181942fSQiang XU BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n"; 100c181942fSQiang XU return; 101c181942fSQiang XU } 102c181942fSQiang XU 103002d39b4SEd Tanous aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] = 1; 1041476687dSEd Tanous aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value; 1051e1e598dSJonathan Doman }); 106c181942fSQiang XU } 107c181942fSQiang XU 108c181942fSQiang XU /** 109c181942fSQiang XU * Retrieves physical security properties over dbus 110c181942fSQiang XU */ 1118d1b46d7Szhanghch05 inline void getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> aResp) 112c181942fSQiang XU { 113e99073f5SGeorge Liu constexpr std::array<std::string_view, 1> interfaces = { 114e99073f5SGeorge Liu "xyz.openbmc_project.Chassis.Intrusion"}; 115e99073f5SGeorge Liu dbus::utility::getSubTree( 116e99073f5SGeorge Liu "/xyz/openbmc_project/Intrusion", 1, interfaces, 117c181942fSQiang XU [aResp{std::move(aResp)}]( 118e99073f5SGeorge Liu const boost::system::error_code& ec, 119b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 120c181942fSQiang XU if (ec) 121c181942fSQiang XU { 1224e0453b1SGunnar Mills // do not add err msg in redfish response, because this is not 123c181942fSQiang XU // mandatory property 124002d39b4SEd Tanous BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec << "\n"; 125c181942fSQiang XU return; 126c181942fSQiang XU } 127c181942fSQiang XU // Iterate over all retrieved ObjectPaths. 128c181942fSQiang XU for (const auto& object : subtree) 129c181942fSQiang XU { 130*840a9ffcSPatrick Williams if (!object.second.empty()) 131c181942fSQiang XU { 132*840a9ffcSPatrick Williams const auto service = object.second.front(); 133c181942fSQiang XU getIntrusionByService(aResp, service.first, object.first); 134c181942fSQiang XU return; 135c181942fSQiang XU } 136c181942fSQiang XU } 137e99073f5SGeorge Liu }); 138c181942fSQiang XU } 139c181942fSQiang XU 140cf7eba09SNan Zhou inline void handleChassisCollectionGet( 141cf7eba09SNan Zhou App& app, const crow::Request& req, 142cf7eba09SNan Zhou const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1431abe55efSEd Tanous { 1443ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 14545ca1b86SEd Tanous { 14645ca1b86SEd Tanous return; 14745ca1b86SEd Tanous } 1488d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 1498d1b46d7Szhanghch05 "#ChassisCollection.ChassisCollection"; 1508d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis"; 1518d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Chassis Collection"; 152e37f8451SRapkiewicz, Pawel 1537a1dbc48SGeorge Liu constexpr std::array<std::string_view, 2> interfaces{ 1547a1dbc48SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board", 1557a1dbc48SGeorge Liu "xyz.openbmc_project.Inventory.Item.Chassis"}; 15602f6ff19SGunnar Mills collection_util::getCollectionMembers( 1577a1dbc48SGeorge Liu asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces); 158cf7eba09SNan Zhou } 159cf7eba09SNan Zhou 160cf7eba09SNan Zhou /** 161cf7eba09SNan Zhou * ChassisCollection derived class for delivering Chassis Collection Schema 162cf7eba09SNan Zhou * Functions triggers appropriate requests on DBus 163cf7eba09SNan Zhou */ 164cf7eba09SNan Zhou inline void requestRoutesChassisCollection(App& app) 165cf7eba09SNan Zhou { 166cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/") 167cf7eba09SNan Zhou .privileges(redfish::privileges::getChassisCollection) 168cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 169cf7eba09SNan Zhou std::bind_front(handleChassisCollectionGet, std::ref(app))); 17062d5e2e4SEd Tanous } 171e37f8451SRapkiewicz, Pawel 172308f70c7SWilly Tu inline void 173308f70c7SWilly Tu getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 174308f70c7SWilly Tu const std::string& connectionName, 175308f70c7SWilly Tu const std::string& path) 176308f70c7SWilly Tu { 1771e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 1781e1e598dSJonathan Doman *crow::connections::systemBus, connectionName, path, 1791e1e598dSJonathan Doman "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", 1805e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec, 1811e1e598dSJonathan Doman const std::string& property) { 182308f70c7SWilly Tu if (ec) 183308f70c7SWilly Tu { 1840fda0f12SGeorge Liu BMCWEB_LOG_DEBUG << "DBUS response error for Location"; 185308f70c7SWilly Tu messages::internalError(asyncResp->res); 186308f70c7SWilly Tu return; 187308f70c7SWilly Tu } 188308f70c7SWilly Tu 189002d39b4SEd Tanous asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = 1901e1e598dSJonathan Doman property; 1911e1e598dSJonathan Doman }); 192308f70c7SWilly Tu } 193308f70c7SWilly Tu 194308f70c7SWilly Tu inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 195308f70c7SWilly Tu const std::string& connectionName, 196308f70c7SWilly Tu const std::string& path) 197308f70c7SWilly Tu { 1981e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 1991e1e598dSJonathan Doman *crow::connections::systemBus, connectionName, path, 2001e1e598dSJonathan Doman "xyz.openbmc_project.Common.UUID", "UUID", 2015e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec, 2021e1e598dSJonathan Doman const std::string& chassisUUID) { 203308f70c7SWilly Tu if (ec) 204308f70c7SWilly Tu { 2050fda0f12SGeorge Liu BMCWEB_LOG_DEBUG << "DBUS response error for UUID"; 206308f70c7SWilly Tu messages::internalError(asyncResp->res); 207308f70c7SWilly Tu return; 208308f70c7SWilly Tu } 2091e1e598dSJonathan Doman asyncResp->res.jsonValue["UUID"] = chassisUUID; 2101e1e598dSJonathan Doman }); 211308f70c7SWilly Tu } 212308f70c7SWilly Tu 213cf7eba09SNan Zhou inline void 214cf7eba09SNan Zhou handleChassisGet(App& app, const crow::Request& req, 21545ca1b86SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 216cf7eba09SNan Zhou const std::string& chassisId) 217cf7eba09SNan Zhou { 2183ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 21945ca1b86SEd Tanous { 22045ca1b86SEd Tanous return; 22145ca1b86SEd Tanous } 222e99073f5SGeorge Liu constexpr std::array<std::string_view, 2> interfaces = { 223734bfe90SGunnar Mills "xyz.openbmc_project.Inventory.Item.Board", 224adc4f0dbSShawn McCarney "xyz.openbmc_project.Inventory.Item.Chassis"}; 225734bfe90SGunnar Mills 226e99073f5SGeorge Liu dbus::utility::getSubTree( 227e99073f5SGeorge Liu "/xyz/openbmc_project/inventory", 0, interfaces, 22862d5e2e4SEd Tanous [asyncResp, chassisId(std::string(chassisId))]( 229e99073f5SGeorge Liu const boost::system::error_code& ec, 230b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 23162d5e2e4SEd Tanous if (ec) 2321abe55efSEd Tanous { 233f12894f8SJason M. Bills messages::internalError(asyncResp->res); 234daf36e2eSEd Tanous return; 235daf36e2eSEd Tanous } 236daf36e2eSEd Tanous // Iterate over all retrieved ObjectPaths. 237cf7eba09SNan Zhou for (const std::pair< 238cf7eba09SNan Zhou std::string, 239cf7eba09SNan Zhou std::vector<std::pair<std::string, std::vector<std::string>>>>& 2401214b7e7SGunnar Mills object : subtree) 2411abe55efSEd Tanous { 242daf36e2eSEd Tanous const std::string& path = object.first; 243cf7eba09SNan Zhou const std::vector<std::pair<std::string, std::vector<std::string>>>& 2441214b7e7SGunnar Mills connectionNames = object.second; 2457e860f15SJohn Edward Broadbent 246997093ebSGeorge Liu sdbusplus::message::object_path objPath(path); 247997093ebSGeorge Liu if (objPath.filename() != chassisId) 2481abe55efSEd Tanous { 249daf36e2eSEd Tanous continue; 250daf36e2eSEd Tanous } 25126f03899SShawn McCarney 252002d39b4SEd Tanous auto health = std::make_shared<HealthPopulate>(asyncResp); 253b49ac873SJames Feist 2546c3e9451SGeorge Liu dbus::utility::getAssociationEndPoints( 2556c3e9451SGeorge Liu path + "/all_sensors", 2565e7e2dc5SEd Tanous [health](const boost::system::error_code& ec2, 2576c3e9451SGeorge Liu const dbus::utility::MapperEndPoints& resp) { 25823a21a1cSEd Tanous if (ec2) 259b49ac873SJames Feist { 260b49ac873SJames Feist return; // no sensors = no failures 261b49ac873SJames Feist } 2621e1e598dSJonathan Doman health->inventory = resp; 2631e1e598dSJonathan Doman }); 264b49ac873SJames Feist 265b49ac873SJames Feist health->populate(); 266b49ac873SJames Feist 26726f6976fSEd Tanous if (connectionNames.empty()) 2681abe55efSEd Tanous { 2691c8fba97SJames Feist BMCWEB_LOG_ERROR << "Got 0 Connection names"; 270e0d918bcSEd Tanous continue; 271daf36e2eSEd Tanous } 272e0d918bcSEd Tanous 27349c53ac9SJohnathan Mantey asyncResp->res.jsonValue["@odata.type"] = 274523d4868SLogananth Sundararaj "#Chassis.v1_22_0.Chassis"; 27549c53ac9SJohnathan Mantey asyncResp->res.jsonValue["@odata.id"] = 276eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 277eddfc437SWilly Tu chassisId); 27849c53ac9SJohnathan Mantey asyncResp->res.jsonValue["Name"] = "Chassis Collection"; 27949c53ac9SJohnathan Mantey asyncResp->res.jsonValue["ChassisType"] = "RackMount"; 280cf7eba09SNan Zhou asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"]["target"] = 281eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 282eddfc437SWilly Tu chassisId, "Actions", 283eddfc437SWilly Tu "Chassis.Reset"); 2841476687dSEd Tanous asyncResp->res 285cf7eba09SNan Zhou .jsonValue["Actions"]["#Chassis.Reset"]["@Redfish.ActionInfo"] = 286eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 287eddfc437SWilly Tu chassisId, "ResetActionInfo"); 2881476687dSEd Tanous asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] = 289eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Systems", 290eddfc437SWilly Tu "system", "PCIeDevices"); 29149c53ac9SJohnathan Mantey 2926c3e9451SGeorge Liu dbus::utility::getAssociationEndPoints( 2936c3e9451SGeorge Liu path + "/drive", 2946c3e9451SGeorge Liu [asyncResp, 2956c3e9451SGeorge Liu chassisId](const boost::system::error_code& ec3, 2966c3e9451SGeorge Liu const dbus::utility::MapperEndPoints& resp) { 29792903bd4SJohn Edward Broadbent if (ec3 || resp.empty()) 29892903bd4SJohn Edward Broadbent { 29992903bd4SJohn Edward Broadbent return; // no drives = no failures 30092903bd4SJohn Edward Broadbent } 30192903bd4SJohn Edward Broadbent 30292903bd4SJohn Edward Broadbent nlohmann::json reference; 303a0cb40cbSJohn Edward Broadbent reference["@odata.id"] = crow::utility::urlFromPieces( 30492903bd4SJohn Edward Broadbent "redfish", "v1", "Chassis", chassisId, "Drives"); 30592903bd4SJohn Edward Broadbent asyncResp->res.jsonValue["Drives"] = std::move(reference); 30692903bd4SJohn Edward Broadbent }); 30792903bd4SJohn Edward Broadbent 308002d39b4SEd Tanous const std::string& connectionName = connectionNames[0].first; 3091c8fba97SJames Feist 31023a21a1cSEd Tanous const std::vector<std::string>& interfaces2 = 3111c8fba97SJames Feist connectionNames[0].second; 3121c8fba97SJames Feist const std::array<const char*, 2> hasIndicatorLed = { 3131c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Panel", 3140fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board.Motherboard"}; 3151c8fba97SJames Feist 316476b9cc5STejas Patil const std::string assetTagInterface = 3170fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.AssetTag"; 318523d4868SLogananth Sundararaj const std::string replaceableInterface = 319523d4868SLogananth Sundararaj "xyz.openbmc_project.Inventory.Decorator.Replaceable"; 320523d4868SLogananth Sundararaj for (const auto& interface : interfaces2) 321523d4868SLogananth Sundararaj { 322523d4868SLogananth Sundararaj if (interface == assetTagInterface) 323476b9cc5STejas Patil { 3241e1e598dSJonathan Doman sdbusplus::asio::getProperty<std::string>( 325002d39b4SEd Tanous *crow::connections::systemBus, connectionName, path, 326002d39b4SEd Tanous assetTagInterface, "AssetTag", 327523d4868SLogananth Sundararaj [asyncResp, 328523d4868SLogananth Sundararaj chassisId](const boost::system::error_code& ec2, 3291e1e598dSJonathan Doman const std::string& property) { 3308a592810SEd Tanous if (ec2) 331476b9cc5STejas Patil { 332523d4868SLogananth Sundararaj BMCWEB_LOG_ERROR 333523d4868SLogananth Sundararaj << "DBus response error for AssetTag: " << ec2; 334476b9cc5STejas Patil messages::internalError(asyncResp->res); 335476b9cc5STejas Patil return; 336476b9cc5STejas Patil } 337002d39b4SEd Tanous asyncResp->res.jsonValue["AssetTag"] = property; 3381e1e598dSJonathan Doman }); 339476b9cc5STejas Patil } 340523d4868SLogananth Sundararaj else if (interface == replaceableInterface) 341523d4868SLogananth Sundararaj { 342523d4868SLogananth Sundararaj sdbusplus::asio::getProperty<bool>( 343523d4868SLogananth Sundararaj *crow::connections::systemBus, connectionName, path, 344523d4868SLogananth Sundararaj replaceableInterface, "HotPluggable", 345523d4868SLogananth Sundararaj [asyncResp, 346523d4868SLogananth Sundararaj chassisId](const boost::system::error_code& ec2, 347523d4868SLogananth Sundararaj const bool property) { 348523d4868SLogananth Sundararaj if (ec2) 349523d4868SLogananth Sundararaj { 350523d4868SLogananth Sundararaj BMCWEB_LOG_ERROR 351523d4868SLogananth Sundararaj << "DBus response error for HotPluggable: " 352523d4868SLogananth Sundararaj << ec2; 353523d4868SLogananth Sundararaj messages::internalError(asyncResp->res); 354523d4868SLogananth Sundararaj return; 355523d4868SLogananth Sundararaj } 356523d4868SLogananth Sundararaj asyncResp->res.jsonValue["HotPluggable"] = property; 357523d4868SLogananth Sundararaj }); 358523d4868SLogananth Sundararaj } 359523d4868SLogananth Sundararaj } 360476b9cc5STejas Patil 3611c8fba97SJames Feist for (const char* interface : hasIndicatorLed) 3621c8fba97SJames Feist { 363002d39b4SEd Tanous if (std::find(interfaces2.begin(), interfaces2.end(), 36423a21a1cSEd Tanous interface) != interfaces2.end()) 3651c8fba97SJames Feist { 3661c8fba97SJames Feist getIndicatorLedState(asyncResp); 3679f8bfa7cSGunnar Mills getLocationIndicatorActive(asyncResp); 3681c8fba97SJames Feist break; 3691c8fba97SJames Feist } 3701c8fba97SJames Feist } 3711c8fba97SJames Feist 37286d89ed7SKrzysztof Grobelny sdbusplus::asio::getAllProperties( 37386d89ed7SKrzysztof Grobelny *crow::connections::systemBus, connectionName, path, 37486d89ed7SKrzysztof Grobelny "xyz.openbmc_project.Inventory.Decorator.Asset", 37562d5e2e4SEd Tanous [asyncResp, chassisId(std::string(chassisId))]( 3765e7e2dc5SEd Tanous const boost::system::error_code& /*ec2*/, 377cf7eba09SNan Zhou const dbus::utility::DBusPropertiesMap& propertiesList) { 37886d89ed7SKrzysztof Grobelny const std::string* partNumber = nullptr; 37986d89ed7SKrzysztof Grobelny const std::string* serialNumber = nullptr; 38086d89ed7SKrzysztof Grobelny const std::string* manufacturer = nullptr; 38186d89ed7SKrzysztof Grobelny const std::string* model = nullptr; 38286d89ed7SKrzysztof Grobelny const std::string* sparePartNumber = nullptr; 38386d89ed7SKrzysztof Grobelny 38486d89ed7SKrzysztof Grobelny const bool success = sdbusplus::unpackPropertiesNoThrow( 38586d89ed7SKrzysztof Grobelny dbus_utils::UnpackErrorPrinter(), propertiesList, 38686d89ed7SKrzysztof Grobelny "PartNumber", partNumber, "SerialNumber", serialNumber, 38786d89ed7SKrzysztof Grobelny "Manufacturer", manufacturer, "Model", model, 38886d89ed7SKrzysztof Grobelny "SparePartNumber", sparePartNumber); 38986d89ed7SKrzysztof Grobelny 39086d89ed7SKrzysztof Grobelny if (!success) 3911abe55efSEd Tanous { 392002d39b4SEd Tanous messages::internalError(asyncResp->res); 393caa11f7aSAlpana Kumari return; 394daf36e2eSEd Tanous } 39586d89ed7SKrzysztof Grobelny 39686d89ed7SKrzysztof Grobelny if (partNumber != nullptr) 39786d89ed7SKrzysztof Grobelny { 39886d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["PartNumber"] = *partNumber; 39986d89ed7SKrzysztof Grobelny } 40086d89ed7SKrzysztof Grobelny 40186d89ed7SKrzysztof Grobelny if (serialNumber != nullptr) 40286d89ed7SKrzysztof Grobelny { 40386d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["SerialNumber"] = *serialNumber; 40486d89ed7SKrzysztof Grobelny } 40586d89ed7SKrzysztof Grobelny 40686d89ed7SKrzysztof Grobelny if (manufacturer != nullptr) 40786d89ed7SKrzysztof Grobelny { 40886d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["Manufacturer"] = *manufacturer; 40986d89ed7SKrzysztof Grobelny } 41086d89ed7SKrzysztof Grobelny 41186d89ed7SKrzysztof Grobelny if (model != nullptr) 41286d89ed7SKrzysztof Grobelny { 41386d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["Model"] = *model; 41486d89ed7SKrzysztof Grobelny } 41586d89ed7SKrzysztof Grobelny 416caa11f7aSAlpana Kumari // SparePartNumber is optional on D-Bus 417caa11f7aSAlpana Kumari // so skip if it is empty 41886d89ed7SKrzysztof Grobelny if (sparePartNumber != nullptr && !sparePartNumber->empty()) 419caa11f7aSAlpana Kumari { 42086d89ed7SKrzysztof Grobelny asyncResp->res.jsonValue["SparePartNumber"] = 42186d89ed7SKrzysztof Grobelny *sparePartNumber; 422caa11f7aSAlpana Kumari } 42386d89ed7SKrzysztof Grobelny 42462d5e2e4SEd Tanous asyncResp->res.jsonValue["Name"] = chassisId; 42562d5e2e4SEd Tanous asyncResp->res.jsonValue["Id"] = chassisId; 4260256b694Szhanghch05 #ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL 427002d39b4SEd Tanous asyncResp->res.jsonValue["Thermal"]["@odata.id"] = 428eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 429eddfc437SWilly Tu chassisId, "Thermal"); 4302474adfaSEd Tanous // Power object 4311476687dSEd Tanous asyncResp->res.jsonValue["Power"]["@odata.id"] = 432eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 433eddfc437SWilly Tu chassisId, "Power"); 4340256b694Szhanghch05 #endif 4352973963eSXiaochao Ma #ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM 4362973963eSXiaochao Ma asyncResp->res.jsonValue["ThermalSubsystem"]["@odata.id"] = 4372973963eSXiaochao Ma crow::utility::urlFromPieces("redfish", "v1", "Chassis", 4382973963eSXiaochao Ma chassisId, "ThermalSubsystem"); 43977b36437SChicago Duan asyncResp->res.jsonValue["PowerSubsystem"]["@odata.id"] = 44077b36437SChicago Duan crow::utility::urlFromPieces("redfish", "v1", "Chassis", 44177b36437SChicago Duan chassisId, "PowerSubsystem"); 4424ca3ec3cSAlbert Zhang asyncResp->res.jsonValue["EnvironmentMetrics"]["@odata.id"] = 4434ca3ec3cSAlbert Zhang crow::utility::urlFromPieces("redfish", "v1", "Chassis", 4444ca3ec3cSAlbert Zhang chassisId, 4454ca3ec3cSAlbert Zhang "EnvironmentMetrics"); 4462973963eSXiaochao Ma #endif 44795a3ecadSAnthony Wilson // SensorCollection 448002d39b4SEd Tanous asyncResp->res.jsonValue["Sensors"]["@odata.id"] = 449eddfc437SWilly Tu crow::utility::urlFromPieces("redfish", "v1", "Chassis", 450eddfc437SWilly Tu chassisId, "Sensors"); 451002d39b4SEd Tanous asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; 4521476687dSEd Tanous 4531476687dSEd Tanous nlohmann::json::array_t computerSystems; 4541476687dSEd Tanous nlohmann::json::object_t system; 455002d39b4SEd Tanous system["@odata.id"] = "/redfish/v1/Systems/system"; 4561476687dSEd Tanous computerSystems.push_back(std::move(system)); 457002d39b4SEd Tanous asyncResp->res.jsonValue["Links"]["ComputerSystems"] = 4581476687dSEd Tanous std::move(computerSystems); 4591476687dSEd Tanous 4601476687dSEd Tanous nlohmann::json::array_t managedBy; 4611476687dSEd Tanous nlohmann::json::object_t manager; 462002d39b4SEd Tanous manager["@odata.id"] = "/redfish/v1/Managers/bmc"; 4631476687dSEd Tanous managedBy.push_back(std::move(manager)); 4647e860f15SJohn Edward Broadbent asyncResp->res.jsonValue["Links"]["ManagedBy"] = 4651476687dSEd Tanous std::move(managedBy); 466beeca0aeSGunnar Mills getChassisState(asyncResp); 46786d89ed7SKrzysztof Grobelny }); 4682c37b4b0SSharad Yadav 469308f70c7SWilly Tu for (const auto& interface : interfaces2) 4702c37b4b0SSharad Yadav { 471308f70c7SWilly Tu if (interface == "xyz.openbmc_project.Common.UUID") 4722c37b4b0SSharad Yadav { 473308f70c7SWilly Tu getChassisUUID(asyncResp, connectionName, path); 4742c37b4b0SSharad Yadav } 475cf7eba09SNan Zhou else if (interface == 4760fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Decorator.LocationCode") 4772c37b4b0SSharad Yadav { 478002d39b4SEd Tanous getChassisLocationCode(asyncResp, connectionName, path); 4792c37b4b0SSharad Yadav } 4802c37b4b0SSharad Yadav } 4812c37b4b0SSharad Yadav 482daf36e2eSEd Tanous return; 483daf36e2eSEd Tanous } 484e0d918bcSEd Tanous 485daf36e2eSEd Tanous // Couldn't find an object with that name. return an error 486d8a5d5d8SJiaqing Zhao messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); 487e99073f5SGeorge Liu }); 488c181942fSQiang XU 489c181942fSQiang XU getPhysicalSecurityData(asyncResp); 490cf7eba09SNan Zhou } 4911c8fba97SJames Feist 492cf7eba09SNan Zhou inline void 493cf7eba09SNan Zhou handleChassisPatch(App& app, const crow::Request& req, 4947e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 495cf7eba09SNan Zhou const std::string& param) 496cf7eba09SNan Zhou { 4973ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 49845ca1b86SEd Tanous { 49945ca1b86SEd Tanous return; 50045ca1b86SEd Tanous } 5019f8bfa7cSGunnar Mills std::optional<bool> locationIndicatorActive; 5021c8fba97SJames Feist std::optional<std::string> indicatorLed; 5031c8fba97SJames Feist 5047e860f15SJohn Edward Broadbent if (param.empty()) 5051c8fba97SJames Feist { 5061c8fba97SJames Feist return; 5071c8fba97SJames Feist } 5081c8fba97SJames Feist 50915ed6780SWilly Tu if (!json_util::readJsonPatch( 5107e860f15SJohn Edward Broadbent req, asyncResp->res, "LocationIndicatorActive", 5117e860f15SJohn Edward Broadbent locationIndicatorActive, "IndicatorLED", indicatorLed)) 5121c8fba97SJames Feist { 5131c8fba97SJames Feist return; 5141c8fba97SJames Feist } 5151c8fba97SJames Feist 5169f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed 5179f8bfa7cSGunnar Mills if (!locationIndicatorActive && !indicatorLed) 5181c8fba97SJames Feist { 5191c8fba97SJames Feist return; // delete this when we support more patch properties 5201c8fba97SJames Feist } 521d6aa0093SGunnar Mills if (indicatorLed) 522d6aa0093SGunnar Mills { 5237e860f15SJohn Edward Broadbent asyncResp->res.addHeader( 5247e860f15SJohn Edward Broadbent boost::beast::http::field::warning, 5250fda0f12SGeorge Liu "299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\""); 526d6aa0093SGunnar Mills } 5271c8fba97SJames Feist 528e99073f5SGeorge Liu constexpr std::array<std::string_view, 2> interfaces = { 5291c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Board", 5301c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Chassis"}; 5311c8fba97SJames Feist 5327e860f15SJohn Edward Broadbent const std::string& chassisId = param; 5331c8fba97SJames Feist 534e99073f5SGeorge Liu dbus::utility::getSubTree( 535e99073f5SGeorge Liu "/xyz/openbmc_project/inventory", 0, interfaces, 536cf7eba09SNan Zhou [asyncResp, chassisId, locationIndicatorActive, 5375e7e2dc5SEd Tanous indicatorLed](const boost::system::error_code& ec, 538b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreeResponse& subtree) { 5391c8fba97SJames Feist if (ec) 5401c8fba97SJames Feist { 5411c8fba97SJames Feist messages::internalError(asyncResp->res); 5421c8fba97SJames Feist return; 5431c8fba97SJames Feist } 5441c8fba97SJames Feist 5451c8fba97SJames Feist // Iterate over all retrieved ObjectPaths. 546cf7eba09SNan Zhou for (const std::pair< 547cf7eba09SNan Zhou std::string, 548cf7eba09SNan Zhou std::vector<std::pair<std::string, std::vector<std::string>>>>& 5491214b7e7SGunnar Mills object : subtree) 5501c8fba97SJames Feist { 5511c8fba97SJames Feist const std::string& path = object.first; 552cf7eba09SNan Zhou const std::vector<std::pair<std::string, std::vector<std::string>>>& 5531214b7e7SGunnar Mills connectionNames = object.second; 5541c8fba97SJames Feist 555997093ebSGeorge Liu sdbusplus::message::object_path objPath(path); 556997093ebSGeorge Liu if (objPath.filename() != chassisId) 5571c8fba97SJames Feist { 5581c8fba97SJames Feist continue; 5591c8fba97SJames Feist } 5601c8fba97SJames Feist 56126f6976fSEd Tanous if (connectionNames.empty()) 5621c8fba97SJames Feist { 5631c8fba97SJames Feist BMCWEB_LOG_ERROR << "Got 0 Connection names"; 5641c8fba97SJames Feist continue; 5651c8fba97SJames Feist } 5661c8fba97SJames Feist 56723a21a1cSEd Tanous const std::vector<std::string>& interfaces3 = 5681c8fba97SJames Feist connectionNames[0].second; 5691c8fba97SJames Feist 5701c8fba97SJames Feist const std::array<const char*, 2> hasIndicatorLed = { 5711c8fba97SJames Feist "xyz.openbmc_project.Inventory.Item.Panel", 5720fda0f12SGeorge Liu "xyz.openbmc_project.Inventory.Item.Board.Motherboard"}; 5731c8fba97SJames Feist bool indicatorChassis = false; 5741c8fba97SJames Feist for (const char* interface : hasIndicatorLed) 5751c8fba97SJames Feist { 576002d39b4SEd Tanous if (std::find(interfaces3.begin(), interfaces3.end(), 57723a21a1cSEd Tanous interface) != interfaces3.end()) 5781c8fba97SJames Feist { 5791c8fba97SJames Feist indicatorChassis = true; 5801c8fba97SJames Feist break; 5811c8fba97SJames Feist } 5821c8fba97SJames Feist } 5839f8bfa7cSGunnar Mills if (locationIndicatorActive) 5849f8bfa7cSGunnar Mills { 5859f8bfa7cSGunnar Mills if (indicatorChassis) 5869f8bfa7cSGunnar Mills { 587002d39b4SEd Tanous setLocationIndicatorActive(asyncResp, 588002d39b4SEd Tanous *locationIndicatorActive); 5899f8bfa7cSGunnar Mills } 5909f8bfa7cSGunnar Mills else 5919f8bfa7cSGunnar Mills { 592002d39b4SEd Tanous messages::propertyUnknown(asyncResp->res, 593002d39b4SEd Tanous "LocationIndicatorActive"); 5949f8bfa7cSGunnar Mills } 5959f8bfa7cSGunnar Mills } 5969f8bfa7cSGunnar Mills if (indicatorLed) 5979f8bfa7cSGunnar Mills { 5981c8fba97SJames Feist if (indicatorChassis) 5991c8fba97SJames Feist { 600f23b7296SEd Tanous setIndicatorLedState(asyncResp, *indicatorLed); 6011c8fba97SJames Feist } 6021c8fba97SJames Feist else 6031c8fba97SJames Feist { 604cf7eba09SNan Zhou messages::propertyUnknown(asyncResp->res, "IndicatorLED"); 6051c8fba97SJames Feist } 6061c8fba97SJames Feist } 6071c8fba97SJames Feist return; 6081c8fba97SJames Feist } 6091c8fba97SJames Feist 610d8a5d5d8SJiaqing Zhao messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); 611e99073f5SGeorge Liu }); 612cf7eba09SNan Zhou } 613cf7eba09SNan Zhou 614cf7eba09SNan Zhou /** 615cf7eba09SNan Zhou * Chassis override class for delivering Chassis Schema 616cf7eba09SNan Zhou * Functions triggers appropriate requests on DBus 617cf7eba09SNan Zhou */ 618cf7eba09SNan Zhou inline void requestRoutesChassis(App& app) 619cf7eba09SNan Zhou { 620cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/") 621cf7eba09SNan Zhou .privileges(redfish::privileges::getChassis) 622cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 623cf7eba09SNan Zhou std::bind_front(handleChassisGet, std::ref(app))); 624cf7eba09SNan Zhou 625cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/") 626cf7eba09SNan Zhou .privileges(redfish::privileges::patchChassis) 627cf7eba09SNan Zhou .methods(boost::beast::http::verb::patch)( 628cf7eba09SNan Zhou std::bind_front(handleChassisPatch, std::ref(app))); 6291c8fba97SJames Feist } 630dd99e04bSP.K. Lee 6318d1b46d7Szhanghch05 inline void 6328d1b46d7Szhanghch05 doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 633dd99e04bSP.K. Lee { 6347a1dbc48SGeorge Liu constexpr std::array<std::string_view, 1> interfaces = { 635c3b3c92aSVijay Khemka "xyz.openbmc_project.State.Chassis"}; 636c3b3c92aSVijay Khemka 637c3b3c92aSVijay Khemka // Use mapper to get subtree paths. 6387a1dbc48SGeorge Liu dbus::utility::getSubTreePaths( 6397a1dbc48SGeorge Liu "/", 0, interfaces, 640b9d36b47SEd Tanous [asyncResp]( 6417a1dbc48SGeorge Liu const boost::system::error_code& ec, 642b9d36b47SEd Tanous const dbus::utility::MapperGetSubTreePathsResponse& chassisList) { 643c3b3c92aSVijay Khemka if (ec) 644c3b3c92aSVijay Khemka { 645c3b3c92aSVijay Khemka BMCWEB_LOG_DEBUG << "[mapper] Bad D-Bus request error: " << ec; 646c3b3c92aSVijay Khemka messages::internalError(asyncResp->res); 647c3b3c92aSVijay Khemka return; 648c3b3c92aSVijay Khemka } 649c3b3c92aSVijay Khemka 650dd99e04bSP.K. Lee const char* processName = "xyz.openbmc_project.State.Chassis"; 651dd99e04bSP.K. Lee const char* interfaceName = "xyz.openbmc_project.State.Chassis"; 652dd99e04bSP.K. Lee const char* destProperty = "RequestedPowerTransition"; 653dd99e04bSP.K. Lee const std::string propertyValue = 654dd99e04bSP.K. Lee "xyz.openbmc_project.State.Chassis.Transition.PowerCycle"; 655002d39b4SEd Tanous std::string objectPath = "/xyz/openbmc_project/state/chassis_system0"; 656c3b3c92aSVijay Khemka 657c3b3c92aSVijay Khemka /* Look for system reset chassis path */ 658002d39b4SEd Tanous if ((std::find(chassisList.begin(), chassisList.end(), objectPath)) == 659002d39b4SEd Tanous chassisList.end()) 660c3b3c92aSVijay Khemka { 661c3b3c92aSVijay Khemka /* We prefer to reset the full chassis_system, but if it doesn't 662c3b3c92aSVijay Khemka * exist on some platforms, fall back to a host-only power reset 663c3b3c92aSVijay Khemka */ 664c3b3c92aSVijay Khemka objectPath = "/xyz/openbmc_project/state/chassis0"; 665c3b3c92aSVijay Khemka } 666dd99e04bSP.K. Lee 667dd99e04bSP.K. Lee crow::connections::systemBus->async_method_call( 6685e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec2) { 669dd99e04bSP.K. Lee // Use "Set" method to set the property value. 6708a592810SEd Tanous if (ec2) 671dd99e04bSP.K. Lee { 6728a592810SEd Tanous BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec2; 673dd99e04bSP.K. Lee messages::internalError(asyncResp->res); 674dd99e04bSP.K. Lee return; 675dd99e04bSP.K. Lee } 676dd99e04bSP.K. Lee 677dd99e04bSP.K. Lee messages::success(asyncResp->res); 678dd99e04bSP.K. Lee }, 679002d39b4SEd Tanous processName, objectPath, "org.freedesktop.DBus.Properties", "Set", 680002d39b4SEd Tanous interfaceName, destProperty, 681168e20c1SEd Tanous dbus::utility::DbusVariantType{propertyValue}); 6827a1dbc48SGeorge Liu }); 683dd99e04bSP.K. Lee } 684dd99e04bSP.K. Lee 685cf7eba09SNan Zhou inline void handleChassisResetActionInfoPost( 686cf7eba09SNan Zhou App& app, const crow::Request& req, 6877e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 688cf7eba09SNan Zhou const std::string& /*chassisId*/) 689cf7eba09SNan Zhou { 6903ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 69145ca1b86SEd Tanous { 69245ca1b86SEd Tanous return; 69345ca1b86SEd Tanous } 694dd99e04bSP.K. Lee BMCWEB_LOG_DEBUG << "Post Chassis Reset."; 695dd99e04bSP.K. Lee 696dd99e04bSP.K. Lee std::string resetType; 697dd99e04bSP.K. Lee 698cf7eba09SNan Zhou if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType)) 699dd99e04bSP.K. Lee { 700dd99e04bSP.K. Lee return; 701dd99e04bSP.K. Lee } 702dd99e04bSP.K. Lee 703dd99e04bSP.K. Lee if (resetType != "PowerCycle") 704dd99e04bSP.K. Lee { 705dd99e04bSP.K. Lee BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: " 706dd99e04bSP.K. Lee << resetType; 707002d39b4SEd Tanous messages::actionParameterNotSupported(asyncResp->res, resetType, 708002d39b4SEd Tanous "ResetType"); 709dd99e04bSP.K. Lee 710dd99e04bSP.K. Lee return; 711dd99e04bSP.K. Lee } 712dd99e04bSP.K. Lee doChassisPowerCycle(asyncResp); 713dd99e04bSP.K. Lee } 7141cb1a9e6SAppaRao Puli 7151cb1a9e6SAppaRao Puli /** 716cf7eba09SNan Zhou * ChassisResetAction class supports the POST method for the Reset 717cf7eba09SNan Zhou * action. 718cf7eba09SNan Zhou * Function handles POST method request. 719cf7eba09SNan Zhou * Analyzes POST body before sending Reset request data to D-Bus. 7201cb1a9e6SAppaRao Puli */ 721cf7eba09SNan Zhou 722cf7eba09SNan Zhou inline void requestRoutesChassisResetAction(App& app) 7231cb1a9e6SAppaRao Puli { 724cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/") 725cf7eba09SNan Zhou .privileges(redfish::privileges::postChassis) 726cf7eba09SNan Zhou .methods(boost::beast::http::verb::post)( 727cf7eba09SNan Zhou std::bind_front(handleChassisResetActionInfoPost, std::ref(app))); 728cf7eba09SNan Zhou } 729cf7eba09SNan Zhou 730cf7eba09SNan Zhou inline void handleChassisResetActionInfoGet( 731cf7eba09SNan Zhou App& app, const crow::Request& req, 7327e860f15SJohn Edward Broadbent const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 733cf7eba09SNan Zhou const std::string& chassisId) 734cf7eba09SNan Zhou { 7353ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 7361cb1a9e6SAppaRao Puli { 73745ca1b86SEd Tanous return; 73845ca1b86SEd Tanous } 739cf7eba09SNan Zhou asyncResp->res.jsonValue["@odata.type"] = "#ActionInfo.v1_1_2.ActionInfo"; 740eddfc437SWilly Tu asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces( 741eddfc437SWilly Tu "redfish", "v1", "Chassis", chassisId, "ResetActionInfo"); 7421476687dSEd Tanous asyncResp->res.jsonValue["Name"] = "Reset Action Info"; 7431476687dSEd Tanous 7441476687dSEd Tanous asyncResp->res.jsonValue["Id"] = "ResetActionInfo"; 7455b9e95a1SNan Zhou nlohmann::json::array_t parameters; 7465b9e95a1SNan Zhou nlohmann::json::object_t parameter; 7475b9e95a1SNan Zhou parameter["Name"] = "ResetType"; 7485b9e95a1SNan Zhou parameter["Required"] = true; 7495b9e95a1SNan Zhou parameter["DataType"] = "String"; 7501476687dSEd Tanous nlohmann::json::array_t allowed; 7511476687dSEd Tanous allowed.push_back("PowerCycle"); 7525b9e95a1SNan Zhou parameter["AllowableValues"] = std::move(allowed); 7535b9e95a1SNan Zhou parameters.push_back(std::move(parameter)); 7545b9e95a1SNan Zhou 7551476687dSEd Tanous asyncResp->res.jsonValue["Parameters"] = std::move(parameters); 756cf7eba09SNan Zhou } 757cf7eba09SNan Zhou 758cf7eba09SNan Zhou /** 759cf7eba09SNan Zhou * ChassisResetActionInfo derived class for delivering Chassis 760cf7eba09SNan Zhou * ResetType AllowableValues using ResetInfo schema. 761cf7eba09SNan Zhou */ 762cf7eba09SNan Zhou inline void requestRoutesChassisResetActionInfo(App& app) 763cf7eba09SNan Zhou { 764cf7eba09SNan Zhou BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/") 765cf7eba09SNan Zhou .privileges(redfish::privileges::getActionInfo) 766cf7eba09SNan Zhou .methods(boost::beast::http::verb::get)( 767cf7eba09SNan Zhou std::bind_front(handleChassisResetActionInfoGet, std::ref(app))); 7681cb1a9e6SAppaRao Puli } 7691cb1a9e6SAppaRao Puli 770e37f8451SRapkiewicz, Pawel } // namespace redfish 771