entity-manager: constructor arg to load config
Introduce a constructor arg to point EM to directories to load
configuration from.
This enables running unit tests without depending on a specific
directory layout from our rofs.
Tested: on Tyan S8030. Config parsed as expected.
```
Oct 02 11:22:52 s8030-bmc-30303035c0c1 systemd[1]: Starting Entity Manager...
Oct 02 11:22:52 s8030-bmc-30303035c0c1 systemd[1]: Started Entity Manager.
Oct 02 11:23:02 s8030-bmc-30303035c0c1 entity-manager[8265]: There's still template variable $PRODUCT_PART_NUMBER un-replaced. Removing it from the string.
Oct 02 11:23:02 s8030-bmc-30303035c0c1 entity-manager[8265]: There's still template variable $PRODUCT_ASSET_TAG un-replaced. Removing it from the string.
Oct 02 11:23:02 s8030-bmc-30303035c0c1 entity-manager[8265]: There's still template variable $PRODUCT_ASSET_TAG un-replaced. Removing it from the string.
Oct 02 11:23:02 s8030-bmc-30303035c0c1 entity-manager[8265]: There's still template variable $PRODUCT_ASSET_TAG un-replaced. Removing it from the string.
Oct 02 11:23:02 s8030-bmc-30303035c0c1 entity-manager[8265]: There's still template variable $PRODUCT_PART_NUMBER un-replaced. Removing it from the string.
Oct 02 11:23:04 s8030-bmc-30303035c0c1 entity-manager[8265]: Inventory Added: Supermicro PWS 920P SQ 0
Oct 02 11:23:04 s8030-bmc-30303035c0c1 entity-manager[8265]: Inventory Added: Supermicro PWS 920P SQ 1
Oct 02 11:23:04 s8030-bmc-30303035c0c1 entity-manager[8265]: Inventory Added: Tyan S8030 Baseboard
Oct 02 11:23:04 s8030-bmc-30303035c0c1 entity-manager[8265]: Inventory Added: MBX 1.57 Chassis
```
Change-Id: I8ce297847d3cafe2e2ae2040e9db261dc1d8f426
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/configuration.cpp b/src/entity_manager/configuration.cpp
index b6ece2b..99f7f66 100644
--- a/src/entity_manager/configuration.cpp
+++ b/src/entity_manager/configuration.cpp
@@ -15,7 +15,9 @@
#include <string>
#include <vector>
-Configuration::Configuration()
+Configuration::Configuration(
+ const std::vector<std::filesystem::path>& configurationDirectories) :
+ configurationDirectories(configurationDirectories)
{
loadConfigurations();
filterProbeInterfaces();
@@ -27,13 +29,13 @@
// find configuration files
std::vector<std::filesystem::path> jsonPaths;
- if (!findFiles(
- std::vector<std::filesystem::path>{configurationDirectory,
- hostConfigurationDirectory},
- R"(.*\.json)", jsonPaths))
+ if (!findFiles(configurationDirectories, R"(.*\.json)", jsonPaths))
{
- lg2::error("Unable to find any configuration files in {DIR}", "DIR",
- configurationDirectory);
+ for (const auto& configurationDirectory : configurationDirectories)
+ {
+ lg2::error("Unable to find any configuration files in {DIR}", "DIR",
+ configurationDirectory);
+ }
return;
}