diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-11-16 15:21:13 -0600 |
---|---|---|
committer | Matthew Barth <msbarth@linux.vnet.ibm.com> | 2017-12-05 16:11:12 +0000 |
commit | 51dd1856e142d30d0d2c351f3d5eec15a11161b0 (patch) | |
tree | 7b177e113d782242c5d1ffaf46119a8e42337c3f /utility.hpp | |
parent | d5cfdbe0240f9a5cb0d29fa6e384ad19b2b32cf3 (diff) | |
download | phosphor-fan-presence-51dd1856e142d30d0d2c351f3d5eec15a11161b0.tar.gz phosphor-fan-presence-51dd1856e142d30d0d2c351f3d5eec15a11161b0.zip |
Update fan inventory method
Use the methods provided within sdbusplus.hpp to update fan inventory
along with prepping inventory to be updated for each fan rotor sensor's
functional state.
Change-Id: I7d3026d289b1dd22cd4e7b4457c4d4396309c0b5
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'utility.hpp')
-rw-r--r-- | utility.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/utility.hpp b/utility.hpp index 32d055e..bb23dea 100644 --- a/utility.hpp +++ b/utility.hpp @@ -20,6 +20,17 @@ namespace fan namespace util { +constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; +constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; +constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; + +constexpr auto INVENTORY_PATH = "/xyz/openbmc_project/inventory"; +constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager"; + +constexpr auto OPERATIONAL_STATUS_INTF = + "xyz.openbmc_project.State.Decorator.OperationalStatus"; +constexpr auto FUNCTIONAL_PROPERTY = "Functional"; + class FileDescriptor { public: @@ -90,6 +101,43 @@ std::string getService(const std::string& path, const std::string& interface, sdbusplus::bus::bus& bus); +/** + * @brief Get the object map for creating or updating an object property + * + * @param[in] path - The dbus object path name + * @param[in] intf - The dbus interface + * @param[in] prop - The dbus property + * @param[in] value - The property value + * + * @return - The full object path containing the property value + */ +template <typename T> +auto getObjMap(const std::string& path, + const std::string& intf, + const std::string& prop, + const T& value) +{ + using Property = std::string; + using Value = sdbusplus::message::variant<T>; + using PropertyMap = std::map<Property, Value>; + + using Interface = std::string; + using InterfaceMap = std::map<Interface, PropertyMap>; + + using Object = sdbusplus::message::object_path; + using ObjectMap = std::map<Object, InterfaceMap>; + + ObjectMap objectMap; + InterfaceMap interfaceMap; + PropertyMap propertyMap; + + propertyMap.emplace(prop, value); + interfaceMap.emplace(intf, std::move(propertyMap)); + objectMap.emplace(path, std::move(interfaceMap)); + + return objectMap; +} + } } } |