Fix get all property values under the client interface
If there is no Client interface in the current path when calling the
GetManagedObjects method, it should continue to traverse all
interfaces under the next path instead of entering the catch to
record the `map::at` error. This is not an expected behavior.
Change-Id: Ifd51ec772a7fc5c870dc78323f19f8071c8cab24
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/snmp_util.cpp b/snmp_util.cpp
index 818bdc1..bc46c99 100644
--- a/snmp_util.cpp
+++ b/snmp_util.cpp
@@ -115,12 +115,16 @@
{
std::vector<std::string> managers;
auto& bus = getBus();
- auto objTree = phosphor::getManagedObjects(bus, busName, root);
- for (const auto& objIter : objTree)
+ try
{
- try
+ auto objTree = phosphor::getManagedObjects(bus, busName, root);
+ for (const auto& [_, intfMap] : objTree)
{
- auto& intfMap = objIter.second;
+ if (!intfMap.contains(clientIntf))
+ {
+ continue;
+ }
+
auto& snmpClientProps = intfMap.at(clientIntf);
auto& address =
std::get<std::string>(snmpClientProps.at("Address"));
@@ -134,11 +138,12 @@
}
managers.push_back(mgr);
}
- catch (const std::exception& e)
- {
- lg2::error("Invalid address: {ERROR}", "ERROR", e);
- }
}
+ catch (const std::exception& e)
+ {
+ lg2::error("Invalid address: {ERROR}", "ERROR", e);
+ }
+
return managers;
}