diff options
-rw-r--r-- | fan_enclosure.cpp | 37 | ||||
-rw-r--r-- | fan_enclosure.hpp | 5 |
2 files changed, 38 insertions, 4 deletions
diff --git a/fan_enclosure.cpp b/fan_enclosure.cpp index 5461b08..2bed251 100644 --- a/fan_enclosure.cpp +++ b/fan_enclosure.cpp @@ -9,6 +9,15 @@ namespace fan namespace presence { +//TODO Should get these from phosphor-objmgr config.h +constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; +constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper"; +constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; + +//TODO Should get these from phosphor-inventory-manager config.h +constexpr auto INVENTORY_PATH = "/xyz/openbmc_project/inventory"; +constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager"; + FanEnclosure::ObjectMap FanEnclosure::getObjectMap() { ObjectMap invObj; @@ -28,15 +37,39 @@ FanEnclosure::ObjectMap FanEnclosure::getObjectMap() return invObj; } -void FanEnclosure::addInventory() +std::string FanEnclosure::getInvService() { - //TODO Add this fan to inventory + auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, + MAPPER_PATH, + MAPPER_INTERFACE, + "GetObject"); + + mapperCall.append(INVENTORY_PATH); + mapperCall.append(std::vector<std::string>({INVENTORY_INTF})); + + auto mapperResponseMsg = bus.call(mapperCall); + if (mapperResponseMsg.is_method_error()) + { + //TODO Retry or throw exception/log error? + } + + std::map<std::string, std::vector<std::string>> mapperResponse; + mapperResponseMsg.read(mapperResponse); + + if (mapperResponse.empty()) + { + //TODO Nothing found, throw exception/log error? + } + + return mapperResponse.begin()->first; } void FanEnclosure::updInventory() { //Get inventory object for this fan ObjectMap invObj = getObjectMap(); + //Get inventory manager service name from mapper + std::string invService = getInvService(); //TODO Update inventory for this fan } diff --git a/fan_enclosure.hpp b/fan_enclosure.hpp index 3876cea..cd9f689 100644 --- a/fan_enclosure.hpp +++ b/fan_enclosure.hpp @@ -40,7 +40,7 @@ class FanEnclosure fanDesc(std::get<1>(fanProp)) { //Add this fan to inventory - addInventory(); + updInventory(); } void updInventory(); @@ -53,7 +53,8 @@ class FanEnclosure const std::string fanDesc; std::vector<std::unique_ptr<Sensor>> sensors; - void addInventory(); + //TODO openbmc/openbmc#1299 - Move getInvService() to a utility file + std::string getInvService(); ObjectMap getObjectMap(); }; |