Add support for executing RPCs
Creating a temporary YangAccess for RPC input means I need to somehow
give the right libyang schemas. For that reason I supply a callable
which is able to fetch the schema and create a YangAccess instance for
ProxyDatastore.
The ProxyDatastore class now has a simple mechanism for deciding whether
to use the normal datastore and the temporary based on a path prefix.
Change-Id: Ib455f53237598bc2620161a44fb89c48ddfeb6e3
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 711cdbd..05195b9 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -101,7 +101,11 @@
[&oldOptions]() {
libyang::set_log_options(oldOptions);
});
- return m_context->get_node(nullptr, node.c_str());
+ auto res = m_context->get_node(nullptr, node.c_str());
+ if (!res) { // If no node is found, try output rpc nodes too.
+ res = m_context->get_node(nullptr, node.c_str(), 1);
+ }
+ return res;
}
}
@@ -476,7 +480,20 @@
bool YangSchema::isConfig(const std::string& path) const
{
- return getSchemaNode(path.c_str())->flags() & LYS_CONFIG_W;
+ auto node = getSchemaNode(path.c_str());
+ if (node->flags() & LYS_CONFIG_W) {
+ return true;
+ }
+
+ // Node can still be an input node.
+ while (node->parent()) {
+ node = node->parent();
+ if (node->nodetype() == LYS_INPUT) {
+ return true;
+ }
+ }
+
+ return false;
}
std::optional<std::string> YangSchema::defaultValue(const std::string& leafPath) const