cleanup: Move probe and scan into their own files
Moving the code into separate files and grouping them by namespace
improves 'separation of concern'. Increases maintainability.
Tested:
Changes have been tested in QEMU/Yosemite35 machine with Yosemite4
Image and adapted configfile, where Probe statement set to true.
Service runs and places the information in the inventory
```
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: I0ae0cb14b054ac1a964c5a8e1164811384a4f31b
Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
diff --git a/src/entity_manager.cpp b/src/entity_manager.cpp
index 84d131b..187373a 100644
--- a/src/entity_manager.cpp
+++ b/src/entity_manager.cpp
@@ -18,6 +18,8 @@
#include "entity_manager.hpp"
#include "overlay.hpp"
+#include "perform_probe.hpp"
+#include "perform_scan.hpp"
#include "topology.hpp"
#include "utils.hpp"
#include "variant_visitors.hpp"
@@ -53,14 +55,6 @@
constexpr const char* currentConfiguration = "/var/configuration/system.json";
constexpr const char* globalSchema = "global.json";
-const boost::container::flat_map<const char*, probe_type_codes, CmpStr>
- probeTypes{{{"FALSE", probe_type_codes::FALSE_T},
- {"TRUE", probe_type_codes::TRUE_T},
- {"AND", probe_type_codes::AND},
- {"OR", probe_type_codes::OR},
- {"FOUND", probe_type_codes::FOUND},
- {"MATCH_ONE", probe_type_codes::MATCH_ONE}}};
-
static constexpr std::array<const char*, 6> settableInterfaces = {
"FanProfile", "Pid", "Pid.Zone", "Stepwise", "Thresholds", "Polling"};
using JsonVariantType =
@@ -100,22 +94,6 @@
}
}
-FoundProbeTypeT findProbeType(const std::string& probe)
-{
- boost::container::flat_map<const char*, probe_type_codes,
- CmpStr>::const_iterator probeType;
- for (probeType = probeTypes.begin(); probeType != probeTypes.end();
- ++probeType)
- {
- if (probe.find(probeType->first) != std::string::npos)
- {
- return probeType;
- }
- }
-
- return std::nullopt;
-}
-
static std::shared_ptr<sdbusplus::asio::dbus_interface> createInterface(
sdbusplus::asio::object_server& objServer, const std::string& path,
const std::string& interface, const std::string& parent,
@@ -1101,7 +1079,7 @@
return;
}
- auto perfScan = std::make_shared<PerformScan>(
+ auto perfScan = std::make_shared<scan::PerformScan>(
systemConfiguration, *missingConfigurations, configurations,
objServer,
[&systemConfiguration, &objServer, count, oldConfiguration,
@@ -1177,7 +1155,7 @@
continue;
}
// Skip it if the probe cmd doesn't contain an interface.
- if (findProbeType(*probe))
+ if (probe::findProbeType(*probe))
{
continue;
}