Move to subproject to enable both projects
Yocto builds need each component to build individually, but meson wants
them to build as a single project. This follows google-misc and moves
to subprojects.
It also enables callback-manager in the build and fixes some build
errors and warnings.
Change-Id: Ie56141bf86b6d9c6b27eb697944fbc392e374c22
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/subprojects/callback-manager/include/callback_manager.hpp b/subprojects/callback-manager/include/callback_manager.hpp
new file mode 100644
index 0000000..e4776c8
--- /dev/null
+++ b/subprojects/callback-manager/include/callback_manager.hpp
@@ -0,0 +1,95 @@
+#pragma once
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+
+#include <iostream>
+
+using Association = std::tuple<std::string, std::string, std::string>;
+
+constexpr const char* rootPath = "/xyz/openbmc_project/CallbackManager";
+constexpr const char* sensorPath = "/xyz/openbmc_project/sensors";
+
+constexpr const char* globalInventoryIface =
+ "xyz.openbmc_project.Inventory.Item.Global";
+constexpr const char* associationIface =
+ "xyz.openbmc_project.Association.Definitions";
+
+namespace threshold
+{
+constexpr const char* critical = "critical";
+constexpr const char* warning = "warning";
+} // namespace threshold
+
+struct AssociationManager
+{
+ AssociationManager(sdbusplus::asio::object_server& objectServerIn,
+ std::shared_ptr<sdbusplus::asio::connection>& /*conn*/) :
+ objectServer(objectServerIn),
+ association(objectServer.add_interface(rootPath, associationIface)),
+ sensorAssociation(
+ objectServer.add_interface(sensorPath, associationIface))
+ {
+ association->register_property("Associations", std::set<Association>());
+ sensorAssociation->register_property("Associations",
+ std::set<Association>());
+ association->initialize();
+ sensorAssociation->initialize();
+ }
+ ~AssociationManager()
+ {
+ objectServer.remove_interface(association);
+ objectServer.remove_interface(sensorAssociation);
+ }
+
+ void setLocalAssociations(const std::vector<std::string>& fatal,
+ const std::vector<std::string>& critical,
+ const std::vector<std::string>& warning)
+ {
+ std::set<Association> result;
+
+ // fatal maps to redfish critical as refish only has 3 states and LED
+ // has 4
+ for (const std::string& path : fatal)
+ {
+ result.emplace(threshold::critical, "", path);
+ }
+ for (const std::string& path : critical)
+ {
+ result.emplace(threshold::warning, "", path);
+ }
+ for (const std::string& path : warning)
+ {
+ result.emplace(threshold::warning, "", path);
+ }
+ association->set_property("Associations", result);
+ }
+
+ void setSensorAssociations(const std::vector<std::string>& critical,
+ const std::vector<std::string>& warning)
+ {
+ std::set<Association> result;
+ for (const std::string& path : critical)
+ {
+ if (!boost::starts_with(path, sensorPath))
+ {
+ continue;
+ }
+ result.emplace(threshold::critical, "", path);
+ }
+ for (const std::string& path : warning)
+ {
+ if (!boost::starts_with(path, sensorPath))
+ {
+ continue;
+ }
+ result.emplace(threshold::warning, "", path);
+ }
+ sensorAssociation->set_property("Associations", result);
+ }
+
+ sdbusplus::asio::object_server& objectServer;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> association;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> sensorAssociation;
+};