Details
-
Bug
-
Status: Resolved
-
Medium
-
Resolution: Cannot Reproduce
-
None
-
None
-
None
-
None
-
I work with ODL Aluminium SR2.
Description
We have a yang file ipi-bfd with rather complex structure. It includes some yang files
…
include ipi-bfd-interface;
…
The included yang file ipi-bfd-interface.yang in its turn imports some other yang files and uses them:
…
import ipi-interface
{ prefix ipi-interface; }…
path "/ipi-interface:interfaces/ipi-interface:interface/ipi-interface:name";
…
These files are located on device and processed by Restconf. We get exception
java.lang.IllegalArgumentException: Failed to resolve xpath: no module found for prefix ipi-interface in module ipi-bfd
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:441) ~[?:?]
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.stringPathPartToQName(SchemaContextUtil.java:606)
File ipi-bfd really does not have prefix ipi-interface. It is defined in included file and is used there.
It looks like SchemaContextUtil.resolveModuleForPrefix method checks only imports from the top file itself ignoring included files.
I fixed this bug in my environment by patching org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java, methodresolveModuleForPrefix.
This is the patch
- return context.findModule(mi.getModuleName(), mi.getRevision()).orElse(null);
+ Optional<? extends Module> moduleOpt = context.findModule(mi.getModuleName(), mi.getRevision());
+ if (moduleOpt.isPresent())
{ + return moduleOpt.get(); + }+ }
+ }
+
+ for (Module submodule : module.getSubmodules()) {
+ Module result = resolveModuleForPrefix(context, submodule, prefix);
+ if (result != null) {
+ return result;