control: Add cache maps to fan control dump
Add the _objects, _parameters, and _servTree maps to the fan control
JSON dump file.
A condensed example is:
{
"flight_recorder": [
"Oct 06 05:59:01.183998: main: Startup"
],
"parameters": null,
"objects": {
"/xyz/openbmc_project/sensors/temperature/vpcie_dcm1_rail_temperature": {
"org.freedesktop.DBus.Introspectable": null,
"org.freedesktop.DBus.Peer": null,
"org.freedesktop.DBus.Properties": null,
"xyz.openbmc_project.Association.Definitions": {
"Associations": false
},
"xyz.openbmc_project.Sensor.Value": {
"MaxValue": 250.0,
"MinValue": -50.0,
"Unit": "xyz.openbmc_project.Sensor.Value.Unit.DegreesC",
"Value": 60.0
},
"xyz.openbmc_project.State.Decorator.Availability": {
"Available": true
},
"xyz.openbmc_project.State.Decorator.OperationalStatus": {
"Functional": true
}
},
},
"services": {
"/xyz/openbmc_project/sensors/temperature/vpcie_dcm1_rail_temperature": {
"xyz.openbmc_project.Power.Regulators": [
true,
[
"xyz.openbmc_project.Sensor.Value"
]
]
},
}
}
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Id3351127e07bcf1094d1e0a7891625632afa8d5b
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 10bb84d..01365e7 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -106,6 +106,7 @@
{
json data;
FlightRecorder::instance().dump(data);
+ dumpCache(data);
std::ofstream file{Manager::dumpFile};
if (!file)
@@ -119,6 +120,35 @@
debugDumpEventSource.reset();
}
+void Manager::dumpCache(json& data)
+{
+ auto& objects = data["objects"];
+ for (const auto& [path, interfaces] : _objects)
+ {
+ auto& interfaceJSON = objects[path];
+
+ for (const auto& [interface, properties] : interfaces)
+ {
+ auto& propertyJSON = interfaceJSON[interface];
+ for (const auto& [propName, propValue] : properties)
+ {
+ std::visit(
+ [&obj = propertyJSON[propName]](auto&& val) { obj = val; },
+ propValue);
+ }
+ }
+ }
+
+ auto& parameters = data["parameters"];
+ for (const auto& [name, value] : _parameters)
+ {
+ std::visit([&obj = parameters["name"]](auto&& val) { obj = val; },
+ value);
+ }
+
+ data["services"] = _servTree;
+}
+
void Manager::load()
{
if (_loadAllowed)