@@ -1375,38 +1375,11 @@ inline void
13751375 });
13761376}
13771377
1378- inline void handleUpdateServiceFirmwareInventoryGet (
1379- App& app, const crow::Request& req ,
1380- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1381- const std::string& param)
1378+ inline void processUpdateServiceFirmwareInventoryGet (
1379+ uint16_t hostNumber ,
1380+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1381+ const std::string& param)
13821382{
1383- if (!redfish::setUpRedfishRoute (app, req, asyncResp))
1384- {
1385- return ;
1386- }
1387-
1388- boost::urls::url_view urlView = req.url ();
1389- uint16_t hostNumber;
1390-
1391- for (const auto & parameter : urlView.params ())
1392- {
1393- if (parameter.key == " HostNumber" && !parameter.value .empty ())
1394- {
1395- try
1396- {
1397- int temp = std::stoi (std::string (parameter.value ));
1398- hostNumber = static_cast <uint16_t >(temp);
1399- }
1400- catch (const std::exception& e)
1401- {
1402- BMCWEB_LOG_WARNING (" Invalid HostNumber format: {}" ,
1403- parameter.value );
1404- hostNumber = 0 ;
1405- }
1406- break ;
1407- }
1408- }
1409-
14101383 if (hostNumber > 2 )
14111384 {
14121385 messages::actionParameterNotSupported (
@@ -1479,6 +1452,74 @@ inline void handleUpdateServiceFirmwareInventoryGet(
14791452 });
14801453}
14811454
1455+ void getBootMode (
1456+ uint16_t hostNumber,
1457+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1458+ const std::string& param)
1459+ {
1460+ sdbusplus::asio::getProperty<uint16_t >
1461+ (*crow::connections::systemBus,
1462+ " xyz.openbmc_project.Settings" ,
1463+ " /xyz/openbmc_project/control/HostMode" ,
1464+ " xyz.openbmc_project.Control.HostMode" ,
1465+ " CurrentMode" ,
1466+ [hostNumber, asyncResp, param](const boost::system::error_code& ec, const uint16_t & bmode) {
1467+ if (ec) {
1468+ BMCWEB_LOG_ERROR (" Current boot mode error: {}" , ec.message ());
1469+ messages::internalError (asyncResp->res );
1470+ return ;
1471+ }
1472+
1473+ if (hostNumber == 0 && bmode == 1 ) {
1474+ BMCWEB_LOG_ERROR (" Invalid HostNumber {} for the mode {}" , hostNumber, bmode);
1475+ messages::actionParameterNotSupported (
1476+ asyncResp->res , std::to_string (hostNumber), " HostNumber" );
1477+ return ;
1478+ }
1479+ BMCWEB_LOG_DEBUG (" boot mode: {}" , bmode);
1480+ processUpdateServiceFirmwareInventoryGet (hostNumber, asyncResp, param);
1481+ }
1482+ );
1483+ }
1484+
1485+ inline void handleUpdateServiceFirmwareInventoryGet (
1486+ App& app, const crow::Request& req,
1487+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1488+ const std::string& param)
1489+ {
1490+ if (!redfish::setUpRedfishRoute (app, req, asyncResp))
1491+ {
1492+ return ;
1493+ }
1494+
1495+ boost::urls::url_view urlView = req.url ();
1496+ uint16_t hostNumber = 0 ;
1497+
1498+ for (const auto & parameter : urlView.params ()) {
1499+ if (parameter.key == " HostNumber" ) {
1500+ if (!parameter.value .empty ()) {
1501+ try {
1502+ int temp = std::stoi (std::string (parameter.value ));
1503+ hostNumber = static_cast <uint16_t >(temp);
1504+ getBootMode (hostNumber, asyncResp, param);
1505+ }
1506+ catch (const std::exception& e) {
1507+ BMCWEB_LOG_ERROR (" Invalid HostNumber format: {}" , parameter.value );
1508+ messages::actionParameterValueFormatError (
1509+ asyncResp->res , parameter.value , " HostNumber" , " " );
1510+ return ;
1511+ }
1512+ } else {
1513+ BMCWEB_LOG_ERROR (" Missing HostNumber" );
1514+ messages::actionParameterMissing (asyncResp->res , " HostNumber" , " " );
1515+ return ;
1516+ }
1517+ }
1518+ }
1519+
1520+ processUpdateServiceFirmwareInventoryGet (hostNumber, asyncResp, param);
1521+ }
1522+
14821523inline void requestRoutesUpdateService (App& app)
14831524{
14841525 BMCWEB_ROUTE (
0 commit comments