summaryrefslogtreecommitdiffstats
path: root/fan_enclosure.cpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2017-02-20 16:01:21 -0600
committerMatthew Barth <msbarth@us.ibm.com>2017-03-15 13:46:31 -0500
commit1562ac70266a50043ec44c8adcafaea4a97dfca5 (patch)
treedf6a6c123f8a4983e071136daadea7a9804bc6df /fan_enclosure.cpp
parentcd4f4d1a0a49f4ed43b3a773d2e2046cc15ef1d1 (diff)
downloadphosphor-fan-presence-1562ac70266a50043ec44c8adcafaea4a97dfca5.tar.gz
phosphor-fan-presence-1562ac70266a50043ec44c8adcafaea4a97dfca5.zip
Function to setup fan inventory object map
The getObjectMap() function constructs the object map needed by inventory manager for the object path, interface, and properties of a fan. Change-Id: I8cce5cd611d3a0f7a2079b81f280b261aee486e2 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'fan_enclosure.cpp')
-rw-r--r--fan_enclosure.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/fan_enclosure.cpp b/fan_enclosure.cpp
index b02d6e1..5461b08 100644
--- a/fan_enclosure.cpp
+++ b/fan_enclosure.cpp
@@ -9,6 +9,25 @@ namespace fan
namespace presence
{
+FanEnclosure::ObjectMap FanEnclosure::getObjectMap()
+{
+ ObjectMap invObj;
+ InterfaceMap invIntf;
+ PropertyMap invProp;
+ auto presPred = [](auto const& s) {return s->isPresent();};
+ // Determine if all sensors show fan is not present
+ auto isPresent = std::any_of(sensors.begin(),
+ sensors.end(),
+ presPred);
+ invProp.emplace("Present", isPresent);
+ invProp.emplace("PrettyName", fanDesc);
+ invIntf.emplace("xyz.openbmc_project.Inventory.Item", std::move(invProp));
+ Object fanInvPath = invPath;
+ invObj.emplace(std::move(fanInvPath), std::move(invIntf));
+
+ return invObj;
+}
+
void FanEnclosure::addInventory()
{
//TODO Add this fan to inventory
@@ -16,15 +35,9 @@ void FanEnclosure::addInventory()
void FanEnclosure::updInventory()
{
- auto presPred = [](auto const& s) {return s->isPresent();};
- // Determine if all sensors show fan is not present
- auto isPresent = std::any_of(FanEnclosure::sensors.begin(),
- FanEnclosure::sensors.end(),
- presPred);
- if (!isPresent)
- {
- //TODO Update inventory for this fan
- }
+ //Get inventory object for this fan
+ ObjectMap invObj = getObjectMap();
+ //TODO Update inventory for this fan
}
void FanEnclosure::addSensor(
OpenPOWER on IntegriCloud