summaryrefslogtreecommitdiffstats
path: root/fan_enclosure.cpp
diff options
context:
space:
mode:
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