diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-02-20 16:09:21 -0600 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-03-15 13:46:31 -0500 |
commit | 736d1432e8b9d4c44b06e529e3c8cea1efe0b32e (patch) | |
tree | a164449623e9997fc05bb4ae894874ca11312934 | |
parent | 1562ac70266a50043ec44c8adcafaea4a97dfca5 (diff) | |
download | phosphor-fan-presence-736d1432e8b9d4c44b06e529e3c8cea1efe0b32e.tar.gz phosphor-fan-presence-736d1432e8b9d4c44b06e529e3c8cea1efe0b32e.zip |
Get inventory manager service name
Retrieve the inventory manager's service name from object mapper.
Change-Id: I56c67012105b5bc389763608c998ccc756b1104a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-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(); }; |