diff options
author | Ed Tanous <ed.tanous@intel.com> | 2018-05-23 01:27:24 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2018-07-27 01:54:37 +0300 |
commit | 55c7b7a2e58779580f33046d2dd8649243776700 (patch) | |
tree | eed2d032dff3e18c4a8d4778e8f52ae5864620ee /redfish-core/lib | |
parent | 1752c9657b56a6e1950d8725f44f4298c9872c63 (diff) | |
download | bmcweb-55c7b7a2e58779580f33046d2dd8649243776700.tar.xz |
Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.
This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.
Tested: Code still compiles, and appears to run, although other issues
are possible and likely.
Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'redfish-core/lib')
-rw-r--r-- | redfish-core/lib/account_service.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/chassis.hpp | 80 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 616 | ||||
-rw-r--r-- | redfish-core/lib/managers.hpp | 22 | ||||
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 4 | ||||
-rw-r--r-- | redfish-core/lib/redfish_sessions.hpp | 91 | ||||
-rw-r--r-- | redfish-core/lib/roles.hpp | 36 | ||||
-rw-r--r-- | redfish-core/lib/sensors.hpp | 162 | ||||
-rw-r--r-- | redfish-core/lib/service_root.hpp | 8 | ||||
-rw-r--r-- | redfish-core/lib/systems.hpp | 174 | ||||
-rw-r--r-- | redfish-core/lib/thermal.hpp | 8 | ||||
-rw-r--r-- | redfish-core/lib/update_service.hpp | 74 |
12 files changed, 642 insertions, 637 deletions
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index 9071067eb3..47b4c4c7b6 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -46,9 +46,9 @@ class AccountService : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } }; diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index ef3b7afc63..731ea7b69e 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -24,7 +24,7 @@ namespace redfish { * DBus types primitives for several generic DBus interfaces * TODO(Pawel) consider move this to separate file into boost::dbus */ -// Note, this is not a very useful variant, but because it isn't used to get +// Note, this is not a very useful Variant, but because it isn't used to get // values, it should be as simple as possible // TODO(ed) invent a nullvariant type using VariantType = sdbusplus::message::variant<bool, std::string>; @@ -55,38 +55,38 @@ class OnDemandChassisProvider { * JSON. */ template <typename CallbackFunc> - void get_chassis_list(CallbackFunc &&callback) { + void getChassisList(CallbackFunc &&callback) { const std::array<const char *, 4> interfaces = { "xyz.openbmc_project.Inventory.Item.Board", "xyz.openbmc_project.Inventory.Item.Chassis", "xyz.openbmc_project.Inventory.Item.PowerSupply", "xyz.openbmc_project.Inventory.Item.System", }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [callback{std::move(callback)}]( const boost::system::error_code error_code, const std::vector<std::string> &resp) { // Callback requires vector<string> to retrieve all available chassis // list. - std::vector<std::string> chassis_list; + std::vector<std::string> chassisList; if (error_code) { // Something wrong on DBus, the error_code is not important at this // moment, just return success=false, and empty output. Since size // of vector may vary depending on information from Entity Manager, // and empty output could not be treated same way as error. - callback(false, chassis_list); + callback(false, chassisList); return; } // Iterate over all retrieved ObjectPaths. for (const std::string &objpath : resp) { - std::size_t last_pos = objpath.rfind("/"); - if (last_pos != std::string::npos) { + std::size_t lastPos = objpath.rfind("/"); + if (lastPos != std::string::npos) { // and put it into output vector. - chassis_list.emplace_back(objpath.substr(last_pos + 1)); + chassisList.emplace_back(objpath.substr(lastPos + 1)); } } - // Finally make a callback with useful data - callback(true, chassis_list); + // Finally make a callback with usefull data + callback(true, chassisList); }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", @@ -120,22 +120,22 @@ class ChassisCollection : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { - // Get chassis list, and call the below callback for JSON preparation - chassis_provider.get_chassis_list( + // get chassis list, and call the below callback for JSON preparation + chassisProvider.getChassisList( [&](const bool &success, const std::vector<std::string> &output) { if (success) { // ... prepare json array with appropriate @odata.id links - nlohmann::json chassis_array = nlohmann::json::array(); - for (const std::string &chassis_item : output) { - chassis_array.push_back( - {{"@odata.id", "/redfish/v1/Chassis/" + chassis_item}}); + nlohmann::json chassisArray = nlohmann::json::array(); + for (const std::string &chassisItem : output) { + chassisArray.push_back( + {{"@odata.id", "/redfish/v1/Chassis/" + chassisItem}}); } // Then attach members, count size and return, - Node::json["Members"] = chassis_array; - Node::json["Members@odata.count"] = chassis_array.size(); - res.json_value = Node::json; + Node::json["Members"] = chassisArray; + Node::json["Members@odata.count"] = chassisArray.size(); + res.jsonValue = Node::json; } else { // ... otherwise, return INTERNALL ERROR res.result(boost::beast::http::status::internal_server_error); @@ -146,7 +146,7 @@ class ChassisCollection : public Node { // Chassis Provider object // TODO(Pawel) consider move it to singleton - OnDemandChassisProvider chassis_provider; + OnDemandChassisProvider chassisProvider; }; /** @@ -175,7 +175,7 @@ class Chassis : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // Check if there is required param, truly entering this shall be // impossible. @@ -185,17 +185,17 @@ class Chassis : public Node { return; } - res.json_value = Node::json; - const std::string &chassis_id = params[0]; - crow::connections::system_bus->async_method_call( - [&res, chassis_id(std::string(chassis_id)) ]( + res.jsonValue = Node::json; + const std::string &chassisId = params[0]; + crow::connections::systemBus->async_method_call( + [&res, chassisId(std::string(chassisId)) ]( const boost::system::error_code error_code, const std::vector<std::pair< std::string, std::vector<std::pair<std::string, std::vector<std::string>>>>> &subtree) { if (error_code) { - res.json_value = {}; + res.jsonValue = {}; res.result(boost::beast::http::status::internal_server_error); res.end(); return; @@ -209,39 +209,39 @@ class Chassis : public Node { const std::vector<std::pair<std::string, std::vector<std::string>>> &connectionNames = object.second; - if (!boost::ends_with(path, chassis_id)) { + if (!boost::ends_with(path, chassisId)) { continue; } if (connectionNames.size() < 1) { - CROW_LOG_ERROR << "Only got " << connectionNames.size() - << " connection names"; + BMCWEB_LOG_ERROR << "Only got " << connectionNames.size() + << " Connection names"; continue; } const std::string connectionName = connectionNames[0].first; - crow::connections::system_bus->async_method_call( - [&res, chassis_id(std::string(chassis_id)) ]( + crow::connections::systemBus->async_method_call( + [&res, chassisId(std::string(chassisId)) ]( const boost::system::error_code error_code, const std::vector<std::pair<std::string, VariantType>> &propertiesList) { for (const std::pair<std::string, VariantType> &property : propertiesList) { const std::string *value = - mapbox::get_ptr<const std::string>(property.second); + mapbox::getPtr<const std::string>(property.second); if (value != nullptr) { - res.json_value[property.first] = *value; + res.jsonValue[property.first] = *value; } } - res.json_value["Name"] = chassis_id; - res.json_value["Id"] = chassis_id; - res.json_value["Thermal"] = { + res.jsonValue["Name"] = chassisId; + res.jsonValue["Id"] = chassisId; + res.jsonValue["Thermal"] = { {"@odata.id", - "/redfish/v1/Chassis/" + chassis_id + "/Thermal"}}; + "/redfish/v1/Chassis/" + chassisId + "/Thermal"}}; res.end(); }, connectionName, path, "org.freedesktop.DBus.Properties", "GetAll", "xyz.openbmc_project.Inventory.Decorator.Asset"); - // Found the connection we were looking for, return + // Found the Connection we were looking for, return return; } @@ -260,7 +260,7 @@ class Chassis : public Node { // Chassis Provider object // TODO(Pawel) consider move it to singleton - OnDemandChassisProvider chassis_provider; + OnDemandChassisProvider chassisProvider; }; // namespace redfish } // namespace redfish diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index c008be6b60..293e8020c0 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -69,11 +69,11 @@ struct IPv4AddressData { */ struct EthernetInterfaceData { const unsigned int *speed; - const bool *auto_neg; + const bool *autoNeg; const std::string *hostname; - const std::string *default_gateway; - const std::string *mac_address; - const unsigned int *vlan_id; + const std::string *defaultGateway; + const std::string *macAddress; + const unsigned int *vlanId; }; /** @@ -88,17 +88,17 @@ struct EthernetInterfaceData { class OnDemandEthernetProvider { private: // Consts that may have influence on EthernetProvider performance/memory usage - const size_t MAX_IPV4_ADDRESSES_PER_INTERFACE = 10; + const size_t maxIpV4AddressesPerInterface = 10; // Helper function that allows to extract GetAllPropertiesType from // GetManagedObjectsType, based on object path, and interface name const PropertiesMapType *extractInterfaceProperties( const sdbusplus::message::object_path &objpath, const std::string &interface, const GetManagedObjectsType &dbus_data) { - const auto &dbus_obj = dbus_data.find(objpath); - if (dbus_obj != dbus_data.end()) { - const auto &iface = dbus_obj->second.find(interface); - if (iface != dbus_obj->second.end()) { + const auto &dbusObj = dbus_data.find(objpath); + if (dbusObj != dbus_data.end()) { + const auto &iface = dbusObj->second.find(interface); + if (iface != dbusObj->second.end()) { return &iface->second; } } @@ -110,8 +110,8 @@ class OnDemandEthernetProvider { inline const PropertiesMapType *extractInterfaceProperties( const std::string &objpath, const std::string &interface, const GetManagedObjectsType &dbus_data) { - const auto &dbus_obj = sdbusplus::message::object_path{objpath}; - return extractInterfaceProperties(dbus_obj, interface, dbus_data); + const auto &dbusObj = sdbusplus::message::object_path{objpath}; + return extractInterfaceProperties(dbusObj, interface, dbus_data); } // Helper function that allows to get pointer to the property from @@ -121,7 +121,7 @@ class OnDemandEthernetProvider { const std::string &name) { const auto &property = properties.find(name); if (property != properties.end()) { - return mapbox::get_ptr<const T>(property->second); + return mapbox::getPtr<const T>(property->second); } return nullptr; } @@ -130,47 +130,47 @@ class OnDemandEthernetProvider { // Helper function that extracts data from several dbus objects and several // interfaces required by single ethernet interface instance - void extractEthernetInterfaceData(const std::string ðiface_id, + void extractEthernetInterfaceData(const std::string ðifaceId, const GetManagedObjectsType &dbus_data, EthernetInterfaceData ð_data) { // Extract data that contains MAC Address - const PropertiesMapType *mac_properties = extractInterfaceProperties( - "/xyz/openbmc_project/network/" + ethiface_id, + const PropertiesMapType *macProperties = extractInterfaceProperties( + "/xyz/openbmc_project/network/" + ethifaceId, "xyz.openbmc_project.Network.MACAddress", dbus_data); - if (mac_properties != nullptr) { - eth_data.mac_address = - extractProperty<std::string>(*mac_properties, "MACAddress"); + if (macProperties != nullptr) { + eth_data.macAddress = + extractProperty<std::string>(*macProperties, "MACAddress"); } - const PropertiesMapType *vlan_properties = extractInterfaceProperties( - "/xyz/openbmc_project/network/" + ethiface_id, + const PropertiesMapType *vlanProperties = extractInterfaceProperties( + "/xyz/openbmc_project/network/" + ethifaceId, "xyz.openbmc_project.Network.VLAN", dbus_data); - if (vlan_properties != nullptr) { - eth_data.vlan_id = extractProperty<unsigned int>(*vlan_properties, "Id"); + if (vlanProperties != nullptr) { + eth_data.vlanId = extractProperty<unsigned int>(*vlanProperties, "Id"); } // Extract data that contains link information (auto negotiation and speed) - const PropertiesMapType *eth_properties = extractInterfaceProperties( - "/xyz/openbmc_project/network/" + ethiface_id, + const PropertiesMapType *ethProperties = extractInterfaceProperties( + "/xyz/openbmc_project/network/" + ethifaceId, "xyz.openbmc_project.Network.EthernetInterface", dbus_data); - if (eth_properties != nullptr) { - eth_data.auto_neg = extractProperty<bool>(*eth_properties, "AutoNeg"); - eth_data.speed = extractProperty<unsigned int>(*eth_properties, "Speed"); + if (ethProperties != nullptr) { + eth_data.autoNeg = extractProperty<bool>(*ethProperties, "AutoNeg"); + eth_data.speed = extractProperty<unsigned int>(*ethProperties, "Speed"); } // Extract data that contains network config (HostName and DefaultGW) - const PropertiesMapType *config_properties = extractInterfaceProperties( + const PropertiesMapType *configProperties = extractInterfaceProperties( "/xyz/openbmc_project/network/config", "xyz.openbmc_project.Network.SystemConfiguration", dbus_data); - if (config_properties != nullptr) { + if (configProperties != nullptr) { eth_data.hostname = - extractProperty<std::string>(*config_properties, "HostName"); - eth_data.default_gateway = - extractProperty<std::string>(*config_properties, "DefaultGateway"); + extractProperty<std::string>(*configProperties, "HostName"); + eth_data.defaultGateway = + extractProperty<std::string>(*configProperties, "DefaultGateway"); } } @@ -186,11 +186,11 @@ class OnDemandEthernetProvider { } // Helper function that extracts data for single ethernet ipv4 address - void extractIPv4Data(const std::string ðiface_id, + void extractIPv4Data(const std::string ðifaceId, const GetManagedObjectsType &dbus_data, std::vector<IPv4AddressData> &ipv4_config) { const std::string pathStart = - "/xyz/openbmc_project/network/" + ethiface_id + "/ipv4/"; + "/xyz/openbmc_project/network/" + ethifaceId + "/ipv4/"; // Since there might be several IPv4 configurations aligned with // single ethernet interface, loop over all of them @@ -198,7 +198,7 @@ class OnDemandEthernetProvider { // Check if proper patter for object path appears if (boost::starts_with( static_cast<const std::string &>(objpath.first), - "/xyz/openbmc_project/network/" + ethiface_id + "/ipv4/")) { + "/xyz/openbmc_project/network/" + ethifaceId + "/ipv4/")) { // and get approrpiate interface const auto &interface = objpath.second.find("xyz.openbmc_project.Network.IP"); @@ -206,23 +206,23 @@ class OnDemandEthernetProvider { // Make a properties 'shortcut', to make everything more readable const PropertiesMapType &properties = interface->second; // Instance IPv4AddressData structure, and set as appropriate - IPv4AddressData ipv4_address; + IPv4AddressData ipv4Address; - ipv4_address.id = static_cast<const std::string &>(objpath.first) - .substr(pathStart.size()); + ipv4Address.id = static_cast<const std::string &>(objpath.first) + .substr(pathStart.size()); // IPv4 address - ipv4_address.address = + ipv4Address.address = extractProperty<std::string>(properties, "Address"); // IPv4 gateway - ipv4_address.gateway = + ipv4Address.gateway = extractProperty<std::string>(properties, "Gateway"); // Origin is kind of DBus object so fetch pointer... const std::string *origin = extractProperty<std::string>(properties, "Origin"); if (origin != nullptr) { - ipv4_address.origin = + ipv4Address.origin = translateAddressOriginBetweenDBusAndRedfish(origin, true, true); } @@ -231,18 +231,18 @@ class OnDemandEthernetProvider { extractProperty<uint8_t>(properties, "PrefixLength"); if (mask != nullptr) { // convert it to the string - ipv4_address.netmask = getNetmask(*mask); + ipv4Address.netmask = getNetmask(*mask); } // Attach IPv4 only if address is present - if (ipv4_address.address != nullptr) { - // Check if given address is local, or global - if (boost::starts_with(*ipv4_address.address, "169.254")) { - ipv4_address.global = false; + if (ipv4Address.address != nullptr) { + // Check if given addres is local, or global + if (boost::starts_with(*ipv4Address.address, "169.254")) { + ipv4Address.global = false; } else { - ipv4_address.global = true; + ipv4Address.global = true; } - ipv4_config.emplace_back(std::move(ipv4_address)); + ipv4_config.emplace_back(std::move(ipv4Address)); } } } @@ -270,7 +270,7 @@ class OnDemandEthernetProvider { template <typename CallbackFunc> void createVlan(const std::string &ifaceId, const uint64_t &inputVlanId, CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( callback, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "xyz.openbmc_project.Network.VLAN.Create", "VLAN", ifaceId, static_cast<uint32_t>(inputVlanId)); @@ -289,7 +289,7 @@ class OnDemandEthernetProvider { static void changeVlanId(const std::string &ifaceId, const uint32_t &inputVlanId, CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( callback, "xyz.openbmc_project.Network", std::string("/xyz/openbmc_project/network/") + ifaceId, "org.freedesktop.DBus.Properties", "Set", @@ -377,7 +377,7 @@ class OnDemandEthernetProvider { * @brief Changes IPv4 address type property (Address, Gateway) * * @param[in] ifaceId Id of interface whose IP should be modified - * @param[in] ipIdx Index of IP in input array that should be modified + * @param[in] ipIdx index of IP in input array that should be modified * @param[in] ipHash DBus Hash id of modified IP * @param[in] name Name of field in JSON representation * @param[in] newValue New value that should be written @@ -397,14 +397,14 @@ class OnDemandEthernetProvider { ](const boost::system::error_code ec) { if (ec) { messages::addMessageToJson( - asyncResp->res.json_value, messages::internalError(), + asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses/" + std::to_string(ipIdx) + "/" + name); } else { - asyncResp->res.json_value["IPv4Addresses"][ipIdx][name] = newValue; + asyncResp->res.jsonValue["IPv4Addresses"][ipIdx][name] = newValue; } }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( std::move(callback), "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash, "org.freedesktop.DBus.Properties", "Set", @@ -416,7 +416,7 @@ class OnDemandEthernetProvider { * @brief Changes IPv4 address origin property * * @param[in] ifaceId Id of interface whose IP should be modified - * @param[in] ipIdx Index of IP in input array that should be modified + * @param[in] ipIdx index of IP in input array that should be modified * @param[in] ipHash DBus Hash id of modified IP * @param[in] newValue New value in Redfish format * @param[in] newValueDbus New value in D-Bus format @@ -434,15 +434,15 @@ class OnDemandEthernetProvider { newValue{std::move(newValue)} ](const boost::system::error_code ec) { if (ec) { messages::addMessageToJson( - asyncResp->res.json_value, messages::internalError(), + asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses/" + std::to_string(ipIdx) + "/AddressOrigin"); } else { - asyncResp->res.json_value["IPv4Addresses"][ipIdx]["AddressOrigin"] = + asyncResp->res.jsonValue["IPv4Addresses"][ipIdx]["AddressOrigin"] = newValue; } }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( std::move(callback), "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash, "org.freedesktop.DBus.Properties", "Set", @@ -454,7 +454,7 @@ class OnDemandEthernetProvider { * @brief Modifies SubnetMask for given IP * * @param[in] ifaceId Id of interface whose IP should be modified - * @param[in] ipIdx Index of IP in input array that should be modified + * @param[in] ipIdx index of IP in input array that should be modified * @param[in] ipHash DBus Hash id of modified IP * @param[in] newValueStr Mask in dot notation as string * @param[in] newValue Mask as PrefixLength in bitcount @@ -471,15 +471,15 @@ class OnDemandEthernetProvider { ](const boost::system::error_code ec) { if (ec) { messages::addMessageToJson( - asyncResp->res.json_value, messages::internalError(), + asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses/" + std::to_string(ipIdx) + "/SubnetMask"); } else { - asyncResp->res.json_value["IPv4Addresses"][ipIdx]["SubnetMask"] = + asyncResp->res.jsonValue["IPv4Addresses"][ipIdx]["SubnetMask"] = newValueStr; } }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( std::move(callback), "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash, "org.freedesktop.DBus.Properties", "Set", @@ -497,7 +497,7 @@ class OnDemandEthernetProvider { */ template <typename CallbackFunc> static void disableVlan(const std::string &ifaceId, CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( callback, "xyz.openbmc_project.Network", std::string("/xyz/openbmc_project/network/") + ifaceId, "xyz.openbmc_project.Object.Delete", "Delete"); @@ -513,7 +513,7 @@ class OnDemandEthernetProvider { */ template <typename CallbackFunc> void setHostName(const std::string &newHostname, CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( callback, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/config", "org.freedesktop.DBus.Properties", "Set", @@ -525,7 +525,7 @@ class OnDemandEthernetProvider { * @brief Deletes given IPv4 * * @param[in] ifaceId Id of interface whose IP should be deleted - * @param[in] ipIdx Index of IP in input array that should be deleted + * @param[in] ipIdx index of IP in input array that should be deleted * @param[in] ipHash DBus Hash id of IP that should be deleted * @param[io] asyncResp Response object that will be returned to client * @@ -534,15 +534,15 @@ class OnDemandEthernetProvider { void deleteIPv4(const std::string &ifaceId, const std::string &ipHash, unsigned int ipIdx, const std::shared_ptr<AsyncResp> &asyncResp) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [ ipIdx{std::move(ipIdx)}, asyncResp{std::move(asyncResp)} ]( const boost::system::error_code ec) { if (ec) { messages::addMessageToJson( - asyncResp->res.json_value, messages::internalError(), + asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses/" + std::to_string(ipIdx) + "/"); } else { - asyncResp->res.json_value["IPv4Addresses"][ipIdx] = nullptr; + asyncResp->res.jsonValue["IPv4Addresses"][ipIdx] = nullptr; } }, "xyz.openbmc_project.Network", @@ -554,7 +554,7 @@ class OnDemandEthernetProvider { * @brief Creates IPv4 with given data * * @param[in] ifaceId Id of interface whose IP should be deleted - * @param[in] ipIdx Index of IP in input array that should be deleted + * @param[in] ipIdx index of IP in input array that should be deleted * @param[in] ipHash DBus Hash id of IP that should be deleted * @param[io] asyncResp Response object that will be returned to client * @@ -569,12 +569,12 @@ class OnDemandEthernetProvider { ](const boost::system::error_code ec) { if (ec) { messages::addMessageToJson( - asyncResp->res.json_value, messages::internalError(), + asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses/" + std::to_string(ipIdx) + "/"); } }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( std::move(createIpHandler), "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/" + ifaceId, "xyz.openbmc_project.Network.IP.Create", "IP", @@ -634,23 +634,23 @@ class OnDemandEthernetProvider { * Function that retrieves all properties for given Ethernet Interface * Object * from EntityManager Network Manager - * @param ethiface_id a eth interface id to query on DBus + * @param ethifaceId a eth interface id to query on DBus * @param callback a function that shall be called to convert Dbus output * into JSON */ template <typename CallbackFunc> - void getEthernetIfaceData(const std::string ðiface_id, + void getEthernetIfaceData(const std::string ðifaceId, CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [ - this, ethiface_id{std::move(ethiface_id)}, + this, ethifaceId{std::move(ethifaceId)}, callback{std::move(callback)} ](const boost::system::error_code error_code, const GetManagedObjectsType &resp) { - EthernetInterfaceData eth_data{}; - std::vector<IPv4AddressData> ipv4_data; - ipv4_data.reserve(MAX_IPV4_ADDRESSES_PER_INTERFACE); + EthernetInterfaceData ethData{}; + std::vector<IPv4AddressData> ipv4Data; + ipv4Data.reserve(maxIpV4AddressesPerInterface); if (error_code) { // Something wrong on DBus, the error_code is not important at @@ -658,31 +658,31 @@ class OnDemandEthernetProvider { // size of vector may vary depending on information from Network // Manager, and empty output could not be treated same way as // error. - callback(false, eth_data, ipv4_data); + callback(false, ethData, ipv4Data); return; } // Find interface - if (resp.find("/xyz/openbmc_project/network/" + ethiface_id) == + if (resp.find("/xyz/openbmc_project/network/" + ethifaceId) == resp.end()) { // Interface has not been found - callback(false, eth_data, ipv4_data); + callback(false, ethData, ipv4Data); return; } - extractEthernetInterfaceData(ethiface_id, resp, eth_data); - extractIPv4Data(ethiface_id, resp, ipv4_data); + extractEthernetInterfaceData(ethifaceId, resp, ethData); + extractIPv4Data(ethifaceId, resp, ipv4Data); // Fix global GW - for (IPv4AddressData &ipv4 : ipv4_data) { + for (IPv4AddressData &ipv4 : ipv4Data) { if ((ipv4.global) && ((ipv4.gateway == nullptr) || (*ipv4.gateway == "0.0.0.0"))) { - ipv4.gateway = eth_data.default_gateway; + ipv4.gateway = ethData.defaultGateway; } } // Finally make a callback with usefull data - callback(true, eth_data, ipv4_data); + callback(true, ethData, ipv4Data); }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); @@ -696,20 +696,20 @@ class OnDemandEthernetProvider { */ template <typename CallbackFunc> void getEthernetIfaceList(CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [ this, callback{std::move(callback)} ]( const boost::system::error_code error_code, GetManagedObjectsType &resp) { // Callback requires vector<string> to retrieve all available ethernet // interfaces - std::vector<std::string> iface_list; - iface_list.reserve(resp.size()); + std::vector<std::string> ifaceList; + ifaceList.reserve(resp.size()); if (error_code) { // Something wrong on DBus, the error_code is not important at this // moment, just return success=false, and empty output. Since size // of vector may vary depending on information from Network Manager, // and empty output could not be treated same way as error. - callback(false, iface_list); + callback(false, ifaceList); return; } @@ -722,18 +722,18 @@ class OnDemandEthernetProvider { if (interface.first == "xyz.openbmc_project.Network.EthernetInterface") { // Cut out everyting until last "/", ... - const std::string &iface_id = + const std::string &ifaceId = static_cast<const std::string &>(objpath.first); - std::size_t last_pos = iface_id.rfind("/"); - if (last_pos != std::string::npos) { + std::size_t lastPos = ifaceId.rfind("/"); + if (lastPos != std::string::npos) { // and put it into output vector. - iface_list.emplace_back(iface_id.substr(last_pos + 1)); + ifaceList.emplace_back(ifaceId.substr(lastPos + 1)); } } } } - // Finally make a callback with useful data - callback(true, iface_list); + // Finally make a callback with usefull data + callback(true, ifaceList); }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); @@ -773,39 +773,38 @@ class EthernetCollection : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // TODO(Pawel) this shall be parametrized call to get EthernetInterfaces for // any Manager, not only hardcoded 'openbmc'. - std::string manager_id = "openbmc"; + std::string managerId = "openbmc"; - // Get eth interface list, and call the below callback for JSON preparation - ethernet_provider.getEthernetIfaceList( - [&, manager_id{std::move(manager_id)} ]( - const bool &success, const std::vector<std::string> &iface_list) { - if (success) { - nlohmann::json iface_array = nlohmann::json::array(); - for (const std::string &iface_item : iface_list) { - iface_array.push_back( - {{"@odata.id", "/redfish/v1/Managers/" + manager_id + - "/EthernetInterfaces/" + iface_item}}); - } - Node::json["Members"] = iface_array; - Node::json["Members@odata.count"] = iface_array.size(); - Node::json["@odata.id"] = - "/redfish/v1/Managers/" + manager_id + "/EthernetInterfaces"; - res.json_value = Node::json; - } else { - // No success, best what we can do is return INTERNALL ERROR - res.result(boost::beast::http::status::internal_server_error); - } - res.end(); - }); + // get eth interface list, and call the below callback for JSON preparation + ethernetProvider.getEthernetIfaceList([&, managerId{std::move(managerId)} ]( + const bool &success, const std::vector<std::string> &iface_list) { + if (success) { + nlohmann::json ifaceArray = nlohmann::json::array(); + for (const std::string &ifaceItem : iface_list) { + ifaceArray.push_back( + {{"@odata.id", "/redfish/v1/Managers/" + managerId + + "/EthernetInterfaces/" + ifaceItem}}); + } + Node::json["Members"] = ifaceArray; + Node::json["Members@odata.count"] = ifaceArray.size(); + Node::json["@odata.id"] = + "/redfish/v1/Managers/" + managerId + "/EthernetInterfaces"; + res.jsonValue = Node::json; + } else { + // No success, best what we can do is return INTERNALL ERROR + res.result(boost::beast::http::status::internal_server_error); + } + res.end(); + }); } // Ethernet Provider object // TODO(Pawel) consider move it to singleton - OnDemandEthernetProvider ethernet_provider; + OnDemandEthernetProvider ethernetProvider; }; /** @@ -845,7 +844,7 @@ class EthernetInterface : public Node { const std::shared_ptr<AsyncResp> &asyncResp) { if (!input.is_object()) { messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueTypeError(input.dump(), "VLAN"), pathPrefix); return; } @@ -853,8 +852,8 @@ class EthernetInterface : public Node { const std::string pathStart = (pathPrefix == "/") ? "" : pathPrefix; nlohmann::json ¶msJson = (pathPrefix == "/") - ? asyncResp->res.json_value - : asyncResp->res.json_value[nlohmann::json_pointer<nlohmann::json>( + ? asyncResp->res.jsonValue + : asyncResp->res.jsonValue[nlohmann::json_pointer<nlohmann::json>( pathPrefix)]; bool inputVlanEnabled; uint64_t inputVlanId; @@ -862,11 +861,11 @@ class EthernetInterface : public Node { json_util::Result inputVlanEnabledState = json_util::getBool( "VLANEnable", input, inputVlanEnabled, static_cast<int>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, std::string(pathStart + "/VLANEnable")); + asyncResp->res.jsonValue, std::string(pathStart + "/VLANEnable")); json_util::Result inputVlanIdState = json_util::getUnsigned( "VLANId", input, inputVlanId, static_cast<int>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, std::string(pathStart + "/VLANId")); + asyncResp->res.jsonValue, std::string(pathStart + "/VLANId")); bool inputInvalid = false; // Do not proceed if fields in VLAN object were of wrong type @@ -876,10 +875,10 @@ class EthernetInterface : public Node { } // Verify input - if (eth_data.vlan_id == nullptr) { + if (eth_data.vlanId == nullptr) { // This interface is not a VLAN. Cannot do anything with it // TODO(kkowalsk) Change this message - messages::addMessageToJson(asyncResp->res.json_value, + messages::addMessageToJson(asyncResp->res.jsonValue, messages::propertyMissing("VLANEnable"), pathPrefix); @@ -891,7 +890,7 @@ class EthernetInterface : public Node { } if (inputVlanIdState == json_util::Result::NOT_EXIST) { - inputVlanId = *eth_data.vlan_id; + inputVlanId = *eth_data.vlanId; } } @@ -901,7 +900,7 @@ class EthernetInterface : public Node { } // VLAN is configured on the interface - if (inputVlanEnabled == true && inputVlanId != *eth_data.vlan_id) { + if (inputVlanEnabled == true && inputVlanId != *eth_data.vlanId) { // Change VLAN Id paramsJson["VLANId"] = inputVlanId; OnDemandEthernetProvider::changeVlanId( @@ -909,7 +908,7 @@ class EthernetInterface : public Node { [&, asyncResp, pathPrefx{std::move(pathPrefix)} ]( const boost::system::error_code ec) { if (ec) { - messages::addMessageToJson(asyncResp->res.json_value, + messages::addMessageToJson(asyncResp->res.jsonValue, messages::internalError(), pathPrefix); } else { paramsJson["VLANEnable"] = true; @@ -921,7 +920,7 @@ class EthernetInterface : public Node { ifaceId, [&, asyncResp, pathPrefx{std::move(pathPrefix)} ]( const boost::system::error_code ec) { if (ec) { - messages::addMessageToJson(asyncResp->res.json_value, + messages::addMessageToJson(asyncResp->res.jsonValue, messages::internalError(), pathPrefix); } else { paramsJson["VLANEnable"] = false; @@ -939,21 +938,21 @@ class EthernetInterface : public Node { if (eth_data.hostname == nullptr || newHostname != *eth_data.hostname) { // Change hostname - ethernet_provider.setHostName( + ethernetProvider.setHostName( newHostname, [asyncResp, newHostname](const boost::system::error_code ec) { if (ec) { - messages::addMessageToJson(asyncResp->res.json_value, + messages::addMessageToJson(asyncResp->res.jsonValue, messages::internalError(), "/HostName"); } else { - asyncResp->res.json_value["HostName"] = newHostname; + asyncResp->res.jsonValue["HostName"] = newHostname; } }); } } else { messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueTypeError(input.dump(), "HostName"), "/HostName"); } @@ -964,7 +963,7 @@ class EthernetInterface : public Node { const std::shared_ptr<AsyncResp> &asyncResp) { if (!input.is_array()) { messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueTypeError(input.dump(), "IPv4Addresses"), "/IPv4Addresses"); return; @@ -974,7 +973,7 @@ class EthernetInterface : public Node { if (input.size() < ipv4_data.size()) { // TODO(kkowalsk) This should be a message indicating that not enough // data has been provided - messages::addMessageToJson(asyncResp->res.json_value, + messages::addMessageToJson(asyncResp->res.jsonValue, messages::internalError(), "/IPv4Addresses"); return; } @@ -996,7 +995,7 @@ class EthernetInterface : public Node { if (!input[entryIdx].is_object() && !input[entryIdx].is_null()) { // Invalid object type messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueTypeError(input[entryIdx].dump(), "IPv4Address"), "/IPv4Addresses/" + std::to_string(entryIdx)); @@ -1008,22 +1007,22 @@ class EthernetInterface : public Node { addressFieldState = json_util::getString( "Address", input[entryIdx], addressFieldValue, static_cast<uint8_t>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, + asyncResp->res.jsonValue, "/IPv4Addresses/" + std::to_string(entryIdx) + "/Address"); subnetMaskFieldState = json_util::getString( "SubnetMask", input[entryIdx], subnetMaskFieldValue, static_cast<uint8_t>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, + asyncResp->res.jsonValue, "/IPv4Addresses/" + std::to_string(entryIdx) + "/SubnetMask"); addressOriginFieldState = json_util::getString( "AddressOrigin", input[entryIdx], addressOriginFieldValue, static_cast<uint8_t>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, + asyncResp->res.jsonValue, "/IPv4Addresses/" + std::to_string(entryIdx) + "/AddressOrigin"); gatewayFieldState = json_util::getString( "Gateway", input[entryIdx], gatewayFieldValue, static_cast<uint8_t>(json_util::MessageSetting::TYPE_ERROR), - asyncResp->res.json_value, + asyncResp->res.jsonValue, "/IPv4Addresses/" + std::to_string(entryIdx) + "/Gateway"); if (addressFieldState == json_util::Result::WRONG_TYPE || @@ -1034,45 +1033,45 @@ class EthernetInterface : public Node { } if (addressFieldState == json_util::Result::SUCCESS && - !ethernet_provider.ipv4VerifyIpAndGetBitcount(*addressFieldValue)) { + !ethernetProvider.ipv4VerifyIpAndGetBitcount(*addressFieldValue)) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueFormatError(*addressFieldValue, "Address"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/Address"); } if (subnetMaskFieldState == json_util::Result::SUCCESS && - !ethernet_provider.ipv4VerifyIpAndGetBitcount( + !ethernetProvider.ipv4VerifyIpAndGetBitcount( *subnetMaskFieldValue, &subnetMaskAsPrefixLength)) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueFormatError(*subnetMaskFieldValue, "SubnetMask"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/SubnetMask"); } - // Get Address origin in proper format + // get Address origin in proper format addressOriginInDBusFormat = - ethernet_provider.translateAddressOriginBetweenDBusAndRedfish( + ethernetProvider.translateAddressOriginBetweenDBusAndRedfish( addressOriginFieldValue, true, false); if (addressOriginFieldState == json_util::Result::SUCCESS && addressOriginInDBusFormat.empty()) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueNotInList(*addressOriginFieldValue, "AddressOrigin"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/AddressOrigin"); } if (gatewayFieldState == json_util::Result::SUCCESS && - !ethernet_provider.ipv4VerifyIpAndGetBitcount(*gatewayFieldValue)) { + !ethernetProvider.ipv4VerifyIpAndGetBitcount(*gatewayFieldValue)) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyValueFormatError(*gatewayFieldValue, "Gateway"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/Gateway"); } @@ -1085,28 +1084,27 @@ class EthernetInterface : public Node { } if (entryIdx >= ipv4_data.size()) { - asyncResp->res.json_value["IPv4Addresses"][entryIdx] = input[entryIdx]; + asyncResp->res.jsonValue["IPv4Addresses"][entryIdx] = input[entryIdx]; // Verify that all field were provided if (addressFieldState == json_util::Result::NOT_EXIST) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, messages::propertyMissing("Address"), + asyncResp->res.jsonValue, messages::propertyMissing("Address"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/Address"); } if (subnetMaskFieldState == json_util::Result::NOT_EXIST) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, - messages::propertyMissing("SubnetMask"), + asyncResp->res.jsonValue, messages::propertyMissing("SubnetMask"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/SubnetMask"); } if (addressOriginFieldState == json_util::Result::NOT_EXIST) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, + asyncResp->res.jsonValue, messages::propertyMissing("AddressOrigin"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/AddressOrigin"); } @@ -1114,7 +1112,7 @@ class EthernetInterface : public Node { if (gatewayFieldState == json_util::Result::NOT_EXIST) { errorDetected = true; messages::addMessageToJson( - asyncResp->res.json_value, messages::propertyMissing("Gateway"), + asyncResp->res.jsonValue, messages::propertyMissing("Gateway"), "/IPv4Addresses/" + std::to_string(entryIdx) + "/Gateway"); } @@ -1126,15 +1124,15 @@ class EthernetInterface : public Node { } // Create IPv4 with provided data - ethernet_provider.createIPv4( - ifaceId, entryIdx, subnetMaskAsPrefixLength, *gatewayFieldValue, - *addressFieldValue, asyncResp); + ethernetProvider.createIPv4(ifaceId, entryIdx, subnetMaskAsPrefixLength, + *gatewayFieldValue, *addressFieldValue, + asyncResp); } else { // Existing object that should be modified/deleted/remain unchanged if (input[entryIdx].is_null()) { // Object should be deleted - ethernet_provider.deleteIPv4(ifaceId, ipv4_data[entryIdx].id, - entryIdx, asyncResp); + ethernetProvider.deleteIPv4(ifaceId, ipv4_data[entryIdx].id, entryIdx, + asyncResp); } else if (input[entryIdx].is_object()) { if (input[entryIdx].size() == 0) { // Object shall remain unchanged @@ -1145,21 +1143,21 @@ class EthernetInterface : public Node { if (addressFieldState == json_util::Result::SUCCESS && ipv4_data[entryIdx].address != nullptr && *ipv4_data[entryIdx].address != *addressFieldValue) { - ethernet_provider.changeIPv4AddressProperty( + ethernetProvider.changeIPv4AddressProperty( ifaceId, entryIdx, ipv4_data[entryIdx].id, "Address", *addressFieldValue, asyncResp); } if (subnetMaskFieldState == json_util::Result::SUCCESS && ipv4_data[entryIdx].netmask != *subnetMaskFieldValue) { - ethernet_provider.changeIPv4SubnetMaskProperty( + ethernetProvider.changeIPv4SubnetMaskProperty( ifaceId, entryIdx, ipv4_data[entryIdx].id, *subnetMaskFieldValue, subnetMaskAsPrefixLength, asyncResp); } if (addressOriginFieldState == json_util::Result::SUCCESS && ipv4_data[entryIdx].origin != *addressFieldValue) { - ethernet_provider.changeIPv4Origin( + ethernetProvider.changeIPv4Origin( ifaceId, entryIdx, ipv4_data[entryIdx].id, *addressOriginFieldValue, addressOriginInDBusFormat, asyncResp); } @@ -1167,7 +1165,7 @@ class EthernetInterface : public Node { if (gatewayFieldState == json_util::Result::SUCCESS && ipv4_data[entryIdx].gateway != nullptr && *ipv4_data[entryIdx].gateway != *gatewayFieldValue) { - ethernet_provider.changeIPv4AddressProperty( + ethernetProvider.changeIPv4AddressProperty( ifaceId, entryIdx, ipv4_data[entryIdx].id, "Gateway", *gatewayFieldValue, asyncResp); } @@ -1177,63 +1175,63 @@ class EthernetInterface : public Node { } nlohmann::json parseInterfaceData( - const std::string &iface_id, const EthernetInterfaceData ð_data, + const std::string &ifaceId, const EthernetInterfaceData ð_data, const std::vector<IPv4AddressData> &ipv4_data) { // Copy JSON object to avoid race condition - nlohmann::json json_response(Node::json); + nlohmann::json jsonResponse(Node::json); // Fill out obvious data... - json_response["Id"] = iface_id; - json_response["@odata.id"] = - "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + iface_id; + jsonResponse["Id"] = ifaceId; + jsonResponse["@odata.id"] = + "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + ifaceId; // ... then the one from DBus, regarding eth iface... - if (eth_data.speed != nullptr) json_response["SpeedMbps"] = *eth_data.speed; + if (eth_data.speed != nullptr) jsonResponse["SpeedMbps"] = *eth_data.speed; - if (eth_data.mac_address != nullptr) - json_response["MACAddress"] = *eth_data.mac_address; + if (eth_data.macAddress != nullptr) + jsonResponse["MACAddress"] = *eth_data.macAddress; if (eth_data.hostname != nullptr) - json_response["HostName"] = *eth_data.hostname; + jsonResponse["HostName"] = *eth_data.hostname; - if (eth_data.vlan_id != nullptr) { - nlohmann::json &vlanObj = json_response["VLAN"]; + if (eth_data.vlanId != nullptr) { + nlohmann::json &vlanObj = jsonResponse["VLAN"]; vlanObj["VLANEnable"] = true; - vlanObj["VLANId"] = *eth_data.vlan_id; + vlanObj["VLANId"] = *eth_data.vlanId; } else { - nlohmann::json &vlanObj = json_response["VLANs"]; + nlohmann::json &vlanObj = jsonResponse["VLANs"]; vlanObj["@odata.id"] = - "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + iface_id + + "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + ifaceId + "/VLANs"; } // ... at last, check if there are IPv4 data and prepare appropriate // collection if (ipv4_data.size() > 0) { - nlohmann::json ipv4_array = nlohmann::json::array(); - for (auto &ipv4_config : ipv4_data) { - nlohmann::json json_ipv4; - if (ipv4_config.address != nullptr) { - json_ipv4["Address"] = *ipv4_config.address; - if (ipv4_config.gateway != nullptr) - json_ipv4["Gateway"] = *ipv4_config.gateway; - - json_ipv4["AddressOrigin"] = ipv4_config.origin; - json_ipv4["SubnetMask"] = ipv4_config.netmask; - - ipv4_array.push_back(std::move(json_ipv4)); + nlohmann::json ipv4Array = nlohmann::json::array(); + for (auto &ipv4Config : ipv4_data) { + nlohmann::json jsonIpv4; + if (ipv4Config.address != nullptr) { + jsonIpv4["Address"] = *ipv4Config.address; + if (ipv4Config.gateway != nullptr) + jsonIpv4["Gateway"] = *ipv4Config.gateway; + + jsonIpv4["AddressOrigin"] = ipv4Config.origin; + jsonIpv4["SubnetMask"] = ipv4Config.netmask; + + ipv4Array.push_back(std::move(jsonIpv4)); } } - json_response["IPv4Addresses"] = std::move(ipv4_array); + jsonResponse["IPv4Addresses"] = std::move(ipv4Array); } - return json_response; + return jsonResponse; } /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // TODO(Pawel) this shall be parametrized call (two params) to get // EthernetInterfaces for any Manager, not only hardcoded 'openbmc'. @@ -1245,30 +1243,30 @@ class EthernetInterface : public Node { return; } - const std::string &iface_id = params[0]; + const std::string &ifaceId = params[0]; - // Get single eth interface data, and call the below callback for JSON + // get single eth interface data, and call the below callback for JSON // preparation - ethernet_provider.getEthernetIfaceData( - iface_id, [&, iface_id](const bool &success, - const EthernetInterfaceData ð_data, - const std::vector<IPv4AddressData> &ipv4_data) { + ethernetProvider.getEthernetIfaceData( + ifaceId, + [&, ifaceId](const bool &success, const EthernetInterfaceData ð_data, + const std::vector<IPv4AddressData> &ipv4_data) { if (success) { - res.json_value = parseInterfaceData(iface_id, eth_data, ipv4_data); + res.jsonValue = parseInterfaceData(ifaceId, eth_data, ipv4_data); } else { // ... otherwise return error // TODO(Pawel)consider distinguish between non existing object, and // other errors messages::addMessageToErrorJson( - res.json_value, - messages::resourceNotFound("EthernetInterface", iface_id)); + res.jsonValue, + messages::resourceNotFound("EthernetInterface", ifaceId)); res.result(boost::beast::http::status::not_found); } res.end(); }); } - void doPatch(crow::response &res, const crow::request &req, + void doPatch(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // TODO(Pawel) this shall be parametrized call (two params) to get // EthernetInterfaces for any Manager, not only hardcoded 'openbmc'. @@ -1280,7 +1278,7 @@ class EthernetInterface : public Node { return; } - const std::string &iface_id = params[0]; + const std::string &ifaceId = params[0]; nlohmann::json patchReq; @@ -1288,27 +1286,26 @@ class EthernetInterface : public Node { return; } - // Get single eth interface data, and call the below callback for JSON + // get single eth interface data, and call the below callback for JSON // preparation - ethernet_provider.getEthernetIfaceData( - iface_id, - [&, iface_id, patchReq = std::move(patchReq) ]( - const bool &success, const EthernetInterfaceData ð_data, - const std::vector<IPv4AddressData> &ipv4_data) { + ethernetProvider.getEthernetIfaceData( + ifaceId, [&, ifaceId, patchReq = std::move(patchReq) ]( + const bool &success, const EthernetInterfaceData ð_data, + const std::vector<IPv4AddressData> &ipv4_data) { if (!success) { // ... otherwise return error // TODO(Pawel)consider distinguish between non existing object, and // other errors messages::addMessageToErrorJson( - res.json_value, - messages::resourceNotFound("VLAN Network Interface", iface_id)); + res.jsonValue, + messages::resourceNotFound("VLAN Network Interface", ifaceId)); res.result(boost::beast::http::status::not_found); res.end(); return; } - res.json_value = parseInterfaceData(iface_id, eth_data, ipv4_data); + res.jsonValue = parseInterfaceData(ifaceId, eth_data, ipv4_data); std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); @@ -1316,30 +1313,29 @@ class EthernetInterface : public Node { for (auto propertyIt = patchReq.begin(); propertyIt != patchReq.end(); ++propertyIt) { if (propertyIt.key() == "VLAN") { - handleVlanPatch(iface_id, propertyIt.value(), eth_data, "/VLAN", + handleVlanPatch(ifaceId, propertyIt.value(), eth_data, "/VLAN", asyncResp); } else if (propertyIt.key() == "HostName") { handleHostnamePatch(propertyIt.value(), eth_data, asyncResp); } else if (propertyIt.key() == "IPv4Addresses") { - handleIPv4Patch(iface_id, propertyIt.value(), ipv4_data, + handleIPv4Patch(ifaceId, propertyIt.value(), ipv4_data, asyncResp); } else if (propertyIt.key() == "IPv6Addresses") { // TODO(kkowalsk) IPv6 Not supported on D-Bus yet messages::addMessageToJsonRoot( - res.json_value, + res.jsonValue, messages::propertyNotWritable(propertyIt.key())); } else { - auto fieldInJsonIt = res.json_value.find(propertyIt.key()); + auto fieldInJsonIt = res.jsonValue.find(propertyIt.key()); - if (fieldInJsonIt == res.json_value.end()) { + if (fieldInJsonIt == res.jsonValue.end()) { // Field not in scope of defined fields messages::addMessageToJsonRoot( - res.json_value, - messages::propertyUnknown(propertyIt.key())); + res.jsonValue, messages::propertyUnknown(propertyIt.key())); } else if (*fieldInJsonIt != *propertyIt) { // User attempted to modify non-writable field messages::addMessageToJsonRoot( - res.json_value, + res.jsonValue, messages::propertyNotWritable(propertyIt.key())); } } @@ -1349,7 +1345,7 @@ class EthernetInterface : public Node { // Ethernet Provider object // TODO(Pawel) consider move it to singleton - OnDemandEthernetProvider ethernet_provider; + OnDemandEthernetProvider ethernetProvider; }; class VlanNetworkInterfaceCollection; @@ -1388,35 +1384,35 @@ class VlanNetworkInterface : public Node { private: nlohmann::json parseInterfaceData( - const std::string &parent_iface_id, const std::string &iface_id, + const std::string &parent_ifaceId, const std::string &ifaceId, const EthernetInterfaceData ð_data, const std::vector<IPv4AddressData> &ipv4_data) { // Copy JSON object to avoid race condition - nlohmann::json json_response(Node::json); + nlohmann::json jsonResponse(Node::json); - if (eth_data.vlan_id == nullptr) { + if (eth_data.vlanId == nullptr) { // Interface not a VLAN - abort - messages::addMessageToErrorJson(json_response, messages::internalError()); - return json_response; + messages::addMessageToErrorJson(jsonResponse, messages::internalError()); + return jsonResponse; } // Fill out obvious data... - json_response["Id"] = iface_id; - json_response["@odata.id"] = - "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + parent_iface_id + - "/VLANs/" + iface_id; + jsonResponse["Id"] = ifaceId; + jsonResponse["@odata.id"] = + "/redfish/v1/Managers/openbmc/EthernetInterfaces/" + parent_ifaceId + + "/VLANs/" + ifaceId; - json_response["VLANEnable"] = true; - json_response["VLANId"] = *eth_data.vlan_id; + jsonResponse["VLANEnable"] = true; + jsonResponse["VLANId"] = *eth_data.vlanId; - return json_response; + return jsonResponse; } - bool verifyNames(crow::response &res, const std::string &parent, + bool verifyNames(crow::Response &res, const std::string &parent, const std::string &iface) { if (!boost::starts_with(iface, parent + "_")) { messages::addMessageToErrorJson( - res.json_value, + res.jsonValue, messages::resourceNotFound("VLAN Network Interface", iface)); res.result(boost::beast::http::status::not_found); res.end(); @@ -1430,7 +1426,7 @@ class VlanNetworkInterface : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // TODO(Pawel) this shall be parametrized call (two params) to get // EthernetInterfaces for any Manager, not only hardcoded 'openbmc'. @@ -1442,33 +1438,33 @@ class VlanNetworkInterface : public Node { return; } - const std::string &parent_iface_id = params[0]; - const std::string &iface_id = params[1]; + const std::string &parentIfaceId = params[0]; + const std::string &ifaceId = params[1]; // Get single eth interface data, and call the below callback for JSON // preparation - ethernet_provider.getEthernetIfaceData( - iface_id, - [&, parent_iface_id, iface_id]( + ethernetProvider.getEthernetIfaceData( + ifaceId, + [&, parentIfaceId, ifaceId]( const bool &success, const EthernetInterfaceData ð_data, const std::vector<IPv4AddressData> &ipv4_data) { - if (success) { - res.json_value = parseInterfaceData(parent_iface_id, iface_id, + if (success && eth_data.vlanId != nullptr) { + res.jsonValue = parseInterfaceData(parentIfaceId, ifaceId, eth_data, ipv4_data); } else { // ... otherwise return error // TODO(Pawel)consider distinguish between non existing object, and // other errors messages::addMessageToErrorJson( - res.json_value, - messages::resourceNotFound("VLAN Network Interface", iface_id)); + res.jsonValue, + messages::resourceNotFound("VLAN Network Interface", ifaceId)); res.result(boost::beast::http::status::not_found); } res.end(); }); } - void doPatch(crow::response &res, const crow::request &req, + void doPatch(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { if (params.size() != 2) { res.result(boost::beast::http::status::internal_server_error); @@ -1476,10 +1472,10 @@ class VlanNetworkInterface : public Node { return; } - const std::string &parent_iface_id = params[0]; - const std::string &iface_id = params[1]; + const std::string &parent_ifaceId = params[0]; + const std::string &ifaceId = params[1]; - if (!verifyNames(res, parent_iface_id, iface_id)) { + if (!verifyNames(res, parent_ifaceId, ifaceId)) { return; } @@ -1491,9 +1487,9 @@ class VlanNetworkInterface : public Node { // Get single eth interface data, and call the below callback for JSON // preparation - ethernet_provider.getEthernetIfaceData( - iface_id, - [&, parent_iface_id, iface_id, patchReq = std::move(patchReq) ]( + ethernetProvider.getEthernetIfaceData( + ifaceId, + [&, parent_ifaceId, ifaceId, patchReq = std::move(patchReq) ]( const bool &success, const EthernetInterfaceData ð_data, const std::vector<IPv4AddressData> &ipv4_data) { if (!success) { @@ -1502,15 +1498,15 @@ class VlanNetworkInterface : public Node { // and // other errors messages::addMessageToErrorJson( - res.json_value, - messages::resourceNotFound("VLAN Network Interface", iface_id)); + res.jsonValue, + messages::resourceNotFound("VLAN Network Interface", ifaceId)); res.result(boost::beast::http::status::not_found); res.end(); return; } - res.json_value = parseInterfaceData(parent_iface_id, iface_id, + res.jsonValue = parseInterfaceData(parent_ifaceId, ifaceId, eth_data, ipv4_data); std::shared_ptr<AsyncResp> asyncResp = @@ -1520,28 +1516,28 @@ class VlanNetworkInterface : public Node { ++propertyIt) { if (propertyIt.key() != "VLANEnable" && propertyIt.key() != "VLANId") { - auto fieldInJsonIt = res.json_value.find(propertyIt.key()); + auto fieldInJsonIt = res.jsonValue.find(propertyIt.key()); - if (fieldInJsonIt == res.json_value.end()) { + if (fieldInJsonIt == res.jsonValue.end()) { // Field not in scope of defined fields messages::addMessageToJsonRoot( - res.json_value, + res.jsonValue, messages::propertyUnknown(propertyIt.key())); } else if (*fieldInJsonIt != *propertyIt) { // User attempted to modify non-writable field messages::addMessageToJsonRoot( - res.json_value, + res.jsonValue, messages::propertyNotWritable(propertyIt.key())); } } } - EthernetInterface::handleVlanPatch(iface_id, patchReq, eth_data, "/", + EthernetInterface::handleVlanPatch(ifaceId, patchReq, eth_data, "/", asyncResp); }); } - void doDelete(crow::response &res, const crow::request &req, + void doDelete(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { if (params.size() != 2) { res.result(boost::beast::http::status::internal_server_error); @@ -1549,30 +1545,30 @@ class VlanNetworkInterface : public Node { return; } - const std::string &parent_iface_id = params[0]; - const std::string &iface_id = params[1]; + const std::string &parent_ifaceId = params[0]; + const std::string &ifaceId = params[1]; - if (!verifyNames(res, parent_iface_id, iface_id)) { + if (!verifyNames(res, parent_ifaceId, ifaceId)) { return; } // Get single eth interface data, and call the below callback for JSON // preparation - ethernet_provider.getEthernetIfaceData( - iface_id, - [&, parent_iface_id, iface_id]( + ethernetProvider.getEthernetIfaceData( + ifaceId, + [&, parent_ifaceId, ifaceId]( const bool &success, const EthernetInterfaceData ð_data, const std::vector<IPv4AddressData> &ipv4_data) { - if (success && eth_data.vlan_id != nullptr) { - res.json_value = parseInterfaceData(parent_iface_id, iface_id, + if (success && eth_data.vlanId != nullptr) { + res.jsonValue = parseInterfaceData(parent_ifaceId, ifaceId, eth_data, ipv4_data); // Disable VLAN OnDemandEthernetProvider::disableVlan( - iface_id, [&](const boost::system::error_code ec) { + ifaceId, [&](const boost::system::error_code ec) { if (ec) { - res.json_value = nlohmann::json::object(); - messages::addMessageToErrorJson(res.json_value, + res.jsonValue = nlohmann::json::object(); + messages::addMessageToErrorJson(res.jsonValue, messages::internalError()); res.result( boost::beast::http::status::internal_server_error); @@ -1585,8 +1581,8 @@ class VlanNetworkInterface : public Node { // and // other errors messages::addMessageToErrorJson( - res.json_value, - messages::resourceNotFound("VLAN Network Interface", iface_id)); + res.jsonValue, + messages::resourceNotFound("VLAN Network Interface", ifaceId)); res.result(boost::beast::http::status::not_found); res.end(); } @@ -1603,7 +1599,7 @@ class VlanNetworkInterface : public Node { // Ethernet Provider object // TODO(Pawel) consider move it to singleton - OnDemandEthernetProvider ethernet_provider; + OnDemandEthernetProvider ethernetProvider; }; /** @@ -1641,7 +1637,7 @@ class VlanNetworkInterfaceCollection : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { if (params.size() != 1) { // This means there is a problem with the router @@ -1653,40 +1649,40 @@ class VlanNetworkInterfaceCollection : public Node { // TODO(Pawel) this shall be parametrized call to get EthernetInterfaces for // any Manager, not only hardcoded 'openbmc'. - std::string manager_id = "openbmc"; + std::string managerId = "openbmc"; std::string rootInterfaceName = params[0]; - // Get eth interface list, and call the below callback for JSON preparation - ethernet_provider.getEthernetIfaceList([ - &, manager_id{std::move(manager_id)}, + // get eth interface list, and call the below callback for JSON preparation + ethernetProvider.getEthernetIfaceList([ + &, managerId{std::move(managerId)}, rootInterfaceName{std::move(rootInterfaceName)} ](const bool &success, const std::vector<std::string> &iface_list) { if (success) { bool rootInterfaceFound = false; - nlohmann::json iface_array = nlohmann::json::array(); + nlohmann::json ifaceArray = nlohmann::json::array(); - for (const std::string &iface_item : iface_list) { - if (iface_item == rootInterfaceName) { + for (const std::string &ifaceItem : iface_list) { + if (ifaceItem == rootInterfaceName) { rootInterfaceFound = true; - } else if (boost::starts_with(iface_item, rootInterfaceName + "_")) { - iface_array.push_back( - {{"@odata.id", "/redfish/v1/Managers/" + manager_id + + } else if (boost::starts_with(ifaceItem, rootInterfaceName + "_")) { + ifaceArray.push_back( + {{"@odata.id", "/redfish/v1/Managers/" + managerId + "/EthernetInterfaces/" + rootInterfaceName + - "/VLANs/" + iface_item}}); + "/VLANs/" + ifaceItem}}); } } if (rootInterfaceFound) { - Node::json["Members"] = iface_array; - Node::json["Members@odata.count"] = iface_array.size(); - Node::json["@odata.id"] = "/redfish/v1/Managers/" + manager_id + + Node::json["Members"] = ifaceArray; + Node::json["Members@odata.count"] = ifaceArray.size(); + Node::json["@odata.id"] = "/redfish/v1/Managers/" + managerId + "/EthernetInterfaces/" + rootInterfaceName + "/VLANs"; - res.json_value = Node::json; + res.jsonValue = Node::json; } else { messages::addMessageToErrorJson( - res.json_value, messages::resourceNotFound("EthernetInterface", - rootInterfaceName)); + res.jsonValue, messages::resourceNotFound("EthernetInterface", + rootInterfaceName)); res.result(boost::beast::http::status::not_found); res.end(); } @@ -1698,7 +1694,7 @@ class VlanNetworkInterfaceCollection : public Node { }); } - void doPost(crow::response &res, const crow::request &req, + void doPost(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { if (params.size() != 1) { // This means there is a problem with the router @@ -1715,7 +1711,7 @@ class VlanNetworkInterfaceCollection : public Node { // TODO(Pawel) this shall be parametrized call to get EthernetInterfaces for // any Manager, not only hardcoded 'openbmc'. - std::string manager_id = "openbmc"; + std::string managerId = "openbmc"; std::string rootInterfaceName = params[0]; uint64_t vlanId; bool errorDetected; @@ -1724,33 +1720,33 @@ class VlanNetworkInterfaceCollection : public Node { "VLANId", postReq, vlanId, static_cast<uint8_t>(json_util::MessageSetting::MISSING) | static_cast<uint8_t>(json_util::MessageSetting::TYPE_ERROR), - res.json_value, "/VLANId") != json_util::Result::SUCCESS) { + res.jsonValue, "/VLANId") != json_util::Result::SUCCESS) { res.end(); return; } - // Get eth interface list, and call the below callback for JSON preparation - ethernet_provider.getEthernetIfaceList([ - &, manager_id{std::move(manager_id)}, + // get eth interface list, and call the below callback for JSON preparation + ethernetProvider.getEthernetIfaceList([ + &, managerId{std::move(managerId)}, rootInterfaceName{std::move(rootInterfaceName)} ](const bool &success, const std::vector<std::string> &iface_list) { if (success) { bool rootInterfaceFound = false; - for (const std::string &iface_item : iface_list) { - if (iface_item == rootInterfaceName) { + for (const std::string &ifaceItem : iface_list) { + if (ifaceItem == rootInterfaceName) { rootInterfaceFound = true; break; } } if (rootInterfaceFound) { - ethernet_provider.createVlan( + ethernetProvider.createVlan( rootInterfaceName, vlanId, [&, vlanId, rootInterfaceName, req{std::move(req)} ](const boost::system::error_code ec) { if (ec) { - messages::addMessageToErrorJson(res.json_value, + messages::addMessageToErrorJson(res.jsonValue, messages::internalError()); res.end(); } else { @@ -1762,8 +1758,8 @@ class VlanNetworkInterfaceCollection : public Node { }); } else { messages::addMessageToErrorJson( - res.json_value, messages::resourceNotFound("EthernetInterface", - rootInterfaceName)); + res.jsonValue, messages::resourceNotFound("EthernetInterface", + rootInterfaceName)); res.result(boost::beast::http::status::not_found); res.end(); } @@ -1777,7 +1773,7 @@ class VlanNetworkInterfaceCollection : public Node { // Ethernet Provider object // TODO(Pawel) consider move it to singleton - OnDemandEthernetProvider ethernet_provider; + OnDemandEthernetProvider ethernetProvider; VlanNetworkInterface memberVlan; }; diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index c8609b441a..daee36a743 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -30,8 +30,8 @@ class Manager : public Node { Node::json["Description"] = "Baseboard Management Controller"; Node::json["PowerState"] = "On"; Node::json["UUID"] = - app.template get_middleware<crow::PersistentData::Middleware>() - .system_uuid; + app.template getMiddleware<crow::persistent_data::Middleware>() + .systemUuid; Node::json["Model"] = "OpenBmc"; // TODO(ed), get model Node::json["FirmwareVersion"] = "1234456789"; // TODO(ed), get fwversion Node::json["EthernetInterfaces"] = nlohmann::json( @@ -52,10 +52,11 @@ class Manager : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { Node::json["DateTime"] = getDateTime(); - res.json_value = Node::json; + // Copy over the static data to include the entries added by SubRoute + res.jsonValue = Node::json; res.end(); } @@ -96,9 +97,18 @@ class ManagerCollection : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + // Collections don't include the static data added by SubRoute because it + // has a duplicate entry for members + res.jsonValue["@odata.id"] = "/redfish/v1/Managers"; + res.jsonValue["@odata.type"] = "#ManagerCollection.ManagerCollection"; + res.jsonValue["@odata.context"] = + "/redfish/v1/$metadata#ManagerCollection.ManagerCollection"; + res.jsonValue["Name"] = "Manager Collection"; + res.jsonValue["Members@odata.count"] = 1; + res.jsonValue["Members"] = { + {{"@odata.id", "/redfish/v1/Managers/openbmc"}}}; res.end(); } diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index d7bf1016ad..235b2b8828 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -45,11 +45,11 @@ class NetworkProtocol : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { refreshProtocolsState(); Node::json["HostName"] = getHostName(); - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp index 9e793df049..a32a660754 100644 --- a/redfish-core/lib/redfish_sessions.hpp +++ b/redfish-core/lib/redfish_sessions.hpp @@ -42,52 +42,52 @@ class Sessions : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { auto session = - crow::PersistentData::SessionStore::getInstance().get_session_by_uid( + crow::persistent_data::SessionStore::getInstance().getSessionByUid( params[0]); if (session == nullptr) { messages::addMessageToErrorJson( - res.json_value, messages::resourceNotFound("Session", params[0])); + res.jsonValue, messages::resourceNotFound("Session", params[0])); res.result(boost::beast::http::status::not_found); res.end(); return; } - Node::json["Id"] = session->unique_id; + Node::json["Id"] = session->uniqueId; Node::json["UserName"] = session->username; Node::json["@odata.id"] = - "/redfish/v1/SessionService/Sessions/" + session->unique_id; + "/redfish/v1/SessionService/Sessions/" + session->uniqueId; - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } - void doDelete(crow::response& res, const crow::request& req, + void doDelete(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { // Need only 1 param which should be id of session to be deleted if (params.size() != 1) { // This should be handled by crow and never happen - CROW_LOG_ERROR + BMCWEB_LOG_ERROR << "Session DELETE has been called with invalid number of params"; res.result(boost::beast::http::status::bad_request); - messages::addMessageToErrorJson(res.json_value, messages::generalError()); + messages::addMessageToErrorJson(res.jsonValue, messages::generalError()); res.end(); return; } auto session = - crow::PersistentData::SessionStore::getInstance().get_session_by_uid( + crow::persistent_data::SessionStore::getInstance().getSessionByUid( params[0]); if (session == nullptr) { messages::addMessageToErrorJson( - res.json_value, messages::resourceNotFound("Session", params[0])); + res.jsonValue, messages::resourceNotFound("Session", params[0])); res.result(boost::beast::http::status::not_found); res.end(); @@ -97,7 +97,7 @@ class Sessions : public Node { // DELETE should return representation of object that will be removed doGet(res, req, params); - crow::PersistentData::SessionStore::getInstance().remove_session(session); + crow::persistent_data::SessionStore::getInstance().removeSession(session); } /** @@ -131,29 +131,29 @@ class SessionCollection : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - std::vector<const std::string*> session_ids = - crow::PersistentData::SessionStore::getInstance().get_unique_ids( - false, crow::PersistentData::PersistenceType::TIMEOUT); + std::vector<const std::string*> sessionIds = + crow::persistent_data::SessionStore::getInstance().getUniqueIds( + false, crow::persistent_data::PersistenceType::TIMEOUT); - Node::json["Members@odata.count"] = session_ids.size(); + Node::json["Members@odata.count"] = sessionIds.size(); Node::json["Members"] = nlohmann::json::array(); - for (const std::string* uid : session_ids) { + for (const std::string* uid : sessionIds) { Node::json["Members"].push_back( {{"@odata.id", "/redfish/v1/SessionService/Sessions/" + *uid}}); } - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } - void doPost(crow::response& res, const crow::request& req, + void doPost(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { boost::beast::http::status status; std::string username; bool userAuthSuccessful = - authenticateUser(req, status, username, res.json_value); + authenticateUser(req, status, username, res.jsonValue); res.result(status); if (!userAuthSuccessful) { @@ -163,12 +163,12 @@ class SessionCollection : public Node { // User is authenticated - create session for him auto session = - crow::PersistentData::SessionStore::getInstance().generate_user_session( + crow::persistent_data::SessionStore::getInstance().generateUserSession( username); - res.add_header("X-Auth-Token", session->session_token); + res.addHeader("X-Auth-Token", session->sessionToken); // Return data for created session - memberSession.doGet(res, req, {session->unique_id}); + memberSession.doGet(res, req, {session->uniqueId}); // No need for res.end(), as it is called by doGet() } @@ -183,15 +183,15 @@ class SessionCollection : public Node { * * @return true if authentication was successful, false otherwise */ - bool authenticateUser(const crow::request& req, + bool authenticateUser(const crow::Request& req, boost::beast::http::status& httpRespCode, std::string& user, nlohmann::json& errJson) { // We need only UserName and Password - nothing more, nothing less static constexpr const unsigned int numberOfRequiredFieldsInReq = 2; // call with exceptions disabled - auto login_credentials = nlohmann::json::parse(req.body, nullptr, false); - if (login_credentials.is_discarded()) { + auto loginCredentials = nlohmann::json::parse(req.body, nullptr, false); + if (loginCredentials.is_discarded()) { httpRespCode = boost::beast::http::status::bad_request; messages::addMessageToErrorJson(errJson, messages::malformedJSON()); @@ -200,7 +200,7 @@ class SessionCollection : public Node { } // Check that there are only as many fields as there should be - if (login_credentials.size() != numberOfRequiredFieldsInReq) { + if (loginCredentials.size() != numberOfRequiredFieldsInReq) { httpRespCode = boost::beast::http::status::bad_request; messages::addMessageToErrorJson(errJson, messages::malformedJSON()); @@ -209,18 +209,17 @@ class SessionCollection : public Node { } // Find fields that we need - UserName and Password - auto user_it = login_credentials.find("UserName"); - auto pass_it = login_credentials.find("Password"); - if (user_it == login_credentials.end() || - pass_it == login_credentials.end()) { + auto userIt = loginCredentials.find("UserName"); + auto passIt = loginCredentials.find("Password"); + if (userIt == loginCredentials.end() || passIt == loginCredentials.end()) { httpRespCode = boost::beast::http::status::bad_request; - if (user_it == login_credentials.end()) { + if (userIt == loginCredentials.end()) { messages::addMessageToErrorJson(errJson, messages::propertyMissing("UserName")); } - if (pass_it == login_credentials.end()) { + if (passIt == loginCredentials.end()) { messages::addMessageToErrorJson(errJson, messages::propertyMissing("Password")); } @@ -229,27 +228,27 @@ class SessionCollection : public Node { } // Check that given data is of valid type (string) - if (!user_it->is_string() || !pass_it->is_string()) { + if (!userIt->is_string() || !passIt->is_string()) { httpRespCode = boost::beast::http::status::bad_request; - if (!user_it->is_string()) { + if (!userIt->is_string()) { messages::addMessageToErrorJson( errJson, - messages::propertyValueTypeError(user_it->dump(), "UserName")); + messages::propertyValueTypeError(userIt->dump(), "UserName")); } - if (!pass_it->is_string()) { + if (!passIt->is_string()) { messages::addMessageToErrorJson( errJson, - messages::propertyValueTypeError(user_it->dump(), "Password")); + messages::propertyValueTypeError(userIt->dump(), "Password")); } return false; } // Extract username and password - std::string username = user_it->get<const std::string>(); - std::string password = pass_it->get<const std::string>(); + std::string username = userIt->get<const std::string>(); + std::string password = passIt->get<const std::string>(); // Verify that required fields are not empty if (username.empty() || password.empty()) { @@ -269,7 +268,7 @@ class SessionCollection : public Node { } // Finally - try to authenticate user - if (!pam_authenticate_user(username, password)) { + if (!pamAuthenticateUser(username, password)) { httpRespCode = boost::beast::http::status::unauthorized; messages::addMessageToErrorJson( @@ -304,8 +303,8 @@ class SessionService : public Node { Node::json["Id"] = "SessionService"; Node::json["Description"] = "Session Service"; Node::json["SessionTimeout"] = - crow::PersistentData::SessionStore::getInstance() - .get_timeout_in_seconds(); + crow::persistent_data::SessionStore::getInstance() + .getTimeoutInSeconds(); Node::json["ServiceEnabled"] = true; entityPrivileges = { @@ -318,9 +317,9 @@ class SessionService : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } }; diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp index f538c834f5..72d79486bb 100644 --- a/redfish-core/lib/roles.hpp +++ b/redfish-core/lib/roles.hpp @@ -34,18 +34,19 @@ class Roles : public Node { "ConfigureUsers", "ConfigureSelf", "ConfigureComponents"}; Node::json["OemPrivileges"] = nlohmann::json::array(); - entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}, - {boost::beast::http::verb::head, {{"Login"}}}, - {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, - {boost::beast::http::verb::put, {{"ConfigureManager"}}}, - {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, - {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; + entityPrivileges = { + {boost::beast::http::verb::get, {{"Login"}}}, + {boost::beast::http::verb::head, {{"Login"}}}, + {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, + {boost::beast::http::verb::put, {{"ConfigureManager"}}}, + {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, + {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } }; @@ -64,23 +65,24 @@ class RoleCollection : public Node { Node::json["Members"] = { {{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}}}; - entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}, - {boost::beast::http::verb::head, {{"Login"}}}, - {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, - {boost::beast::http::verb::put, {{"ConfigureManager"}}}, - {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, - {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; + entityPrivileges = { + {boost::beast::http::verb::get, {{"Login"}}}, + {boost::beast::http::verb::head, {{"Login"}}}, + {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, + {boost::beast::http::verb::put, {{"ConfigureManager"}}}, + {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, + {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + res.jsonValue = Node::json; // This is a short term solution to work around a bug. GetSubroutes // accidentally recognizes the Roles/Administrator route as a subroute // (because it's hardcoded to a single entity). Remove this line when that // is resolved - res.json_value.erase("Administrator"); + res.jsonValue.erase("Administrator"); res.end(); } }; diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 727fa9f2c7..9aa1da4cc8 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -43,10 +43,10 @@ using ManagedObjectsVectorType = std::vector<std::pair< */ class SensorsAsyncResp { public: - SensorsAsyncResp(crow::response& response, const std::string& chassisId, + SensorsAsyncResp(crow::Response& response, const std::string& chassisId, const std::initializer_list<const char*> types) : res(response), chassisId(chassisId), types(types) { - res.json_value["@odata.id"] = + res.jsonValue["@odata.id"] = "/redfish/v1/Chassis/" + chassisId + "/Thermal"; } @@ -55,7 +55,7 @@ class SensorsAsyncResp { // Reset the json object to clear out any data that made it in before the // error happened // todo(ed) handle error condition with proper code - res.json_value = nlohmann::json::object(); + res.jsonValue = nlohmann::json::object(); } res.end(); } @@ -64,7 +64,7 @@ class SensorsAsyncResp { res.result(boost::beast::http::status::internal_server_error); } - crow::response& res; + crow::Response& res; std::string chassisId{}; const std::vector<const char*> types; }; @@ -79,23 +79,23 @@ template <typename Callback> void getConnections(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, const boost::container::flat_set<std::string>& sensorNames, Callback&& callback) { - CROW_LOG_DEBUG << "getConnections enter"; + BMCWEB_LOG_DEBUG << "getConnections enter"; const std::string path = "/xyz/openbmc_project/sensors"; const std::array<std::string, 1> interfaces = { "xyz.openbmc_project.Sensor.Value"}; // Response handler for parsing objects subtree - auto resp_handler = + auto respHandler = [ callback{std::move(callback)}, SensorsAsyncResp, sensorNames ]( const boost::system::error_code ec, const GetSubTreeType& subtree) { - CROW_LOG_DEBUG << "getConnections resp_handler enter"; + BMCWEB_LOG_DEBUG << "getConnections resp_handler enter"; if (ec) { SensorsAsyncResp->setErrorStatus(); - CROW_LOG_ERROR << "getConnections resp_handler: Dbus error " << ec; + BMCWEB_LOG_ERROR << "getConnections resp_handler: Dbus error " << ec; return; } - CROW_LOG_DEBUG << "Found " << subtree.size() << " subtrees"; + BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " subtrees"; // Make unique list of connections only for requested sensor types and // found in the chassis @@ -103,9 +103,9 @@ void getConnections(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, // Intrinsic to avoid malloc. Most systems will have < 8 sensor producers connections.reserve(8); - CROW_LOG_DEBUG << "sensorNames list count: " << sensorNames.size(); + BMCWEB_LOG_DEBUG << "sensorNames list count: " << sensorNames.size(); for (const std::string& tsensor : sensorNames) { - CROW_LOG_DEBUG << "Sensor to find: " << tsensor; + BMCWEB_LOG_DEBUG << "Sensor to find: " << tsensor; } for (const std::pair< @@ -119,10 +119,10 @@ void getConnections(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, std::string sensorName = object.first.substr(lastPos + 1); if (sensorNames.find(sensorName) != sensorNames.end()) { - // For each connection name + // For each Connection name for (const std::pair<std::string, std::vector<std::string>>& objData : object.second) { - CROW_LOG_DEBUG << "Adding connection: " << objData.first; + BMCWEB_LOG_DEBUG << "Adding connection: " << objData.first; connections.insert(objData.first); } } @@ -131,17 +131,17 @@ void getConnections(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, } } } - CROW_LOG_DEBUG << "Found " << connections.size() << " connections"; + BMCWEB_LOG_DEBUG << "Found " << connections.size() << " connections"; callback(std::move(connections)); - CROW_LOG_DEBUG << "getConnections resp_handler exit"; + BMCWEB_LOG_DEBUG << "getConnections resp_handler exit"; }; // Make call to ObjectMapper to find all sensors objects - crow::connections::system_bus->async_method_call( - std::move(resp_handler), "xyz.openbmc_project.ObjectMapper", + crow::connections::systemBus->async_method_call( + std::move(respHandler), "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, 2, interfaces); - CROW_LOG_DEBUG << "getConnections exit"; + BMCWEB_LOG_DEBUG << "getConnections exit"; } /** @@ -152,13 +152,13 @@ void getConnections(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, template <typename Callback> void getChassis(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, Callback&& callback) { - CROW_LOG_DEBUG << "getChassis enter"; + BMCWEB_LOG_DEBUG << "getChassis enter"; // Process response from EntityManager and extract chassis data - auto resp_handler = [ callback{std::move(callback)}, SensorsAsyncResp ]( + auto respHandler = [ callback{std::move(callback)}, SensorsAsyncResp ]( const boost::system::error_code ec, ManagedObjectsVectorType& resp) { - CROW_LOG_DEBUG << "getChassis resp_handler enter"; + BMCWEB_LOG_DEBUG << "getChassis respHandler enter"; if (ec) { - CROW_LOG_ERROR << "getChassis resp_handler DBUS error: " << ec; + BMCWEB_LOG_ERROR << "getChassis respHandler DBUS error: " << ec; SensorsAsyncResp->setErrorStatus(); return; } @@ -176,7 +176,7 @@ void getChassis(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, static_cast<const std::string&>(objDictEntry.first); boost::algorithm::split(split, objectPath, boost::is_any_of("/")); if (split.size() < 2) { - CROW_LOG_ERROR << "Got path that isn't long enough " << objectPath; + BMCWEB_LOG_ERROR << "Got path that isn't long enough " << objectPath; split.clear(); continue; } @@ -187,28 +187,28 @@ void getChassis(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp, split.clear(); continue; } - CROW_LOG_DEBUG << "New sensor: " << sensorName; + BMCWEB_LOG_DEBUG << "New sensor: " << sensorName; foundChassis = true; sensorNames.emplace(sensorName); split.clear(); }; - CROW_LOG_DEBUG << "Found " << sensorNames.size() << " Sensor names"; + BMCWEB_LOG_DEBUG << "Found " << sensorNames.size() << " Sensor names"; if (!foundChassis) { - CROW_LOG_INFO << "Unable to find chassis named " - << SensorsAsyncResp->chassisId; + BMCWEB_LOG_INFO << "Unable to find chassis named " + << SensorsAsyncResp->chassisId; SensorsAsyncResp->res.result(boost::beast::http::status::not_found); } else { callback(sensorNames); } - CROW_LOG_DEBUG << "getChassis resp_handler exit"; + BMCWEB_LOG_DEBUG << "getChassis respHandler exit"; }; // Make call to EntityManager to find all chassis objects - crow::connections::system_bus->async_method_call( - resp_handler, "xyz.openbmc_project.EntityManager", "/", + crow::connections::systemBus->async_method_call( + respHandler, "xyz.openbmc_project.EntityManager", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); - CROW_LOG_DEBUG << "getChassis exit"; + BMCWEB_LOG_DEBUG << "getChassis exit"; } /** @@ -227,20 +227,19 @@ void objectInterfacesToJson( interfacesDict, nlohmann::json& sensor_json) { // We need a value interface before we can do anything with it - auto value_it = interfacesDict.find("xyz.openbmc_project.Sensor.Value"); - if (value_it == interfacesDict.end()) { - CROW_LOG_ERROR << "Sensor doesn't have a value interface"; + auto valueIt = interfacesDict.find("xyz.openbmc_project.Sensor.Value"); + if (valueIt == interfacesDict.end()) { + BMCWEB_LOG_ERROR << "Sensor doesn't have a value interface"; return; } // Assume values exist as is (10^0 == 1) if no scale exists int64_t scaleMultiplier = 0; - auto scale_it = value_it->second.find("Scale"); + auto scaleIt = valueIt->second.find("Scale"); // If a scale exists, pull value as int64, and use the scaling. - if (scale_it != value_it->second.end()) { - const int64_t* int64Value = - mapbox::get_ptr<const int64_t>(scale_it->second); + if (scaleIt != valueIt->second.end()) { + const int64_t* int64Value = mapbox::getPtr<const int64_t>(scaleIt->second); if (int64Value != nullptr) { scaleMultiplier = *int64Value; } @@ -271,7 +270,7 @@ void objectInterfacesToJson( unit = "ReadingVolts"; sensor_json["@odata.type"] = "#Power.v1_0_0.Voltage"; } else { - CROW_LOG_ERROR << "Redfish cannot map object type for " << sensorName; + BMCWEB_LOG_ERROR << "Redfish cannot map object type for " << sensorName; return; } // Map of dbus interface name, dbus property name and redfish property_name @@ -304,39 +303,38 @@ void objectInterfacesToJson( properties) { auto interfaceProperties = interfacesDict.find(std::get<0>(p)); if (interfaceProperties != interfacesDict.end()) { - auto value_it = interfaceProperties->second.find(std::get<1>(p)); - if (value_it != interfaceProperties->second.end()) { - const SensorVariant& valueVariant = value_it->second; - nlohmann::json& value_it = sensor_json[std::get<2>(p)]; + auto valueIt = interfaceProperties->second.find(std::get<1>(p)); + if (valueIt != interfaceProperties->second.end()) { + const SensorVariant& valueVariant = valueIt->second; + nlohmann::json& valueIt = sensor_json[std::get<2>(p)]; // Attempt to pull the int64 directly - const int64_t* int64Value = - mapbox::get_ptr<const int64_t>(valueVariant); + const int64_t* int64Value = mapbox::getPtr<const int64_t>(valueVariant); if (int64Value != nullptr) { if (forceToInt || scaleMultiplier >= 0) { - value_it = *int64Value * std::pow(10, scaleMultiplier); + valueIt = *int64Value * std::pow(10, scaleMultiplier); } else { - value_it = *int64Value * - std::pow(10, static_cast<double>(scaleMultiplier)); + valueIt = *int64Value * + std::pow(10, static_cast<double>(scaleMultiplier)); } } // Attempt to pull the float directly - const double* doubleValue = mapbox::get_ptr<const double>(valueVariant); + const double* doubleValue = mapbox::getPtr<const double>(valueVariant); if (doubleValue != nullptr) { if (!forceToInt) { - value_it = *doubleValue * - std::pow(10, static_cast<double>(scaleMultiplier)); + valueIt = *doubleValue * + std::pow(10, static_cast<double>(scaleMultiplier)); } else { - value_it = static_cast<int64_t>(*doubleValue * - std::pow(10, scaleMultiplier)); + valueIt = static_cast<int64_t>(*doubleValue * + std::pow(10, scaleMultiplier)); } } } } } - CROW_LOG_DEBUG << "Added sensor " << sensorName; + BMCWEB_LOG_DEBUG << "Added sensor " << sensorName; } /** @@ -345,24 +343,24 @@ void objectInterfacesToJson( * @param SensorsAsyncResp Pointer to object holding response data */ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp) { - CROW_LOG_DEBUG << "getChassisData enter"; + BMCWEB_LOG_DEBUG << "getChassisData enter"; auto getChassisCb = [&, SensorsAsyncResp]( boost::container::flat_set<std::string>& sensorNames) { - CROW_LOG_DEBUG << "getChassisCb enter"; + BMCWEB_LOG_DEBUG << "getChassisCb enter"; auto getConnectionCb = [&, SensorsAsyncResp, sensorNames]( const boost::container::flat_set<std::string>& connections) { - CROW_LOG_DEBUG << "getConnectionCb enter"; + BMCWEB_LOG_DEBUG << "getConnectionCb enter"; // Get managed objects from all services exposing sensors for (const std::string& connection : connections) { // Response handler to process managed objects auto getManagedObjectsCb = [&, SensorsAsyncResp, sensorNames]( const boost::system::error_code ec, ManagedObjectsVectorType& resp) { - CROW_LOG_DEBUG << "getManagedObjectsCb enter"; + BMCWEB_LOG_DEBUG << "getManagedObjectsCb enter"; if (ec) { - CROW_LOG_ERROR << "getManagedObjectsCb DBUS error: " << ec; + BMCWEB_LOG_ERROR << "getManagedObjectsCb DBUS error: " << ec; SensorsAsyncResp->setErrorStatus(); return; } @@ -371,8 +369,8 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp) { for (const auto& objDictEntry : resp) { const std::string& objPath = static_cast<const std::string&>(objDictEntry.first); - CROW_LOG_DEBUG << "getManagedObjectsCb parsing object " - << objPath; + BMCWEB_LOG_DEBUG << "getManagedObjectsCb parsing object " + << objPath; std::vector<std::string> split; // Reserve space for @@ -380,18 +378,18 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp) { split.reserve(6); boost::algorithm::split(split, objPath, boost::is_any_of("/")); if (split.size() < 6) { - CROW_LOG_ERROR << "Got path that isn't long enough " - << objPath; + BMCWEB_LOG_ERROR << "Got path that isn't long enough " + << objPath; continue; } // These indexes aren't intuitive, as boost::split puts an empty // string at the beggining const std::string& sensorType = split[4]; const std::string& sensorName = split[5]; - CROW_LOG_DEBUG << "sensorName " << sensorName << " sensorType " - << sensorType; + BMCWEB_LOG_DEBUG << "sensorName " << sensorName + << " sensorType " << sensorType; if (sensorNames.find(sensorName) == sensorNames.end()) { - CROW_LOG_ERROR << sensorName << " not in sensor list "; + BMCWEB_LOG_ERROR << sensorName << " not in sensor list "; continue; } @@ -407,43 +405,43 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp) { } else if (sensorType == "power") { fieldName = "PowerSupply"; } else { - CROW_LOG_ERROR << "Unsure how to handle sensorType " - << sensorType; + BMCWEB_LOG_ERROR << "Unsure how to handle sensorType " + << sensorType; continue; } - nlohmann::json& temp_array = - SensorsAsyncResp->res.json_value[fieldName]; + nlohmann::json& tempArray = + SensorsAsyncResp->res.jsonValue[fieldName]; // Create the array if it doesn't yet exist - if (temp_array.is_array() == false) { - temp_array = nlohmann::json::array(); + if (tempArray.is_array() == false) { + tempArray = nlohmann::json::array(); } - temp_array.push_back( + tempArray.push_back( {{"@odata.id", "/redfish/v1/Chassis/" + SensorsAsyncResp->chassisId + "/Thermal#/" + sensorName}}); - nlohmann::json& sensor_json = temp_array.back(); + nlohmann::json& sensorJson = tempArray.back(); objectInterfacesToJson(sensorName, sensorType, - objDictEntry.second, sensor_json); + objDictEntry.second, sensorJson); } - CROW_LOG_DEBUG << "getManagedObjectsCb exit"; + BMCWEB_LOG_DEBUG << "getManagedObjectsCb exit"; }; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( getManagedObjectsCb, connection, "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); }; - CROW_LOG_DEBUG << "getConnectionCb exit"; + BMCWEB_LOG_DEBUG << "getConnectionCb exit"; }; - // Get connections and then pass it to get sensors + // get connections and then pass it to get sensors getConnections(SensorsAsyncResp, sensorNames, std::move(getConnectionCb)); - CROW_LOG_DEBUG << "getChassisCb exit"; + BMCWEB_LOG_DEBUG << "getChassisCb exit"; }; - // Get chassis information related to sensors + // get chassis information related to sensors getChassis(SensorsAsyncResp, std::move(getChassisCb)); - CROW_LOG_DEBUG << "getChassisData exit"; + BMCWEB_LOG_DEBUG << "getChassisData exit"; }; } // namespace redfish diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp index d6cf44e784..6fa9632c9b 100644 --- a/redfish-core/lib/service_root.hpp +++ b/redfish-core/lib/service_root.hpp @@ -33,7 +33,7 @@ class ServiceRoot : public Node { Node::json["Links"]["Sessions"] = { {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; - Node::json["UUID"] = get_uuid(); + Node::json["UUID"] = getUuid(); entityPrivileges = { {boost::beast::http::verb::get, {}}, @@ -45,13 +45,13 @@ class ServiceRoot : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } - const std::string get_uuid() { + const std::string getUuid() { // If we are using a version of systemd that can get the app specific uuid, // use that #ifdef sd_id128_get_machine_app_specific diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 7619f14708..668e6a92be 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -28,14 +28,14 @@ namespace redfish { */ class SystemAsyncResp { public: - SystemAsyncResp(crow::response &response) : res(response) {} + SystemAsyncResp(crow::Response &response) : res(response) {} ~SystemAsyncResp() { if (res.result() != (boost::beast::http::status::ok)) { // Reset the json object to clear out any data that made it in before the // error happened // todo(ed) handle error condition with proper code - res.json_value = messages::internalError(); + res.jsonValue = messages::internalError(); } res.end(); } @@ -44,7 +44,7 @@ class SystemAsyncResp { res.result(boost::beast::http::status::internal_server_error); } - crow::response &res; + crow::Response &res; }; /** @@ -63,8 +63,8 @@ class OnDemandSystemsProvider { public: template <typename CallbackFunc> void getBaseboardList(CallbackFunc &&callback) { - CROW_LOG_DEBUG << "Get list of available boards."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Get list of available boards."; + crow::connections::systemBus->async_method_call( [callback{std::move(callback)}](const boost::system::error_code ec, const std::vector<std::string> &resp) { // Callback requires vector<string> to retrieve all available board @@ -78,7 +78,7 @@ class OnDemandSystemsProvider { callback(false, board_list); return; } - CROW_LOG_DEBUG << "Got " << resp.size() << " boards."; + BMCWEB_LOG_DEBUG << "Got " << resp.size() << " boards."; // Iterate over all retrieved ObjectPaths. for (const std::string &objpath : resp) { std::size_t last_pos = objpath.rfind("/"); @@ -114,8 +114,8 @@ class OnDemandSystemsProvider { "xyz.openbmc_project.Inventory.Item.System", "xyz.openbmc_project.Common.UUID", }; - CROW_LOG_DEBUG << "Get available system components."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Get available system components."; + crow::connections::systemBus->async_method_call( [ name, aResp{std::move(aResp)} ]( const boost::system::error_code ec, const std::vector<std::pair< @@ -123,7 +123,7 @@ class OnDemandSystemsProvider { std::vector<std::pair<std::string, std::vector<std::string>>>>> &subtree) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG << "DBUS response error"; aResp->setErrorStatus(); return; } @@ -134,7 +134,7 @@ class OnDemandSystemsProvider { std::vector<std::string>>>> &object : subtree) { const std::string &path = object.first; - CROW_LOG_DEBUG << "Got path: " << path; + BMCWEB_LOG_DEBUG << "Got path: " << path; const std::vector<std::pair<std::string, std::vector<std::string>>> &connectionNames = object.second; if (connectionNames.size() < 1) { @@ -143,31 +143,31 @@ class OnDemandSystemsProvider { // Check if computer system exist if (boost::ends_with(path, name)) { foundName = true; - CROW_LOG_DEBUG << "Found name: " << name; + BMCWEB_LOG_DEBUG << "Found name: " << name; const std::string connectionName = connectionNames[0].first; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [ aResp, name(std::string(name)) ]( const boost::system::error_code ec, const std::vector<std::pair<std::string, VariantType>> &propertiesList) { if (ec) { - CROW_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR << "DBUS response error: " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << propertiesList.size() + BMCWEB_LOG_DEBUG << "Got " << propertiesList.size() << "properties for system"; for (const std::pair<std::string, VariantType> &property : propertiesList) { const std::string *value = - mapbox::get_ptr<const std::string>(property.second); + mapbox::getPtr<const std::string>(property.second); if (value != nullptr) { - aResp->res.json_value[property.first] = *value; + aResp->res.jsonValue[property.first] = *value; } } - aResp->res.json_value["Name"] = name; - aResp->res.json_value["Id"] = - aResp->res.json_value["SerialNumber"]; + aResp->res.jsonValue["Name"] = name; + aResp->res.jsonValue["Id"] = + aResp->res.jsonValue["SerialNumber"]; }, connectionName, path, "org.freedesktop.DBus.Properties", "GetAll", "xyz.openbmc_project.Inventory.Decorator.Asset"); @@ -176,22 +176,22 @@ class OnDemandSystemsProvider { for (auto const &s : connectionNames) { for (auto const &i : s.second) { if (boost::ends_with(i, "Dimm")) { - CROW_LOG_DEBUG << "Found Dimm, now get it properties."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Found Dimm, now get it properties."; + crow::connections::systemBus->async_method_call( [&, aResp](const boost::system::error_code ec, const std::vector<std::pair< std::string, VariantType>> &properties) { if (ec) { - CROW_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << properties.size() + BMCWEB_LOG_DEBUG << "Got " << properties.size() << "Dimm properties."; for (const auto &p : properties) { if (p.first == "MemorySize") { const std::string *value = - mapbox::get_ptr<const std::string>(p.second); + mapbox::getPtr<const std::string>(p.second); if ((value != nullptr) && (*value != "NULL")) { // Remove units char int32_t unitCoeff; @@ -200,16 +200,16 @@ class OnDemandSystemsProvider { } else if (boost::ends_with(*value, "KB")) { unitCoeff = 1000000; } else { - CROW_LOG_ERROR << "Unsupported memory units"; + BMCWEB_LOG_ERROR << "Unsupported memory units"; aResp->setErrorStatus(); return; } auto memSize = boost::lexical_cast<int>( value->substr(0, value->length() - 2)); - aResp->res.json_value["TotalSystemMemoryGiB"] += + aResp->res.jsonValue["TotalSystemMemoryGiB"] += memSize * unitCoeff; - aResp->res.json_value["MemorySummary"]["Status"] + aResp->res.jsonValue["MemorySummary"]["Status"] ["State"] = "Enabled"; } } @@ -218,34 +218,34 @@ class OnDemandSystemsProvider { s.first, path, "org.freedesktop.DBus.Properties", "GetAll", "xyz.openbmc_project.Inventory.Item.Dimm"); } else if (boost::ends_with(i, "Cpu")) { - CROW_LOG_DEBUG << "Found Cpu, now get it properties."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Found Cpu, now get it properties."; + crow::connections::systemBus->async_method_call( [&, aResp](const boost::system::error_code ec, const std::vector<std::pair< std::string, VariantType>> &properties) { if (ec) { - CROW_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << properties.size() + BMCWEB_LOG_DEBUG << "Got " << properties.size() << "Cpu properties."; for (const auto &p : properties) { if (p.first == "ProcessorFamily") { const std::string *value = - mapbox::get_ptr<const std::string>(p.second); + mapbox::getPtr<const std::string>(p.second); if (value != nullptr) { aResp->res - .json_value["ProcessorSummary"]["Count"] = + .jsonValue["ProcessorSummary"]["Count"] = aResp->res - .json_value["ProcessorSummary"]["Count"] + .jsonValue["ProcessorSummary"]["Count"] .get<int>() + 1; - aResp->res.json_value["ProcessorSummary"] + aResp->res.jsonValue["ProcessorSummary"] ["Status"]["State"] = "Enabled"; aResp->res - .json_value["ProcessorSummary"]["Model"] = + .jsonValue["ProcessorSummary"]["Model"] = *value; } } @@ -254,31 +254,31 @@ class OnDemandSystemsProvider { s.first, path, "org.freedesktop.DBus.Properties", "GetAll", "xyz.openbmc_project.Inventory.Item.Cpu"); } else if (boost::ends_with(i, "UUID")) { - CROW_LOG_DEBUG << "Found UUID, now get it properties."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Found UUID, now get it properties."; + crow::connections::systemBus->async_method_call( [aResp](const boost::system::error_code ec, const std::vector<std::pair< std::string, VariantType>> &properties) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << properties.size() + BMCWEB_LOG_DEBUG << "Got " << properties.size() << "UUID properties."; for (const std::pair<std::string, VariantType> &p : properties) { if (p.first == "BIOSVer") { const std::string *value = - mapbox::get_ptr<const std::string>(p.second); + mapbox::getPtr<const std::string>(p.second); if (value != nullptr) { - aResp->res.json_value["BiosVersion"] = *value; + aResp->res.jsonValue["BiosVersion"] = *value; } } if (p.first == "UUID") { const std::string *value = - mapbox::get_ptr<const std::string>(p.second); - CROW_LOG_DEBUG << "UUID = " << *value + mapbox::getPtr<const std::string>(p.second); + BMCWEB_LOG_DEBUG << "UUID = " << *value << " length " << value->length(); if (value != nullptr) { // Workaround for to short return str in smbios @@ -290,7 +290,7 @@ class OnDemandSystemsProvider { '0'); value = &correctedValue; } else if (value->length() == 32) { - aResp->res.json_value["UUID"] = + aResp->res.jsonValue["UUID"] = value->substr(0, 8) + "-" + value->substr(8, 4) + "-" + value->substr(12, 4) + "-" + @@ -329,17 +329,17 @@ class OnDemandSystemsProvider { template <typename CallbackFunc> void getLedGroupIdentify(std::shared_ptr<SystemAsyncResp> aResp, CallbackFunc &&callback) { - CROW_LOG_DEBUG << "Get led groups"; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Get led groups"; + crow::connections::systemBus->async_method_call( [ aResp{std::move(aResp)}, &callback ](const boost::system::error_code &ec, const ManagedObjectsType &resp) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << resp.size() << "led group objects."; + BMCWEB_LOG_DEBUG << "Got " << resp.size() << "led group objects."; for (const auto &objPath : resp) { const std::string &path = objPath.first; if (path.rfind("enclosure_identify") != std::string::npos) { @@ -348,7 +348,7 @@ class OnDemandSystemsProvider { for (const auto &property : interface.second) { if (property.first == "Asserted") { const bool *asserted = - mapbox::get_ptr<const bool>(property.second); + mapbox::getPtr<const bool>(property.second); if (nullptr != asserted) { callback(*asserted, aResp); } else { @@ -369,24 +369,24 @@ class OnDemandSystemsProvider { template <typename CallbackFunc> void getLedIdentify(std::shared_ptr<SystemAsyncResp> aResp, CallbackFunc &&callback) { - CROW_LOG_DEBUG << "Get identify led properties"; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Get identify led properties"; + crow::connections::systemBus->async_method_call( [ aResp{std::move(aResp)}, &callback ]( const boost::system::error_code ec, const PropertiesType &properties) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << properties.size() << "led properties."; + BMCWEB_LOG_DEBUG << "Got " << properties.size() << "led properties."; std::string output; for (const auto &property : properties) { if (property.first == "State") { const std::string *s = - mapbox::get_ptr<std::string>(property.second); + mapbox::getPtr<std::string>(property.second); if (nullptr != s) { - CROW_LOG_DEBUG << "Identify Led State: " << *s; + BMCWEB_LOG_DEBUG << "Identify Led State: " << *s; const auto pos = s->rfind('.'); if (pos != std::string::npos) { auto led = s->substr(pos + 1); @@ -419,31 +419,31 @@ class OnDemandSystemsProvider { * @return None. */ void getHostState(std::shared_ptr<SystemAsyncResp> aResp) { - CROW_LOG_DEBUG << "Get host information."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Get host information."; + crow::connections::systemBus->async_method_call( [aResp{std::move(aResp)}](const boost::system::error_code ec, const PropertiesType &properties) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; aResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Got " << properties.size() << "host properties."; + BMCWEB_LOG_DEBUG << "Got " << properties.size() << "host properties."; for (const auto &property : properties) { if (property.first == "CurrentHostState") { const std::string *s = - mapbox::get_ptr<const std::string>(property.second); - CROW_LOG_DEBUG << "Host state: " << *s; + mapbox::getPtr<const std::string>(property.second); + BMCWEB_LOG_DEBUG << "Host state: " << *s; if (nullptr != s) { const auto pos = s->rfind('.'); if (pos != std::string::npos) { // Verify Host State if (s->substr(pos + 1) == "Running") { - aResp->res.json_value["PowerState"] = "On"; - aResp->res.json_value["Status"]["State"] = "Enabled"; + aResp->res.jsonValue["PowerState"] = "On"; + aResp->res.jsonValue["Status"]["State"] = "Enabled"; } else { - aResp->res.json_value["PowerState"] = "Off"; - aResp->res.json_value["Status"]["State"] = "Disabled"; + aResp->res.jsonValue["PowerState"] = "Off"; + aResp->res.jsonValue["Status"]["State"] = "Disabled"; } } } @@ -484,7 +484,7 @@ class SystemsCollection : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // Get board list, and call the below callback for JSON preparation provider.getBaseboardList( @@ -499,7 +499,7 @@ class SystemsCollection : public Node { // Then attach members, count size and return, Node::json["Members"] = boardArray; Node::json["Members@odata.count"] = boardArray.size(); - res.json_value = Node::json; + res.jsonValue = Node::json; } else { // ... otherwise, return INTERNALL ERROR res.result(boost::beast::http::status::internal_server_error); @@ -555,7 +555,7 @@ class Systems : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // Check if there is required param, truly entering this shall be // impossible @@ -567,8 +567,8 @@ class Systems : public Node { const std::string &name = params[0]; - res.json_value = Node::json; - res.json_value["@odata.id"] = "/redfish/v1/Systems/" + name; + res.jsonValue = Node::json; + res.jsonValue["@odata.id"] = "/redfish/v1/Systems/" + name; auto asyncResp = std::make_shared<SystemAsyncResp>(res); @@ -582,18 +582,18 @@ class Systems : public Node { aResp, [](const std::string &ledStatus, const std::shared_ptr<SystemAsyncResp> &aResp) { if (!ledStatus.empty()) { - aResp->res.json_value["IndicatorLED"] = ledStatus; + aResp->res.jsonValue["IndicatorLED"] = ledStatus; } }); } else { - aResp->res.json_value["IndicatorLED"] = "Off"; + aResp->res.jsonValue["IndicatorLED"] = "Off"; } }); provider.getComputerSystem(asyncResp, name); provider.getHostState(asyncResp); } - void doPatch(crow::response &res, const crow::request &req, + void doPatch(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { // Check if there is required param, truly entering this shall be // impossible @@ -614,7 +614,7 @@ class Systems : public Node { "IndicatorLED", patch, reqLedState, static_cast<int>(json_util::MessageSetting::TYPE_ERROR) | static_cast<int>(json_util::MessageSetting::MISSING), - res.json_value, std::string("/" + name + "/IndicatorLED")); + res.jsonValue, std::string("/" + name + "/IndicatorLED")); if ((r != json_util::Result::SUCCESS) || (reqLedState == nullptr)) { res.result(boost::beast::http::status::bad_request); res.end(); @@ -631,28 +631,28 @@ class Systems : public Node { // Update led status auto asyncResp = std::make_shared<SystemAsyncResp>(res); - res.json_value = Node::json; - res.json_value["@odata.id"] = "/redfish/v1/Systems/" + name; + res.jsonValue = Node::json; + res.jsonValue["@odata.id"] = "/redfish/v1/Systems/" + name; provider.getHostState(asyncResp); provider.getComputerSystem(asyncResp, name); if (dbusLedState.empty()) { messages::addMessageToJsonRoot( - res.json_value, + res.jsonValue, messages::propertyValueNotInList(*reqLedState, "IndicatorLED")); } else { // Update led group - CROW_LOG_DEBUG << "Update led group."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Update led group."; + crow::connections::systemBus->async_method_call( [&, asyncResp{std::move(asyncResp)} ]( const boost::system::error_code ec) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; asyncResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Led group update done."; + BMCWEB_LOG_DEBUG << "Led group update done."; }, "xyz.openbmc_project.LED.GroupManager", "/xyz/openbmc_project/led/groups/enclosure_identify", @@ -661,17 +661,17 @@ class Systems : public Node { sdbusplus::message::variant<bool>( (dbusLedState == "Off" ? false : true))); // Update identify led status - CROW_LOG_DEBUG << "Update led SoftwareInventoryCollection."; - crow::connections::system_bus->async_method_call( + BMCWEB_LOG_DEBUG << "Update led SoftwareInventoryCollection."; + crow::connections::systemBus->async_method_call( [&, asyncResp{std::move(asyncResp)} ]( const boost::system::error_code ec) { if (ec) { - CROW_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; asyncResp->setErrorStatus(); return; } - CROW_LOG_DEBUG << "Led state update done."; - res.json_value["IndicatorLED"] = *reqLedState; + BMCWEB_LOG_DEBUG << "Led state update done."; + res.jsonValue["IndicatorLED"] = *reqLedState; }, "xyz.openbmc_project.LED.Controller.identify", "/xyz/openbmc_project/led/physical/identify", diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp index c1b9ada090..8fb291b9bb 100644 --- a/redfish-core/lib/thermal.hpp +++ b/redfish-core/lib/thermal.hpp @@ -39,18 +39,18 @@ class Thermal : public Node { } private: - void doGet(crow::response& res, const crow::request& req, + void doGet(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { if (params.size() != 1) { res.result(boost::beast::http::status::internal_server_error); res.end(); return; } - const std::string& chassis_name = params[0]; + const std::string& chassisName = params[0]; - res.json_value = Node::json; + res.jsonValue = Node::json; auto asyncResp = std::make_shared<SensorsAsyncResp>( - res, chassis_name, + res, chassisName, std::initializer_list<const char*>{ "/xyz/openbmc_project/sensors/fan", "/xyz/openbmc_project/sensors/temperature"}); diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index de659bcc1e..2ffa82ccef 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -24,14 +24,14 @@ class OnDemandSoftwareInventoryProvider { public: template <typename CallbackFunc> void get_all_software_inventory_object(CallbackFunc &&callback) { - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [callback{std::move(callback)}]( const boost::system::error_code error_code, const std::vector<std::pair< std::string, std::vector<std::pair<std::string, std::vector<std::string>>>>> &subtree) { - CROW_LOG_DEBUG << "get all software inventory object callback..."; + BMCWEB_LOG_DEBUG << "get all software inventory object callback..."; if (error_code) { // Something wrong on DBus, the error_code is not important at this // moment, just return success=false, and empty output. Since size @@ -42,10 +42,10 @@ class OnDemandSoftwareInventoryProvider { } if (subtree.empty()) { - CROW_LOG_DEBUG << "subtree empty"; + BMCWEB_LOG_DEBUG << "subtree empty"; callback(false, subtree); } else { - CROW_LOG_DEBUG << "subtree has something"; + BMCWEB_LOG_DEBUG << "subtree has something"; callback(true, subtree); } }, @@ -81,9 +81,9 @@ class UpdateService : public Node { } private: - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { - res.json_value = Node::json; + res.jsonValue = Node::json; res.end(); } }; @@ -117,10 +117,10 @@ class SoftwareInventoryCollection : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { - res.json_value = Node::json; - software_inventory_provider.get_all_software_inventory_object( + res.jsonValue = Node::json; + softwareInventoryProvider.get_all_software_inventory_object( [&](const bool &success, const std::vector<std::pair< std::string, @@ -133,12 +133,12 @@ class SoftwareInventoryCollection : public Node { } if (subtree.empty()) { - CROW_LOG_DEBUG << "subtree empty!!"; + BMCWEB_LOG_DEBUG << "subtree empty!!"; res.end(); return; } - res.json_value["Members"] = nlohmann::json::array(); + res.jsonValue["Members"] = nlohmann::json::array(); for (auto &obj : subtree) { const std::vector<std::pair<std::string, std::vector<std::string>>> @@ -146,14 +146,14 @@ class SoftwareInventoryCollection : public Node { for (auto &conn : connections) { const std::string connectionName = conn.first; - CROW_LOG_DEBUG << "connectionName = " << connectionName; - CROW_LOG_DEBUG << "obj.first = " << obj.first; + BMCWEB_LOG_DEBUG << "connectionName = " << connectionName; + BMCWEB_LOG_DEBUG << "obj.first = " << obj.first; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [&](const boost::system::error_code error_code, const boost::container::flat_map<std::string, VariantType> &propertiesList) { - CROW_LOG_DEBUG << "safe returned in lambda function"; + BMCWEB_LOG_DEBUG << "safe returned in lambda function"; if (error_code) { res.result( boost::beast::http::status::internal_server_error); @@ -164,15 +164,15 @@ class SoftwareInventoryCollection : public Node { VariantType>::const_iterator it = propertiesList.find("Purpose"); const std::string &sw_inv_purpose = - *(mapbox::get_ptr<const std::string>(it->second)); + *(mapbox::getPtr<const std::string>(it->second)); std::size_t last_pos = sw_inv_purpose.rfind("."); if (last_pos != std::string::npos) { - res.json_value["Members"].push_back( + res.jsonValue["Members"].push_back( {{"@odata.id", "/redfish/v1/UpdateService/FirmwareInventory/" + sw_inv_purpose.substr(last_pos + 1)}}); - res.json_value["Members@odata.count"] = - res.json_value["Members"].size(); + res.jsonValue["Members@odata.count"] = + res.jsonValue["Members"].size(); res.end(); } @@ -183,7 +183,7 @@ class SoftwareInventoryCollection : public Node { } }); } - OnDemandSoftwareInventoryProvider software_inventory_provider; + OnDemandSoftwareInventoryProvider softwareInventoryProvider; }; /** * Chassis override class for delivering Chassis Schema @@ -217,9 +217,9 @@ class SoftwareInventory : public Node { /** * Functions triggers appropriate requests on DBus */ - void doGet(crow::response &res, const crow::request &req, + void doGet(crow::Response &res, const crow::Request &req, const std::vector<std::string> ¶ms) override { - res.json_value = Node::json; + res.jsonValue = Node::json; if (params.size() != 1) { res.result(boost::beast::http::status::internal_server_error); @@ -228,16 +228,16 @@ class SoftwareInventory : public Node { } const std::string &sw_id = params[0]; - res.json_value["@odata.id"] = + res.jsonValue["@odata.id"] = "/redfish/v1/UpdateService/FirmwareInventory/" + sw_id; - software_inventory_provider.get_all_software_inventory_object( + softwareInventoryProvider.get_all_software_inventory_object( [&, id{std::string(sw_id)} ]( const bool &success, const std::vector<std::pair< std::string, std::vector<std::pair<std::string, std::vector<std::string>>>>> &subtree) { - CROW_LOG_DEBUG << "doGet callback..."; + BMCWEB_LOG_DEBUG << "doGet callback..."; if (!success) { res.result(boost::beast::http::status::internal_server_error); res.end(); @@ -245,7 +245,7 @@ class SoftwareInventory : public Node { } if (subtree.empty()) { - CROW_LOG_DEBUG << "subtree empty!!"; + BMCWEB_LOG_DEBUG << "subtree empty!!"; res.end(); return; } @@ -256,10 +256,10 @@ class SoftwareInventory : public Node { for (auto &conn : connections) { const std::string connectionName = conn.first; - CROW_LOG_DEBUG << "connectionName = " << connectionName; - CROW_LOG_DEBUG << "obj.first = " << obj.first; + BMCWEB_LOG_DEBUG << "connectionName = " << connectionName; + BMCWEB_LOG_DEBUG << "obj.first = " << obj.first; - crow::connections::system_bus->async_method_call( + crow::connections::systemBus->async_method_call( [&, id{std::string(id)} ]( const boost::system::error_code error_code, const boost::container::flat_map<std::string, VariantType> @@ -274,21 +274,21 @@ class SoftwareInventory : public Node { VariantType>::const_iterator it = propertiesList.find("Purpose"); if (it == propertiesList.end()) { - CROW_LOG_DEBUG << "Can't find property \"Purpose\"!"; + BMCWEB_LOG_DEBUG << "Can't find property \"Purpose\"!"; return; } const std::string &sw_inv_purpose = - *(mapbox::get_ptr<const std::string>(it->second)); - CROW_LOG_DEBUG << "sw_inv_purpose = " << sw_inv_purpose; + *(mapbox::getPtr<const std::string>(it->second)); + BMCWEB_LOG_DEBUG << "sw_inv_purpose = " << sw_inv_purpose; if (boost::ends_with(sw_inv_purpose, "." + id)) { it = propertiesList.find("Version"); if (it == propertiesList.end()) { - CROW_LOG_DEBUG << "Can't find property \"Version\"!"; + BMCWEB_LOG_DEBUG << "Can't find property \"Version\"!"; return; } - res.json_value["Version"] = - *(mapbox::get_ptr<const std::string>(it->second)); - res.json_value["Id"] = id; + res.jsonValue["Version"] = + *(mapbox::getPtr<const std::string>(it->second)); + res.jsonValue["Id"] = id; res.end(); } @@ -300,7 +300,7 @@ class SoftwareInventory : public Node { }); } - OnDemandSoftwareInventoryProvider software_inventory_provider; + OnDemandSoftwareInventoryProvider softwareInventoryProvider; }; } // namespace redfish |