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_fspyhpsu.cpp b/tests/hardware_fspyhpsu.cpp
index fbf36c4..01b319e 100644
--- a/tests/hardware_fspyhpsu.cpp
+++ b/tests/hardware_fspyhpsu.cpp
@@ -96,6 +96,7 @@
             expected = {
                 {"/ietf-hardware:hardware/component[name='ne:psu']/class", "iana-hardware:power-supply"},
                 {"/ietf-hardware:hardware/component[name='ne:psu']/parent", "ne"},
+                {"/ietf-hardware:hardware/component[name='ne:psu']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/sensor-data/oper-status", "ok"},
@@ -103,6 +104,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/sensor-data/value-type", "amperes"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:current-12V']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/sensor-data/oper-status", "ok"},
@@ -110,6 +112,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/sensor-data/value-type", "amperes"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:current-5Vsb']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/sensor-data/oper-status", "ok"},
@@ -117,10 +120,13 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/sensor-data/value-type", "amperes"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:current-in']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan']/class", "iana-hardware:module"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan']/parent", "ne:psu"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:fan']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1']/class", "iana-hardware:fan"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1']/parent", "ne:psu:fan"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/parent", "ne:psu:fan:fan1"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/sensor-data/oper-status", "ok"},
@@ -128,6 +134,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/sensor-data/value-scale", "units"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/sensor-data/value-type", "rpm"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:fan:fan1:rpm']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/sensor-data/oper-status", "ok"},
@@ -135,6 +142,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/sensor-data/value-scale", "micro"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/sensor-data/value-type", "watts"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:power-in']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/sensor-data/oper-status", "ok"},
@@ -142,6 +150,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/sensor-data/value-scale", "micro"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/sensor-data/value-type", "watts"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:power-out']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/sensor-data/oper-status", "ok"},
@@ -149,6 +158,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/sensor-data/value-type", "celsius"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:temperature-1']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/sensor-data/oper-status", "ok"},
@@ -156,6 +166,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/sensor-data/value-type", "celsius"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:temperature-2']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/oper-status", "ok"},
@@ -163,6 +174,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-type", "volts-DC"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/oper-status", "ok"},
@@ -170,6 +182,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-type", "volts-DC"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/state/oper-state", "enabled"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/class", "iana-hardware:sensor"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/parent", "ne:psu"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/oper-status", "ok"},
@@ -177,6 +190,7 @@
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-precision", "0"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-scale", "milli"},
                 {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-type", "volts-AC"},
+                {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/state/oper-state", "enabled"},
             };
             break;
         case 2:
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
diff --git a/tests/sysrepo_ietf-hardware.cpp b/tests/sysrepo_ietf-hardware.cpp
index 89b599f..b6cb517 100644
--- a/tests/sysrepo_ietf-hardware.cpp
+++ b/tests/sysrepo_ietf-hardware.cpp
@@ -48,11 +48,15 @@
             {"[name='ne']/name", "ne"},
             {"[name='ne']/class", "iana-hardware:chassis"},
             {"[name='ne']/mfg-name", "CESNET"},
+            {"[name='ne']/state", ""},
+            {"[name='ne']/state/oper-state", "enabled"},
 
             {"[name='ne:temperature-cpu']", ""},
             {"[name='ne:temperature-cpu']/name", "ne:temperature-cpu"},
             {"[name='ne:temperature-cpu']/class", "iana-hardware:sensor"},
             {"[name='ne:temperature-cpu']/parent", "ne"},
+            {"[name='ne:temperature-cpu']/state", ""},
+            {"[name='ne:temperature-cpu']/state/oper-state", "enabled"},
             {"[name='ne:temperature-cpu']/sensor-data", ""},
             {"[name='ne:temperature-cpu']/sensor-data/oper-status", "ok"},
             {"[name='ne:temperature-cpu']/sensor-data/value", "41800"},
@@ -64,6 +68,8 @@
             {"[name='ne:power']/name", "ne:power"},
             {"[name='ne:power']/class", "iana-hardware:sensor"},
             {"[name='ne:power']/parent", "ne"},
+            {"[name='ne:power']/state", ""},
+            {"[name='ne:power']/state/oper-state", "enabled"},
             {"[name='ne:power']/sensor-data", ""},
             {"[name='ne:power']/sensor-data/oper-status", "ok"},
             {"[name='ne:power']/sensor-data/value", "14000000"},
diff --git a/tests/sysrepo_two-daemons.cpp b/tests/sysrepo_two-daemons.cpp
index ac93736..fc21867 100644
--- a/tests/sysrepo_two-daemons.cpp
+++ b/tests/sysrepo_two-daemons.cpp
@@ -28,12 +28,15 @@
                     {"/component[name='ne']/name", "ne"},
                     {"/component[name='ne']/class", "iana-hardware:module"},
                     {"/component[name='ne']/description", "This data was brought to you by process 2 (subscr)."},
+                    {"/component[name='ne']/state", ""},
                     {"/component[name='ne:edfa']", ""},
                     {"/component[name='ne:edfa']/name", "ne:edfa"},
                     {"/component[name='ne:edfa']/class", "iana-hardware:module"},
+                    {"/component[name='ne:edfa']/state", ""},
                     {"/component[name='ne:ctrl']", ""},
                     {"/component[name='ne:ctrl']/name", "ne:ctrl"},
                     {"/component[name='ne:ctrl']/class", "iana-hardware:module"},
+                    {"/component[name='ne:ctrl']/state", ""},
                 });
         srSess.switchDatastore(sysrepo::Datastore::Running);
     }