How do I parse YANG models in java ? I need to convert the yang model into a xml format.
I have already tried pyang. But since it is in python, it does not suite my requirement.
yang > ietf. xml and then using python xmltodict library the same can be converted to json.
YANG is a data modeling language for the NETCONF configuration management protocol. Together, NETCONF and YANG provide the tools that network administrators need to automate configuration tasks across heterogeneous devices in a software-defined network (SDN).
YANG Tools Overview YANG is a data modeling language used to model configuration & state data. Modeling languages such as SMI (SNMP), UML, XML Schema, and others already existed. However, none of these languages were specifically targeted to the needs of configuration management.
Yes, that's true.
Use yang-parser-impl from Open daylight. It provides a yang parser and returns a set of parsed modules. Which you can further query to get more node objects.
The above API is valid for previous versions. Use the following API for the current version
YangTextSchemaContextResolver yangContextResolver = YangTextSchemaContextResolver.create("yang-context-resolver");
yangContextResolver.registerSource(new URL("file:///home/ABA/XXX/Workspaces/ABC/X/config.yang"));
yangContextResolver.registerSource(new URL("file:///home/ABC/XXX/Workspaces/ABC/X/XXX-YY.yang"));
Optional<SchemaContext> sc = yangContextResolver.getSchemaContext();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With