From ed3982131dcef2b499da36e674d2d21b2289ef29 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 9 Jun 2021 17:05:54 -0700 Subject: Automate PrivilegeRegistry to code This commit attempts to automate the creation of our privileges structures from the redfish privilege registry. It accomplishes this by updating parse_registries.py to also pull down the privilege registry from DMTF. The script then generates privilege_registry.hpp, which include const defines for all the privilege registry entries in the same format that the Privileges struct accepts. This allows new clients to simply reference the variable to these privilege structures, instead of having to manually (ie error pronely) put the privileges in themselves. This commit updates all the routes. For the moment, override and OEM schemas are not considered. Today we don't have any OEM-specific Redfish routes, so the existing ones inherit their parents schema. Overrides have other issues, and are already incorrect as Redfish defines them. Binary size remains unchanged after this patchset. Tested: Ran redfish service validator Ran test case from f9a6708c4c6490257e2eb6a8c04458f500902476 to ensure that the new privileges constructor didn't cause us to regress the brace construction initializer. Checked binary size with: gzip -c $BBPATH/tmp/work/s7106-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/bin/bmcweb | wc -c 1244048 (tested on previous patchset) Signed-off-by: Ed Tanous Change-Id: Ideede3d5b39d50bffe7fe78a0848bdbc22ac387f --- redfish-core/lib/hypervisor_system.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'redfish-core/lib/hypervisor_system.hpp') diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp index 5274e5390a..79a89fa15e 100644 --- a/redfish-core/lib/hypervisor_system.hpp +++ b/redfish-core/lib/hypervisor_system.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -725,7 +726,7 @@ inline void requestRoutesHypervisorSystems(App& app) */ BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/") - .privileges({{"Login"}}) + .privileges(redfish::privileges::getComputerSystem) .methods(boost::beast::http::verb::get)( [](const crow::Request&, const std::shared_ptr& asyncResp) { @@ -769,7 +770,7 @@ inline void requestRoutesHypervisorSystems(App& app) */ BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/EthernetInterfaces/") - .privileges({{"Login"}}) + .privileges(redfish::privileges::getEthernetInterfaceCollection) .methods(boost::beast::http::verb::get)( [](const crow::Request&, const std::shared_ptr& asyncResp) { @@ -825,7 +826,7 @@ inline void requestRoutesHypervisorSystems(App& app) BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/EthernetInterfaces//") - .privileges({{"Login"}}) + .privileges(redfish::privileges::getEthernetInterface) .methods( boost::beast::http::verb::get)([](const crow::Request&, const std::shared_ptr< @@ -856,7 +857,7 @@ inline void requestRoutesHypervisorSystems(App& app) BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/EthernetInterfaces//") - .privileges({{"ConfigureComponents"}}) + .privileges(redfish::privileges::patchEthernetInterface) .methods( boost::beast::http::verb:: patch)([](const crow::Request& req, @@ -970,7 +971,7 @@ inline void requestRoutesHypervisorSystems(App& app) }); BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/ResetActionInfo/") - .privileges({{"Login"}}) + .privileges(redfish::privileges::getActionInfo) .methods(boost::beast::http::verb::get)( [](const crow::Request&, const std::shared_ptr& asyncResp) { @@ -1029,7 +1030,7 @@ inline void requestRoutesHypervisorSystems(App& app) BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset/") - .privileges({{"ConfigureComponents"}}) + .privileges(redfish::privileges::postComputerSystem) .methods(boost::beast::http::verb::post)( [](const crow::Request& req, const std::shared_ptr& asyncResp) { -- cgit v1.2.3