Merge changes Idd613cc8,Iba5bc44f,I0e500bb9
* changes:
NetconfAccess: do not ignore ops data
netconf-c++: handle empty <data/> for <get/> RPC
netconf-c++: simplify <get-config/> implementation
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 9f6908b..db421ed 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -288,10 +288,11 @@
throw std::runtime_error("Cannot create get RPC");
}
auto reply = impl::do_rpc_data(this, std::move(rpc));
+ auto dataNode = libyang::create_new_Data_Node(reply->data);
// TODO: can we do without copying?
// If we just default-construct a new node (or use the create_new_Data_Node) and then set reply->data to nullptr,
// there are mem leaks and even libnetconf2 complains loudly.
- return libyang::create_new_Data_Node(reply->data)->dup_withsiblings(1);
+ return dataNode ? dataNode->dup_withsiblings(1) : nullptr;
}
std::string Session::getSchema(const std::string_view identifier, const std::optional<std::string_view> version)
@@ -320,14 +321,9 @@
throw std::runtime_error("Cannot create get-config RPC");
}
auto reply = impl::do_rpc_data(this, std::move(rpc));
- // TODO: can we do without copying?
- // If we just default-construct a new node (or use the create_new_Data_Node) and then set reply->data to nullptr,
- // there are mem leaks and even libnetconf2 complains loudly.
auto dataNode = libyang::create_new_Data_Node(reply->data);
- if (!dataNode)
- return nullptr;
- else
- return dataNode->dup_withsiblings(1);
+ // TODO: can we do without copying? See Session::get() for details.
+ return dataNode ? dataNode->dup_withsiblings(1) : nullptr;
}
void Session::editConfig(const NC_DATASTORE datastore,
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 9fb456d..e592759 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -52,7 +52,7 @@
DatastoreAccess::Tree NetconfAccess::getItems(const std::string& path)
{
Tree res;
- auto config = m_session->getConfig(NC_DATASTORE_RUNNING, (path != "/") ? std::optional{path} : std::nullopt);
+ auto config = m_session->get((path != "/") ? std::optional{path} : std::nullopt);
if (config) {
for (auto it : config->tree_for()) {