getConfig.cpp (3cf9e80680a02a33c428a82769a697373612c9be) | getConfig.cpp (15b63e12bdc3f3116fb841349dd4f1cd17a8398b) |
---|---|
1 2#include "getConfig.hpp" 3 4#include <boost/asio/steady_timer.hpp> 5#include <phosphor-logging/lg2.hpp> 6#include <sdbusplus/asio/connection.hpp> 7 8#include <chrono> --- 14 unchanged lines hidden (view full) --- 23constexpr const char* interface = "xyz.openbmc_project.ObjectMapper"; 24constexpr const char* subtree = "GetSubTree"; 25} // namespace mapper 26 27using GetSubTreeType = std::vector< 28 std::pair<std::string, 29 std::vector<std::pair<std::string, std::vector<std::string>>>>>; 30 | 1 2#include "getConfig.hpp" 3 4#include <boost/asio/steady_timer.hpp> 5#include <phosphor-logging/lg2.hpp> 6#include <sdbusplus/asio/connection.hpp> 7 8#include <chrono> --- 14 unchanged lines hidden (view full) --- 23constexpr const char* interface = "xyz.openbmc_project.ObjectMapper"; 24constexpr const char* subtree = "GetSubTree"; 25} // namespace mapper 26 27using GetSubTreeType = std::vector< 28 std::pair<std::string, 29 std::vector<std::pair<std::string, std::vector<std::string>>>>>; 30 |
31void GetStorageConfiguration::getStorageInfo(const std::string& path, 32 const std::string& owner, 33 size_t retries) | 31void GetStorageConfiguration::getStorageInfo( 32 const std::string& path, const std::string& owner, size_t retries) |
34{ 35 std::shared_ptr<GetStorageConfiguration> self = shared_from_this(); 36 self->dbusConnection->async_method_call( 37 [self, path, owner, retries]( 38 const boost::system::error_code ec, 39 boost::container::flat_map<std::string, BasicVariantType>& data) { | 33{ 34 std::shared_ptr<GetStorageConfiguration> self = shared_from_this(); 35 self->dbusConnection->async_method_call( 36 [self, path, owner, retries]( 37 const boost::system::error_code ec, 38 boost::container::flat_map<std::string, BasicVariantType>& data) { |
40 if (ec) 41 { 42 lg2::error( 43 "Error getting properties for {PATH}: {RETRIES} retries left", 44 "PATH", path, "RETRIES", retries - 1, "REDFISH_MESSAGE_ID", 45 std::string("OpenBMC.0.1.GetStorageInfoFail")); 46 if (retries == 0U) | 39 if (ec) |
47 { | 40 { |
48 return; 49 } 50 51 auto timer = std::make_shared<boost::asio::steady_timer>( 52 self->dbusConnection->get_io_context()); 53 timer->expires_after(std::chrono::seconds(10)); 54 timer->async_wait([self, timer, path, owner, 55 retries](boost::system::error_code ec) { 56 if (ec) | 41 lg2::error( 42 "Error getting properties for {PATH}: {RETRIES} retries left", 43 "PATH", path, "RETRIES", retries - 1, "REDFISH_MESSAGE_ID", 44 std::string("OpenBMC.0.1.GetStorageInfoFail")); 45 if (retries == 0U) |
57 { | 46 { |
58 lg2::error("Timer error!"); | |
59 return; 60 } | 47 return; 48 } |
61 self->getStorageInfo(path, owner, retries - 1); 62 }); | |
63 | 49 |
64 return; 65 } | 50 auto timer = std::make_shared<boost::asio::steady_timer>( 51 self->dbusConnection->get_io_context()); 52 timer->expires_after(std::chrono::seconds(10)); 53 timer->async_wait([self, timer, path, owner, 54 retries](boost::system::error_code ec) { 55 if (ec) 56 { 57 lg2::error("Timer error!"); 58 return; 59 } 60 self->getStorageInfo(path, owner, retries - 1); 61 }); |
66 | 62 |
67 self->respData[path] = std::move(data); 68 }, | 63 return; 64 } 65 66 self->respData[path] = std::move(data); 67 }, |
69 owner, path, "org.freedesktop.DBus.Properties", "GetAll", 70 emmcConfigInterface); 71} 72 73void GetStorageConfiguration::getConfiguration() 74{ 75 std::shared_ptr<GetStorageConfiguration> self = shared_from_this(); 76 dbusConnection->async_method_call( 77 [self](const boost::system::error_code ec, const GetSubTreeType& ret) { | 68 owner, path, "org.freedesktop.DBus.Properties", "GetAll", 69 emmcConfigInterface); 70} 71 72void GetStorageConfiguration::getConfiguration() 73{ 74 std::shared_ptr<GetStorageConfiguration> self = shared_from_this(); 75 dbusConnection->async_method_call( 76 [self](const boost::system::error_code ec, const GetSubTreeType& ret) { |
78 if (ec) 79 { 80 lg2::error("Error calling mapper"); 81 return; 82 } 83 for (const auto& [objPath, objDict] : ret) 84 { 85 if (objDict.empty()) | 77 if (ec) |
86 { | 78 { |
79 lg2::error("Error calling mapper"); |
|
87 return; 88 } | 80 return; 81 } |
89 const std::string& objOwner = objDict.begin()->first; 90 /* Look for the config interface exposed by this object. */ 91 for (const std::string& interface : objDict.begin()->second) | 82 for (const auto& [objPath, objDict] : ret) |
92 { | 83 { |
93 if (interface.compare(emmcConfigInterface) == 0) | 84 if (objDict.empty()) |
94 { | 85 { |
95 /* Get the properties exposed by this interface. */ 96 self->getStorageInfo(objPath, objOwner); | 86 return; |
97 } | 87 } |
88 const std::string& objOwner = objDict.begin()->first; 89 /* Look for the config interface exposed by this object. */ 90 for (const std::string& interface : objDict.begin()->second) 91 { 92 if (interface.compare(emmcConfigInterface) == 0) 93 { 94 /* Get the properties exposed by this interface. */ 95 self->getStorageInfo(objPath, objOwner); 96 } 97 } |
|
98 } | 98 } |
99 } 100 }, | 99 }, |
101 mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/", 102 0, std::vector<const char*>(1, emmcConfigInterface)); 103} 104 105GetStorageConfiguration::~GetStorageConfiguration() 106{ 107 callback(respData); 108} 109 110} // namespace estoraged | 100 mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/", 101 0, std::vector<const char*>(1, emmcConfigInterface)); 102} 103 104GetStorageConfiguration::~GetStorageConfiguration() 105{ 106 callback(respData); 107} 108 109} // namespace estoraged |