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.hpp b/src/entity_manager/configuration.hpp
index f7f0b31..3cd94d4 100644
--- a/src/entity_manager/configuration.hpp
+++ b/src/entity_manager/configuration.hpp
@@ -6,21 +6,23 @@
#include <vector>
constexpr const char* globalSchema = "global.json";
-constexpr const char* hostConfigurationDirectory = SYSCONF_DIR "configurations";
-constexpr const char* configurationDirectory = PACKAGE_DIR "configurations";
constexpr const char* currentConfiguration = "/var/configuration/system.json";
constexpr const char* schemaDirectory = PACKAGE_DIR "schemas";
class Configuration
{
public:
- explicit Configuration();
+ explicit Configuration(
+ const std::vector<std::filesystem::path>& configurationDirectories);
std::unordered_set<std::string> probeInterfaces;
std::vector<nlohmann::json> configurations;
- private:
+ protected:
void loadConfigurations();
void filterProbeInterfaces();
+
+ private:
+ std::vector<std::filesystem::path> configurationDirectories;
};
bool writeJsonFiles(const nlohmann::json& systemConfiguration);