diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-08-27 08:13:37 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-09-08 18:49:51 +0000 |
commit | e602709d4b95895a72d77f2cda1259c2ff9b8b1b (patch) | |
tree | 9e611532486e1a5e61341c4cef82d1641365492d | |
parent | 62736ecab919357d85d8a578bd0df33d5038e578 (diff) | |
download | phosphor-host-ipmid-e602709d4b95895a72d77f2cda1259c2ff9b8b1b.tar.gz phosphor-host-ipmid-e602709d4b95895a72d77f2cda1259c2ff9b8b1b.zip |
settings: handle multiple objects/interfaces
Handle the fact that a settings object can now implement multiple
interfaces, and also the fact that multiple settings objects
can implement the same interface.
Change-Id: Icf55b08fe2d355a10f7007489dfddb128e05d90e
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r-- | chassishandler.cpp | 10 | ||||
-rw-r--r-- | ipmid.cpp | 5 | ||||
-rw-r--r-- | settings.cpp | 15 | ||||
-rw-r--r-- | settings.hpp | 6 |
4 files changed, 22 insertions, 14 deletions
diff --git a/chassishandler.cpp b/chassishandler.cpp index bb6d5c2..de22d80 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -734,7 +734,7 @@ ipmi_ret_t ipmi_get_chassis_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd, using namespace chassis::internal::cache; using namespace power_policy; - const auto& powerRestoreSetting = objects.map.at(powerRestoreIntf); + const auto& powerRestoreSetting = objects.map.at(powerRestoreIntf).front(); auto method = dbus.new_method_call( objects.service(powerRestoreSetting, powerRestoreIntf).c_str(), @@ -1096,7 +1096,7 @@ ipmi_ret_t ipmi_chassis_get_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, using namespace chassis::internal; using namespace chassis::internal::cache; - const auto& bootSourceSetting = objects.map.at(bootSourceIntf); + const auto& bootSourceSetting = objects.map.at(bootSourceIntf).front(); auto method = dbus.new_method_call( objects.service(bootSourceSetting, bootSourceIntf).c_str(), @@ -1117,7 +1117,7 @@ ipmi_ret_t ipmi_chassis_get_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, auto bootSource = Source::convertSourcesFromString(result.get<std::string>()); - const auto& bootModeSetting = objects.map.at(bootModeIntf); + const auto& bootModeSetting = objects.map.at(bootModeIntf).front(); method = dbus.new_method_call( objects.service(bootModeSetting, bootModeIntf).c_str(), bootModeSetting.c_str(), @@ -1235,7 +1235,7 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, sdbusplus::message::variant<std::string> property = convertForMessage(sourceItr->second); const auto& bootSourceSetting = - objects.map.at(bootSourceIntf); + objects.map.at(bootSourceIntf).front(); auto method = dbus.new_method_call( objects.service(bootSourceSetting, bootSourceIntf).c_str(), @@ -1257,7 +1257,7 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, { sdbusplus::message::variant<std::string> property = convertForMessage(modeItr->second); - const auto& bootModeSetting = objects.map.at(bootModeIntf); + const auto& bootModeSetting = objects.map.at(bootModeIntf).front(); auto method = dbus.new_method_call( objects.service(bootModeSetting, bootModeIntf).c_str(), @@ -308,7 +308,7 @@ void cache_restricted_mode() using namespace internal::cache; sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); const auto& restrictionModeSetting = - objects->map.at(restrictionModeIntf); + objects->map.at(restrictionModeIntf).front(); auto method = dbus.new_method_call( objects->service(restrictionModeSetting, restrictionModeIntf).c_str(), @@ -596,7 +596,8 @@ int main(int argc, char *argv[]) sdbusplus::bus::match_t restrictedModeMatch( dbus, sdbusRule::propertiesChanged( - objects->map.at(restrictionModeIntf), restrictionModeIntf), + objects->map.at(restrictionModeIntf).front(), + restrictionModeIntf), handle_restricted_mode_change); for (;;) { diff --git a/settings.cpp b/settings.cpp index cb86d99..59f9f33 100644 --- a/settings.cpp +++ b/settings.cpp @@ -46,8 +46,19 @@ Objects::Objects(sdbusplus::bus::bus& bus, for (auto& iter : result) { const auto& path = iter.first; - auto& interface = iter.second.begin()->second[0]; - map.emplace(std::move(interface), path); + for (auto& interface : iter.second.begin()->second) + { + auto found = map.find(interface); + if (map.end() != found) + { + auto& paths = found->second; + paths.push_back(path); + } + else + { + map.emplace(std::move(interface), std::vector<Path>({path})); + } + } } } diff --git a/settings.hpp b/settings.hpp index 60ee4d4..ec1d913 100644 --- a/settings.hpp +++ b/settings.hpp @@ -42,12 +42,8 @@ struct Objects */ Service service(const Path& path, const Interface& interface) const; - // TODO openbmc/openbmc#2058 - This will break when multiple settings, - // or in general multiple objects implement a single setting interface. - // For instance this will break for a 2-blade server, because we'd have - // 2 sets of settings objects. Need to revisit and fix this. /** @brief map of settings objects */ - std::map<Interface, Path> map; + std::map<Interface, std::vector<Path>> map; /** @brief The Dbus bus object */ sdbusplus::bus::bus& bus; |