hardware: support component/state container in ietf-hardware
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.
We decided to change that and use state container with oper-state leaf
in ietf-hardware[1] that reports the operational status of a component.
In this commit, we set every oper-state leaf to enabled but in the next
commit we implement setting oper-state of our PSU to enabled/disabled
depending on whether it is/isn't currently present.
[1] https://www.rfc-editor.org/rfc/rfc8348
Change-Id: I27d8e3d2bf66592fdcfdaaca992a4b5b5f10cb73
diff --git a/tests/hardware_ietf-hardware.cpp b/tests/hardware_ietf-hardware.cpp
index 27a7c8b..58087ed 100644
--- a/tests/hardware_ietf-hardware.cpp
+++ b/tests/hardware_ietf-hardware.cpp
@@ -68,11 +68,14 @@
std::map<std::string, std::string> expected = {
{"/ietf-hardware:hardware/component[name='ne']/class", "iana-hardware:chassis"},
{"/ietf-hardware:hardware/component[name='ne']/mfg-name", "CESNET"},
+ {"/ietf-hardware:hardware/component[name='ne']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans']/class", "iana-hardware:module"},
{"/ietf-hardware:hardware/component[name='ne:fans']/parent", "ne"},
+ {"/ietf-hardware:hardware/component[name='ne:fans']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1']/class", "iana-hardware:fan"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1']/parent", "ne:fans"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan1']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/parent", "ne:fans:fan1"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/oper-status", "ok"},
@@ -80,8 +83,10 @@
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-scale", "units"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-type", "rpm"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2']/class", "iana-hardware:fan"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2']/parent", "ne:fans"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan2']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/parent", "ne:fans:fan2"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/oper-status", "ok"},
@@ -89,8 +94,10 @@
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-scale", "units"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-type", "rpm"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3']/class", "iana-hardware:fan"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3']/parent", "ne:fans"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan3']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/parent", "ne:fans:fan3"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/oper-status", "ok"},
@@ -98,8 +105,10 @@
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-scale", "units"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-type", "rpm"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4']/class", "iana-hardware:fan"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4']/parent", "ne:fans"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan4']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/parent", "ne:fans:fan4"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/oper-status", "ok"},
@@ -107,9 +116,11 @@
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-scale", "units"},
{"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-type", "rpm"},
+ {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl']/parent", "ne"},
{"/ietf-hardware:hardware/component[name='ne:ctrl']/class", "iana-hardware:module"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/parent", "ne:ctrl"},
@@ -118,6 +129,7 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-type", "celsius"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:power']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:power']/parent", "ne:ctrl"},
@@ -126,6 +138,7 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:power']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:power']/sensor-data/value-scale", "micro"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:power']/sensor-data/value-type", "watts"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:power']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/parent", "ne:ctrl"},
@@ -134,6 +147,7 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-type", "volts-AC"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/parent", "ne:ctrl"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/oper-status", "ok"},
@@ -141,6 +155,7 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-type", "volts-DC"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/parent", "ne:ctrl"},
@@ -149,12 +164,14 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/sensor-data/value-precision", "0"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/sensor-data/value-type", "amperes"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:current']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/parent", "ne:ctrl"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/class", "iana-hardware:module"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/serial-num", "0x00a8808d"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/mfg-date", "2017-02-01T00:00:00-00:00"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/model-name", "8GME4R"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/state/oper-state", "enabled"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/parent", "ne:ctrl:emmc"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/oper-status", "ok"},
@@ -163,6 +180,7 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value-scale", "units"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value-type", "other"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/units-display", "percent"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/state/oper-state", "enabled"},
};
// exclude last-change node