psutil: Add PSU update validation logic
This commit adds the PSUUpdateValidator class implementation which
validates whether it is safe to proceed with a PSU firmware update
based on current system state. It verifies the following:
- All present PSUs match the model of the target PSU
- Count the number of present PSUs in the system
- Ensure that the number of PSUs currently present, none faulty and
all of the same model, is sufficient to meet the PSU requirement
specified in the system configuration
This validator fetches PSU inventory paths, properties such as
'SupportedModel' and 'RedundantCount', and checks the PSU presence and
not faulty via D-Bus.
The method `validToUpdate()` encapsulates the overall logic, returning
true if all criteria for a safe update are met.
This class is designed to be integrated before triggering PSU updates
to ensure system safety.
Tested:
- Ran psutils with --validate on powered-on system, verified update
blocked
- Ran psutils with simulated PSUs of mismatched models, verified
update blocked
- Ran with matching models and sufficient present PSUs, verified
update succeeded
Change-Id: I367ef6d1b2cd66e8209f6b67a325de2b1a6da12a
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/tools/power-utils/test/meson.build b/tools/power-utils/test/meson.build
index 3ac7b5c..ae29078 100644
--- a/tools/power-utils/test/meson.build
+++ b/tools/power-utils/test/meson.build
@@ -7,6 +7,8 @@
'test_version.cpp',
'../updater.cpp',
'../aei_updater.cpp',
+ '../validator.cpp',
+ '../model.cpp',
'../utils.cpp',
'../version.cpp',
dependencies: [gtest, gmock, nlohmann_json_dep, phosphor_logging],