summaryrefslogtreecommitdiffstats
path: root/monitor/conditions.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-05-02 16:03:48 -0500
committerMatthew Barth <msbarth@us.ibm.com>2018-05-03 16:56:37 -0500
commit81748b1425e453b6a815a7b8ed2fa861d3068ac7 (patch)
treead4094ee41e9623f9d0433be246d601e92c837f1 /monitor/conditions.hpp
parent7311c39440a88c6dcf3e64e5ee05900488721fbc (diff)
downloadphosphor-fan-presence-81748b1425e453b6a815a7b8ed2fa861d3068ac7.tar.gz
phosphor-fan-presence-81748b1425e453b6a815a7b8ed2fa861d3068ac7.zip
Support optional conditions on creating fans
This adds the functional infrastructure to optionally attach a condition function to a fan definition. When a condition is defined on a fan, it must be true for a fan's associated functional properties to be created. When the given condition fails, that fan's functional properties will not be created by fan monitor. A fan without a defined condition will have all of its associated functional properties created. Example of generated condition (generation commit to follow): make_condition(condition::propertiesMatch( std::vector<PropertyState>{ PropertyState{ PropertyIdentity{ "/xyz/openbmc_project/inventory/system/chassis", "xyz.openbmc_project.Inventory.Decorator.CoolingType", "WaterCooled" }, static_cast<bool>(false) } } )), Tested: Fan functional properties are not created when a condition fails Fan functional properties are created when condition passes Fan functional properties are created when no condition exists Change-Id: I9ced2e520d2f97e6655c9417970b3e976d78fef4 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/conditions.hpp')
-rw-r--r--monitor/conditions.hpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/monitor/conditions.hpp b/monitor/conditions.hpp
new file mode 100644
index 0000000..76aa0de
--- /dev/null
+++ b/monitor/conditions.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "types.hpp"
+
+namespace phosphor
+{
+namespace fan
+{
+namespace monitor
+{
+
+/**
+ * @brief Create a condition function object
+ *
+ * @param[in] condition - The condition being created
+ *
+ * @return - The created condition function object
+ */
+template <typename T>
+auto make_condition(T&& condition)
+{
+ return Condition(std::forward<T>(condition));
+}
+
+namespace condition
+{
+
+/**
+ * @brief A condition that checks all properties match the given values
+ * @details Checks each property entry against its given value where all
+ * property values must match their given value for the condition to pass
+ *
+ * @param[in] propStates - List of property identifiers and their value
+ *
+ * @return Condition lambda function
+ * A Condition function that checks all properties match
+ */
+Condition propertiesMatch(std::vector<PropertyState>&& propStates);
+
+} // namespace condition
+} // namespace monitor
+} // namespace fan
+} // namespace phosphor
OpenPOWER on IntegriCloud