[YANGTOOLS-492] Yang tools failing to parse Augmentations under "uses" clause while mounting a Netconf Device(Both Helium SR5 and Lithium) Created: 02/Sep/15  Updated: 10/Apr/22  Resolved: 16/Oct/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Balaji Varadaraju Assignee: Peter Kajsa
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 4231

 Description   

I am trying to mount a Netconf device that has an YANG file that uses augmentation under "uses" clause. The YANG snippet looks like this.

augment /if:interfaces/interfaces-bridge:bridge {
uses firewall-if-parameters
{
augment firewall {
leaf-list l2

{ type types:alpha-numeric; ordered-by "user"; configd:help "Ruleset for forwarded packets on bridge interface"; configd:allowed "echo $VAR(/security/firewall/name/@@)"; configd:validate "check-fw-ruleset-exists"; }

}
}
}

Note that there are two augmentation targets here. Yang tools fails to handle this condition. It is doing an unsafe type cast while handling the augmentations under "uses" clause.

If I manually take out the uses augment as pasted below, this file is parsed properly and device is mounted.

================= Section which YANG tools fails to parse.
augment firewall {
leaf-list l2

{ type types:alpha-numeric; ordered-by "user"; configd:help "Ruleset for forwarded packets on bridge interface"; configd:allowed "echo $VAR(/security/firewall/name/@@)"; configd:validate "check-fw-ruleset-exists"; }

}
}
================

I think the issue is YANG tools may be handling the direct uses augmentation well but if this augmentation comes under another augmentation as specified in the snippet, it is having issues.

The issue is in the resolveUsesAugment method of java file YangParserImpl.java.

Please note that this happens in both Helium and Lithium.

Stack trace is below:

java.lang.ClassCastException: org.opendaylight.yangtools.yang.parser.builder.impl.AugmentationSchemaBuilderImpl cannot be cast to org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveUsesAugment(YangParserImpl.java:954)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveUses(YangParserImpl.java:1157)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveUsesForNodes(YangParserImpl.java:1126)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.build(YangParserImpl.java:709)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.buildModules(YangParserImpl.java:335)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.repo.SharedSchemaContextFactory$2.apply(SharedSchemaContextFactory.java:106)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.yangtools.yang.parser.repo.SharedSchemaContextFactory$2.apply(SharedSchemaContextFactory.java:68)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:859)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.ExecutionList.add(ExecutionList.java:106)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:170)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.Futures.transform(Futures.java:613)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.Futures.transform(Futures.java:565)[135:com.google.guava:14.0.1]
at org.opendaylight.yangtools.yang.parser.repo.SharedSchemaContextFactory.createSchemaContext(SharedSchemaContextFactory.java:142)[160:org.opendaylight.yangtools.yang-parser-impl:0.6.6.Helium-SR4]
at org.opendaylight.controller.sal.connect.netconf.NetconfDevice$RecursiveSchemaSetup.setUpSchema(NetconfDevice.java:318)[270:org.opendaylight.controller.sal-netconf-connector:1.1.4.Helium-SR4]
at org.opendaylight.controller.sal.connect.netconf.NetconfDevice$RecursiveSchemaSetup.access$1000(NetconfDevice.java:288)[270:org.opendaylight.controller.sal-netconf-connector:1.1.4.Helium-SR4]
at org.opendaylight.controller.sal.connect.netconf.NetconfDevice$RecursiveSchemaSetup$1.onFailure(NetconfDevice.java:334)[270:org.opendaylight.controller.sal-netconf-connector:1.1.4.Helium-SR4]
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1140)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.ExecutionList.add(ExecutionList.java:106)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:170)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.ForwardingListenableFuture.addListener(ForwardingListenableFuture.java:47)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1152)[135:com.google.guava:14.0.1]
at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1088)[135:com.google.guava:14.0.1]
at org.opendaylight.controller.sal.connect.netconf.NetconfDevice$RecursiveSchemaSetup.setUpSchema(NetconfDevice.java:349)[270:org.opendaylight.controller.sal-netconf-connector:1.1.4.Helium-SR4]
at org.opendaylight.controller.sal.connect.netconf.NetconfDevice$RecursiveSchemaSetup.run(NetconfDevice.java:303)[270:org.opendaylight.controller.sal-netconf-connector:1.1.4.Helium-SR4]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]



 Comments   
Comment by Peter Kajsa [ 02/Sep/15 ]

fix: https://git.opendaylight.org/gerrit/#/c/26329/

Comment by Balaji Varadaraju [ 02/Sep/15 ]

Hi Peter,
Thanks a lot for the very quick fix on this. Really appreciate it. I've tested this fix locally and it works. Netconf device is mounted without issues.

Thanks again,
Bala

Comment by Peter Kajsa [ 04/Sep/15 ]

You are welcome,
Peter

Generated at Wed Feb 07 20:53:24 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.