diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2018-09-13 13:47:50 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2018-10-08 17:26:43 +0000 |
| commit | b9b2e0b2119e6d589f5f6981f853dbcc231cd899 (patch) | |
| tree | 85c0694b97bea88d019facd241645fe2e813b705 /include | |
| parent | 62d5e2e47f76c062c06eefac9a3dc29d24c390f5 (diff) | |
| download | bmcweb-b9b2e0b2119e6d589f5f6981f853dbcc231cd899.tar.gz bmcweb-b9b2e0b2119e6d589f5f6981f853dbcc231cd899.zip | |
Move AccountService to node structure
AccountService was the last service hanging on to the old way of doing
things. This moves it up to our current standard using the Node class.
Tested by: Ran service validator. Saw no errors.
Change-Id: I84d0097f48803cb06d2ec95171f18bff04661666
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/openbmc_dbus_rest.hpp | 2 | ||||
| -rw-r--r-- | include/redfish_v1.hpp | 123 |
2 files changed, 2 insertions, 123 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 7ed8e16..e0d9986 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -1,3 +1,5 @@ +#pragma once + #include <crow/app.h> #include <tinyxml2.h> diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp index 13e1838..f1dbfd2 100644 --- a/include/redfish_v1.hpp +++ b/include/redfish_v1.hpp @@ -13,13 +13,6 @@ namespace crow { namespace redfish { - -using ManagedObjectType = std::vector<std::pair< - sdbusplus::message::object_path, - boost::container::flat_map< - std::string, boost::container::flat_map< - std::string, sdbusplus::message::variant<bool>>>>>; - template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app) { BMCWEB_ROUTE(app, "/redfish/") @@ -28,122 +21,6 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app) res.jsonValue = {{"v1", "/redfish/v1/"}}; res.end(); }); - - BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/") - .methods( - "GET"_method)([&](const crow::Request& req, crow::Response& res) { - crow::connections::systemBus->async_method_call( - [&](const boost::system::error_code ec, - const ManagedObjectType& users) { - if (ec) - { - res.result( - boost::beast::http::status::internal_server_error); - } - else - { - res.jsonValue = { - {"@odata.context", - "/redfish/v1/" - "$metadata#ManagerAccountCollection." - "ManagerAccountCollection"}, - {"@odata.id", - "/redfish/v1/AccountService/Accounts"}, - {"@odata.type", "#ManagerAccountCollection." - "ManagerAccountCollection"}, - {"Name", "Accounts Collection"}, - {"Description", "BMC User Accounts"}, - {"Members@odata.count", users.size()}}; - nlohmann::json memberArray = nlohmann::json::array(); - int userIndex = 0; - for (auto& user : users) - { - const std::string& path = - static_cast<const std::string&>(user.first); - std::size_t lastIndex = path.rfind("/"); - if (lastIndex == std::string::npos) - { - lastIndex = 0; - } - else - { - lastIndex += 1; - } - memberArray.push_back( - {{"@odata.id", - "/redfish/v1/AccountService/Accounts/" + - path.substr(lastIndex)}}); - } - res.jsonValue["Members"] = memberArray; - } - res.end(); - }, - "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user", - "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); - }); - - BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/<str>/") - .methods("GET"_method)([](const crow::Request& req, crow::Response& res, - const std::string& account_name) { - crow::connections::systemBus->async_method_call( - [&, accountName{std::move(account_name)}]( - const boost::system::error_code ec, - const ManagedObjectType& users) { - if (ec) - { - res.result( - boost::beast::http::status::internal_server_error); - } - else - { - for (auto& user : users) - { - const std::string& path = - static_cast<const std::string&>(user.first); - std::size_t lastIndex = path.rfind("/"); - if (lastIndex == std::string::npos) - { - lastIndex = 0; - } - else - { - lastIndex += 1; - } - if (path.substr(lastIndex) == accountName) - { - res.jsonValue = { - {"@odata.context", - "/redfish/v1/" - "$metadata#ManagerAccount.ManagerAccount"}, - {"@odata.id", - "/redfish/v1/AccountService/Accounts/1"}, - {"@odata.type", - "#ManagerAccount.v1_0_3.ManagerAccount"}, - {"Id", "1"}, - {"Name", "User Account"}, - {"Description", "User Account"}, - {"Enabled", false}, - {"Password", nullptr}, - {"UserName", accountName}, - {"RoleId", "Administrator"}, - {"Links", - {{"Role", - {{"@odata.id", - "/redfish/v1/AccountService/Roles/" - "Administrator"}}}}}}; - break; - } - } - if (res.jsonValue.is_null()) - { - res.result(boost::beast::http::status::not_found); - } - } - res.end(); - }, - "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user", - "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); - }); } } // namespace redfish } // namespace crow |

