Fix NetconfAccess not being able to fetch submodules
When I implemented SysrepoAccess, I ignored the submoduleRevision
argument in the "libyang missing schema callback" as Sysrepo seemed to
work just fine without supplying it. However, libnetconf needs it
because one can't supply both module name and submodule name to a
<get-schema> request. Now, if a submodule is being requested by libyang
from NetconfAccess, I pass the submodule name to libnetconf rather
than the module name.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/123
Change-Id: I0e5f6b82b1598ecc9f27732f450b1a204ee500f9
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index c1bd5dc..3d54443 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -76,10 +76,11 @@
void NetconfAccess::datastoreInit()
{
- m_schema->registerModuleCallback([this](const char* moduleName, const char* revision, const char* submodule) {
+ m_schema->registerModuleCallback([this](const char* moduleName, const char* revision, const char* submodule, const char* submoduleRevision) {
return fetchSchema(moduleName,
revision ? std::optional{revision} : std::nullopt,
- submodule ? std::optional{submodule} : std::nullopt);
+ submodule ? std::optional{submodule} : std::nullopt,
+ submoduleRevision ? std::optional{submoduleRevision} : std::nullopt);
});
for (const auto& it : listImplementedSchemas()) {
@@ -149,8 +150,14 @@
m_session->discard();
}
-std::string NetconfAccess::fetchSchema(const std::string_view module, const std::optional<std::string_view> revision, const std::optional<std::string_view>)
+std::string NetconfAccess::fetchSchema(const std::string_view module, const
+ std::optional<std::string_view> revision, const
+ std::optional<std::string_view> submodule, const
+ std::optional<std::string_view> submoduleRevision)
{
+ if (submodule) {
+ return m_session->getSchema(*submodule, submoduleRevision);
+ }
return m_session->getSchema(module, revision);
}