entity-manager: create power_status_monitor.cpp
These functions belong to PowerStatusMonitor class but were still in
utils.cpp.
Code was only moved and otherwise unchanged.
Tested: Inspection only.
Change-Id: I179eb53718df376116e056b1285f7d1eb4a0ec22
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/meson.build b/src/entity_manager/meson.build
index 0fe71dd..200c9f9 100644
--- a/src/entity_manager/meson.build
+++ b/src/entity_manager/meson.build
@@ -14,6 +14,7 @@
'dbus_interface.cpp',
'perform_scan.cpp',
'perform_probe.cpp',
+ 'power_status_monitor.cpp',
'overlay.cpp',
'topology.cpp',
'utils.cpp',
diff --git a/src/entity_manager/power_status_monitor.cpp b/src/entity_manager/power_status_monitor.cpp
new file mode 100644
index 0000000..cd8b9ca
--- /dev/null
+++ b/src/entity_manager/power_status_monitor.cpp
@@ -0,0 +1,61 @@
+#include "power_status_monitor.hpp"
+
+#include "utils.hpp"
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <sdbusplus/bus/match.hpp>
+
+namespace power
+{
+
+const static constexpr char* busname = "xyz.openbmc_project.State.Host";
+const static constexpr char* interface = "xyz.openbmc_project.State.Host";
+const static constexpr char* path = "/xyz/openbmc_project/state/host0";
+const static constexpr char* property = "CurrentHostState";
+
+bool PowerStatusMonitor::isPowerOn()
+{
+ if (!powerMatch)
+ {
+ throw std::runtime_error("Power Match Not Created");
+ }
+ return powerStatusOn;
+}
+
+void PowerStatusMonitor::setupPowerMatch(
+ const std::shared_ptr<sdbusplus::asio::connection>& conn)
+{
+ powerMatch = std::make_unique<sdbusplus::bus::match_t>(
+ static_cast<sdbusplus::bus_t&>(*conn),
+ "type='signal',interface='" +
+ std::string(em_utils::properties::interface) + "',path='" +
+ std::string(power::path) + "',arg0='" +
+ std::string(power::interface) + "'",
+ [this](sdbusplus::message_t& message) {
+ std::string objectName;
+ boost::container::flat_map<std::string, std::variant<std::string>>
+ values;
+ message.read(objectName, values);
+ auto findState = values.find(power::property);
+ if (findState != values.end())
+ {
+ powerStatusOn = boost::ends_with(
+ std::get<std::string>(findState->second), "Running");
+ }
+ });
+
+ conn->async_method_call(
+ [this](boost::system::error_code ec,
+ const std::variant<std::string>& state) {
+ if (ec)
+ {
+ return;
+ }
+ powerStatusOn =
+ boost::ends_with(std::get<std::string>(state), "Running");
+ },
+ power::busname, power::path, em_utils::properties::interface,
+ em_utils::properties::get, power::interface, power::property);
+}
+
+} // namespace power
diff --git a/src/entity_manager/power_status_monitor.hpp b/src/entity_manager/power_status_monitor.hpp
index 29840e2..e70031e 100644
--- a/src/entity_manager/power_status_monitor.hpp
+++ b/src/entity_manager/power_status_monitor.hpp
@@ -6,11 +6,6 @@
namespace power
{
-const static constexpr char* busname = "xyz.openbmc_project.State.Host";
-const static constexpr char* interface = "xyz.openbmc_project.State.Host";
-const static constexpr char* path = "/xyz/openbmc_project/state/host0";
-const static constexpr char* property = "CurrentHostState";
-
class PowerStatusMonitor
{
public:
diff --git a/src/entity_manager/utils.cpp b/src/entity_manager/utils.cpp
index 92dba87..90d53d1 100644
--- a/src/entity_manager/utils.cpp
+++ b/src/entity_manager/utils.cpp
@@ -2,7 +2,6 @@
#include "../variant_visitors.hpp"
#include "expression.hpp"
-#include "power_status_monitor.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/find.hpp>
@@ -14,51 +13,6 @@
#include <fstream>
#include <iostream>
-bool power::PowerStatusMonitor::isPowerOn()
-{
- if (!powerMatch)
- {
- throw std::runtime_error("Power Match Not Created");
- }
- return powerStatusOn;
-}
-
-void power::PowerStatusMonitor::setupPowerMatch(
- const std::shared_ptr<sdbusplus::asio::connection>& conn)
-{
- powerMatch = std::make_unique<sdbusplus::bus::match_t>(
- static_cast<sdbusplus::bus_t&>(*conn),
- "type='signal',interface='" +
- std::string(em_utils::properties::interface) + "',path='" +
- std::string(power::path) + "',arg0='" +
- std::string(power::interface) + "'",
- [this](sdbusplus::message_t& message) {
- std::string objectName;
- boost::container::flat_map<std::string, std::variant<std::string>>
- values;
- message.read(objectName, values);
- auto findState = values.find(power::property);
- if (findState != values.end())
- {
- powerStatusOn = boost::ends_with(
- std::get<std::string>(findState->second), "Running");
- }
- });
-
- conn->async_method_call(
- [this](boost::system::error_code ec,
- const std::variant<std::string>& state) {
- if (ec)
- {
- return;
- }
- powerStatusOn =
- boost::ends_with(std::get<std::string>(state), "Running");
- },
- power::busname, power::path, em_utils::properties::interface,
- em_utils::properties::get, power::interface, power::property);
-}
-
namespace em_utils
{