RAUC: change slot status reporting
I would like to make it possible to change which one of the healthy
slots gets booted next time, but for that, we must keep track of which
slots are healthy. I think that in this context exporting them as
booleans makes more sense, and it will make these property data types a
bit less complex.
Change-Id: I8ebd9c28a4c5b5717e9d61ae5693ef506d72e905
diff --git a/src/system/Firmware.cpp b/src/system/Firmware.cpp
index 023b880..83d4ca3 100644
--- a/src/system/Firmware.cpp
+++ b/src/system/Firmware.cpp
@@ -158,13 +158,25 @@
}
}
- for (const auto& [yangKey, raucKey] : {std::pair{"state", "state"}, {"boot-status", "boot-status"}, {"version", "bundle.version"}, {"installed", "installed.timestamp"}}) {
+ for (const auto& [yangKey, raucKey] : {std::pair{"version", "bundle.version"}, {"installed", "installed.timestamp"}}) {
if (auto pit = props.find(raucKey); pit != props.end()) {
m_slotStatusCache[xpathPrefix + yangKey] = std::get<std::string>(pit->second);
} else {
m_log->warn("RAUC didn't provide '{}' property for slot '{}'.", raucKey, slotName);
}
}
+
+ if (auto pit = props.find("state"); pit != props.end()) {
+ m_slotStatusCache[xpathPrefix + "is-booted-now"] = (std::get<std::string>(pit->second) == "booted" ? "true" : "false");
+ } else {
+ m_log->warn("RAUC didn't provide 'state' property for slot '{}'.", slotName);
+ }
+ if (auto pit = props.find("boot-status"); pit != props.end()) {
+ m_slotStatusCache[xpathPrefix + "is-healthy"] = (std::get<std::string>(pit->second) == "good" ? "true" : "false");
+ } else {
+ m_log->warn("RAUC didn't provide 'boot-status' property for slot '{}'.", slotName);
+ }
+
}
}