Fix create sensor failure after process restart
When the virtual-sensor process is intentionally restarted, the
createVirtualSensors method will only create sensors with Type equal
to ModifiedMedian, so if other types of sensors (eg: Sum, Minimum,
Maximum, etc.) are configured in EM.json, they will not be loaded.
This commit will remove the `Type` and create the sensor by
traversing the calculationIfaces when parsing to 'Config: D-Bus'.
Change-Id: I4a22bd2eef26e745e770acb260616374b5aba89b
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 3aeddf3..d7be691 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -861,17 +861,8 @@
* don't want to miss them */
setupMatches();
- if (desc.contains("Type"))
+ for (const auto& intf : std::views::keys(calculationIfaces))
{
- auto type = desc.value("Type", "");
- auto intf = "xyz.openbmc_project.Configuration." + type;
-
- if (!calculationIfaces.contains(intf))
- {
- error("Invalid calculation type {TYPE} supplied.",
- "TYPE", type);
- continue;
- }
createVirtualSensorsFromDBus(intf);
}
continue;