presence: Split config filename from path
Change-Id: I295807c724ce849c43376998330ddd1eaa939fe5
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/presence/json_config.cpp b/presence/json_config.cpp
index 6dc06c2..59d452a 100644
--- a/presence/json_config.cpp
+++ b/presence/json_config.cpp
@@ -36,8 +36,6 @@
namespace fs = std::filesystem;
using namespace phosphor::logging;
-constexpr auto jsonFileAlt = "/etc/phosphor-fan-presence/presence/config.json";
-
policies JsonConfig::_policies;
const std::map<std::string, methodHandler> JsonConfig::_methods =
{
@@ -50,8 +48,8 @@
{"fallback", rpolicy::getFallback}
};
-JsonConfig::JsonConfig(const std::string& jsonFile) :
- _defaultFile(fs::path(jsonFile))
+JsonConfig::JsonConfig(const std::string& jsonConfigPath) :
+ _defaultFile(fs::path(fs::path{jsonConfigPath} / jsonFileName))
{
if (!_defaultFile.empty())
{
@@ -92,7 +90,7 @@
void JsonConfig::load()
{
- fs::path confFile{jsonFileAlt};
+ fs::path confFile{fs::path{jsonOverridePath} / jsonFileName};
if (!fs::exists(confFile))
{
confFile = _defaultFile;
diff --git a/presence/json_config.hpp b/presence/json_config.hpp
index a369bd5..206b290 100644
--- a/presence/json_config.hpp
+++ b/presence/json_config.hpp
@@ -21,6 +21,10 @@
namespace fs = std::filesystem;
using json = nlohmann::json;
+
+constexpr auto jsonFileName = "config.json";
+constexpr auto jsonOverridePath = "/etc/phosphor-fan-presence/presence";
+
using policies = std::vector<std::unique_ptr<RedundancyPolicy>>;
constexpr auto fanPolicyFanPos = 0;
@@ -49,9 +53,9 @@
* Constructor
* Parses and populates the fan presence policies from a json file
*
- * @param[in] jsonFile - json configuration file
+ * @param[in] jsonConfigPath - json configuration path
*/
- explicit JsonConfig(const std::string& jsonFile);
+ explicit JsonConfig(const std::string& jsonConfigPath);
/**
* @brief Get the json config based fan presence policies