Add Configuration class
Adding this class improves maintainability by increasing separation
of concern. One major improvement is the removal of reoccuring calls to
loadConfigurations. These calls took a long time. Now it's only called
once.
Tested:
QEMU/yosemite4 with probe statement set to TRUE.
```
root@yosemite4:~# journalctl | grep entity-manager
Dec 19 13:26:21 yosemite4 entity-manager[502]: Clearing previous configuration
Dec 19 13:26:25 yosemite4 entity-manager[502]: Inventory Added: Yosemite 4 Management Board
root@yosemite4:~# busctl tree xyz.openbmc_project.EntityManager
`- /xyz
`- /xyz/openbmc_project
|- /xyz/openbmc_project/EntityManager
`- /xyz/openbmc_project/inventory
`- /xyz/openbmc_project/inventory/system
`- /xyz/openbmc_project/inventory/system/board
`- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/All_Fan
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P0V6_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P12V_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V0_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V2_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V8_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P2V5_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V3_RGM_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V3_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V_BAT_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P5V_USB_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P5V_VOLT_V
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_TEMP_C
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/PID_NIC_TEMP
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_MGNT_TEMP
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_NIC_TEMP
|- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_SENTINEL_DOME_SLOT_PRESENT_PERCENTAGE
`- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Zone_1
```
Change-Id: I5684a03232012e14d97edcf4ea5ed1aed4d50c8d
Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
diff --git a/src/entity_manager/dbus_interface.cpp b/src/entity_manager/dbus_interface.cpp
index 1efa0c3..cea5d42 100644
--- a/src/entity_manager/dbus_interface.cpp
+++ b/src/entity_manager/dbus_interface.cpp
@@ -89,7 +89,7 @@
objServer.remove_interface(dbusInterface);
});
- if (!configuration::writeJsonFiles(systemConfiguration))
+ if (!writeJsonFiles(systemConfiguration))
{
std::cerr << "error setting json file\n";
throw DBusInternalError();
@@ -312,9 +312,8 @@
lastIndex++;
}
- std::ifstream schemaFile(
- std::string(configuration::schemaDirectory) + "/" +
- boost::to_lower_copy(*type) + ".json");
+ std::ifstream schemaFile(std::string(schemaDirectory) + "/" +
+ boost::to_lower_copy(*type) + ".json");
// todo(james) we might want to also make a list of 'can add'
// interfaces but for now I think the assumption if there is a
// schema avaliable that it is allowed to update is fine
@@ -330,7 +329,7 @@
std::cerr << "Schema not legal" << *type << ".json\n";
throw DBusInternalError();
}
- if (!configuration::validateJson(schema, newData))
+ if (!validateJson(schema, newData))
{
throw std::invalid_argument("Data does not match schema");
}
@@ -342,7 +341,7 @@
{
findExposes->push_back(newData);
}
- if (!configuration::writeJsonFiles(systemConfiguration))
+ if (!writeJsonFiles(systemConfiguration))
{
std::cerr << "Error writing json files\n";
throw DBusInternalError();