hardware: set oper-state to disabled if PSU is not present
Our PSU can be plugged or unplugged when the system is running. When
this happens whole PSU subtree is not returned to sysrepo from
ietf-hardware.
This patch changes that by returning the PSU component tree but with no
sensors and oper-state [1] of the PSU component is set to disabled.
This return value applies for situations when (a) the PSU was
unplugged before trying to read its sensors, or (b) the PSU was
unplugged during the reading.
We did not discover any other possibility of how to report a
"not-present" except for setting the oper-state leaf.
(Originally I thought that a clever rewrite of ietf-hardware
abstraction that somehow polls the current "state" of the component
would be a good idea. But the code reporting PSU component works
differently than the rest of the sensors and we only want to support
disabled/enabled for this component. Therefore I only simply edited the
PSU code.)
[1] https://www.rfc-editor.org/rfc/rfc8348
Change-Id: I6a8a992105d42df7491b1c10614ead680836de65
diff --git a/src/ietf-hardware/FspYhPsu.h b/src/ietf-hardware/FspYhPsu.h
index f4c708f..27b9952 100644
--- a/src/ietf-hardware/FspYhPsu.h
+++ b/src/ietf-hardware/FspYhPsu.h
@@ -44,6 +44,9 @@
std::string m_psuName;
std::shared_ptr<velia::ietf_hardware::sysfs::HWMon> m_hwmon;
+
+ std::string m_namePrefix;
+ velia::ietf_hardware::DataTree m_staticData;
std::vector<std::function<velia::ietf_hardware::DataTree()>> m_properties;
void createPower();