summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--fan_enclosure.cpp31
-rw-r--r--fan_enclosure.hpp12
2 files changed, 34 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(
diff --git a/fan_enclosure.hpp b/fan_enclosure.hpp
index 5c6a040..3876cea 100644
--- a/fan_enclosure.hpp
+++ b/fan_enclosure.hpp
@@ -14,6 +14,17 @@ namespace presence
class FanEnclosure
{
+ using Property = std::string;
+ using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
+ // Association between property and its value
+ using PropertyMap = std::map<Property, Value>;
+ using Interface = std::string;
+ // Association between interface and the dbus property
+ using InterfaceMap = std::map<Interface, PropertyMap>;
+ using Object = sdbusplus::message::object_path;
+ // Association between object and the interface
+ using ObjectMap = std::map<Object, InterfaceMap>;
+
public:
FanEnclosure() = delete;
FanEnclosure(const FanEnclosure&) = delete;
@@ -43,6 +54,7 @@ class FanEnclosure
std::vector<std::unique_ptr<Sensor>> sensors;
void addInventory();
+ ObjectMap getObjectMap();
};
OpenPOWER on IntegriCloud