Add more types to YangSchema::nodeType
This doesn't do much here (we can't parse paths to these new types, so
no way to call it with that a path of a new type), but it will be useful
with the new approach to node parsing, where nodeType is used.
Change-Id: If7aefca145094f305752a192bfaa3ea658f32081
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index 0a4f59e..eb0fd66 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -150,6 +150,12 @@
case yang::NodeTypes::List:
ss << "list";
break;
+ case yang::NodeTypes::Action:
+ case yang::NodeTypes::AnyXml:
+ case yang::NodeTypes::LeafList:
+ case yang::NodeTypes::Notification:
+ case yang::NodeTypes::Rpc:
+ throw std::logic_error("describe got an rpc or an action: this should never happen, because their paths cannot be parsed");
}
if (!m_datastore.schema()->isConfig(path)) {
diff --git a/src/schema.hpp b/src/schema.hpp
index 052386e..f11265f 100644
--- a/src/schema.hpp
+++ b/src/schema.hpp
@@ -22,7 +22,12 @@
Container,
PresenceContainer,
List,
- Leaf
+ Leaf,
+ Rpc,
+ Action,
+ Notification,
+ AnyXml,
+ LeafList
};
enum class Status {
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 2c8b30d..b243fd2 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -344,11 +344,7 @@
for (const auto& node : nodes) {
if (node->module()->name() == "ietf-yang-library"sv)
continue;
- // FIXME: This is a temporary fix to filter out RPC nodes in
- // tab-completion. The method will have to be changed/reworked when RPC
- // support gets added.
- if (node->nodetype() == LYS_RPC)
- continue;
+
if (recursion == Recursion::Recursive) {
for (auto it : node->tree_dfs()) {
res.insert(ModuleNodePair(boost::none, it->path(LYS_PATH_FIRST_PREFIX)));
@@ -420,6 +416,16 @@
return yang::NodeTypes::Leaf;
case LYS_LIST:
return yang::NodeTypes::List;
+ case LYS_RPC:
+ return yang::NodeTypes::Rpc;
+ case LYS_ACTION:
+ return yang::NodeTypes::Action;
+ case LYS_NOTIF:
+ return yang::NodeTypes::Notification;
+ case LYS_ANYXML:
+ return yang::NodeTypes::AnyXml;
+ case LYS_LEAFLIST:
+ return yang::NodeTypes::LeafList;
default:
throw InvalidNodeException(); // FIXME: Implement all types.
}
diff --git a/tests/yang.cpp b/tests/yang.cpp
index cdb200e..3c658b3 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -816,6 +816,7 @@
{"example-schema"s, "obsoleteLeaf"},
{"example-schema"s, "obsoleteLeafWithDeprecatedType"},
{"example-schema"s, "obsoleteLeafWithObsoleteType"},
+ {"example-schema"s, "myRpc"},
{"example-schema"s, "systemStats"}};
}
@@ -887,6 +888,7 @@
{"example-schema"s, "leafUint8"},
{"example-schema"s, "length"},
{"example-schema"s, "loopback"},
+ {"example-schema"s, "myRpc"},
{"example-schema"s, "numberOrString"},
{"example-schema"s, "obsoleteLeaf"},
{"example-schema"s, "obsoleteLeafWithDeprecatedType"},
@@ -944,6 +946,9 @@
{boost::none, "/example-schema:leafUint64"},
{boost::none, "/example-schema:leafUint8"},
{boost::none, "/example-schema:length"},
+ {boost::none, "/example-schema:myRpc"},
+ {boost::none, "/example-schema:myRpc/input"},
+ {boost::none, "/example-schema:myRpc/output"},
{boost::none, "/example-schema:numberOrString"},
{boost::none, "/example-schema:obsoleteLeaf"},
{boost::none, "/example-schema:obsoleteLeafWithDeprecatedType"},