Only include RPC/action output in the output

NetconfAccess and SysrepoAccess include more stuff in RPC/action output
like keys and stuff. Change this to include only the actual output. More
info in comment.

Change-Id: I89138d5e28e00d5a7fafdc5110779ab13c4c627d
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index e3fbb1c..b5f7ccb 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -144,7 +144,9 @@
     Tree res;
     auto output = m_session->rpc_or_action(data);
     if (output) {
-        lyNodesToTree(res, output->tree_for(), joinPaths(path, "/"));
+        // If there's output, it will be a top-level node. In case of action, the output can be nested so we need to use
+        // find_path to get to the actual output.
+        lyNodesToTree(res, output->find_path(path.c_str())->data(), joinPaths(path, "/"));
     }
     return res;
 }
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index a75c5e8..c18ff31 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -312,10 +312,14 @@
         inputNode->merge(node, 0);
     }
 
+    Tree res;
     auto output = m_session->rpc_send(inputNode);
-    DatastoreAccess::Tree resTree;
-    lyNodesToTree(resTree, {output}, joinPaths(path, "/"));
-    return resTree;
+    if (output) {
+        // The output is "some top-level node". If we actually want the output of our RPC/action we need to use
+        // find_path.
+        lyNodesToTree(res, output->find_path(path.c_str())->data(), joinPaths(path, "/"));
+    }
+    return res;
 }
 
 void SysrepoAccess::copyConfig(const Datastore source, const Datastore destination)
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index 6c640fd..cf92a45 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -1042,8 +1042,6 @@
         DatastoreAccess::Tree input, output;
 
         output = {
-            {"/example-schema:ports[name='A']", special_{SpecialValue::List}},
-            {"/example-schema:ports[name='A']/name", enum_{"A"}},
             {"success", true}
         };
         datastore->createItem("/example-schema:ports[name='A']");