psu-ng: Remove JSON parsing code
Remove the JSON parsing code/functions from the PSUManager class.
Remove the constructor using the JSON configfile path as it is no longer
used.
Remove the getJSONProperties function, as it is no longer used.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Iec7fcc167dbd2eb21bc6769af46594bb2d53e3ea
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 5bb0807..8045a41 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -21,41 +21,6 @@
"xyz.openbmc_project.Configuration.SupportedConfiguration";
constexpr auto maxCountProp = "MaxCount";
-PSUManager::PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e,
- const std::string& configfile) :
- bus(bus)
-{
- sysProperties = {0};
- // Parse out the JSON properties
- getJSONProperties(configfile);
- // Subscribe to InterfacesAdded before doing a property read, otherwise
- // the interface could be created after the read attempt but before the
- // match is created.
- entityManagerIfacesAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
- bus,
- sdbusplus::bus::match::rules::interfacesAdded() +
- sdbusplus::bus::match::rules::sender(
- "xyz.openbmc_project.EntityManager"),
- std::bind(&PSUManager::entityManagerIfaceAdded, this,
- std::placeholders::_1));
- getSystemProperties();
-
- using namespace sdeventplus;
- auto interval = std::chrono::milliseconds(1000);
- timer = std::make_unique<utility::Timer<ClockId::Monotonic>>(
- e, std::bind(&PSUManager::analyze, this), interval);
-
- // Subscribe to power state changes
- powerService = util::getService(POWER_OBJ_PATH, POWER_IFACE, bus);
- powerOnMatch = std::make_unique<sdbusplus::bus::match_t>(
- bus,
- sdbusplus::bus::match::rules::propertiesChanged(POWER_OBJ_PATH,
- POWER_IFACE),
- [this](auto& msg) { this->powerStateChanged(msg); });
-
- initialize();
-}
-
PSUManager::PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e) :
bus(bus)
{
@@ -89,44 +54,6 @@
initialize();
}
-void PSUManager::getJSONProperties(const std::string& path)
-{
- nlohmann::json configFileJSON = util::loadJSONFromFile(path.c_str());
-
- if (configFileJSON == nullptr)
- {
- throw std::runtime_error("Failed to load JSON configuration file");
- }
-
- if (!configFileJSON.contains("PowerSupplies"))
- {
- throw std::runtime_error("Missing required PowerSupplies");
- }
-
- for (auto psuJSON : configFileJSON["PowerSupplies"])
- {
- if (psuJSON.contains("Inventory") && psuJSON.contains("Bus") &&
- psuJSON.contains("Address"))
- {
- std::string invpath = psuJSON["Inventory"];
- std::uint8_t i2cbus = psuJSON["Bus"];
- std::uint16_t i2caddr = static_cast<uint16_t>(psuJSON["Address"]);
- auto psu =
- std::make_unique<PowerSupply>(bus, invpath, i2cbus, i2caddr);
- psus.emplace_back(std::move(psu));
- }
- else
- {
- log<level::ERR>("Insufficient PowerSupply properties");
- }
- }
-
- if (psus.empty())
- {
- throw std::runtime_error("No power supplies to monitor");
- }
-}
-
void PSUManager::getPSUConfiguration()
{
using namespace phosphor::power::util;
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index b950869..ba531c6 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -37,16 +37,6 @@
PSUManager& operator=(PSUManager&&) = delete;
/**
- * Constructor to read configuration from JSON file.
- *
- * @param[in] bus - D-Bus bus object
- * @param[in] e - event object
- * @param[in] configfile - string path to the configuration file
- */
- PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e,
- const std::string& configfile);
-
- /**
* Constructor to read configuration from D-Bus.
*
* @param[in] bus - D-Bus bus object
@@ -55,12 +45,6 @@
PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e);
/**
- * @brief Initialize the PowerSupply objects from the JSON config file.
- * @param[in] path - Path to the JSON config file
- */
- void getJSONProperties(const std::string& path);
-
- /**
* Get PSU properties from D-Bus, use that to build a power supply
* object.
*