0

i just want to know is yang modeling language specific and can only be used with NetConf protocol, or can it be used to model data like Xml and Json ?

Thank you

Mheni
  • 228
  • 4
  • 15
  • Welcome to Stack Overflow! You can [take the tour](http://stackoverflow.com/tour) first and learn [How to Ask a good question](http://stackoverflow.com/help/how-to-ask) and create a [Minimal, Complete, and Verifiable](http://stackoverflow.com/help/mcve) example. That makes it easier for us to help you. – Stephen Rauch Jan 19 '17 at 00:09

1 Answers1

2

YANG was originally intended to model data exchanged between peers in a NETCONF session, but this is no longer the only case. There are now other protocols that (will) make use of it, such as RESTCONF and CoMI.

YANG is a data modeling language originally designed to model configuration and state data manipulated by the Network Configuration Protocol (NETCONF), NETCONF Remote Procedure Calls, and NETCONF notifications [RFC6241]. Since the publication of YANG version 1 [RFC6020], YANG has been used or proposed to be used for other protocols (e.g., RESTCONF [RESTCONF] and the Constrained Application Protocol (CoAP) Management Interface (CoMI) [CoMI]). Further, encodings other than XML have been proposed (e.g., JSON [RFC7951]).

RFC7950, Section 1

In fact the recent new YANG specification release (1.1) has made a move toward decoupling the model from its encoding. In the future, we will probably see separate XML and JSON encoding documents (plus perhaps others) and a single document dealing only with the language specifics.

You could use YANG to model data for other more general purposes if you ignore statements like rpc, action, notification, config, etc. Those that are only relevant in specific contexts. Of course you would have to define the context in which you wish to use the model and what it means to you. Some modelers make use of the extension statement to define such requirements, then implement a specialized YANG compiler that recognizes the extensions and acts accordingly - this allows you to make use of the language for things not originally intended by the authors.

There are some definitions in the specification that could make it harder to make YANG a general purpose modeling language (like what XML Schema is for XML). Concepts like configuration datastore, configuration data, state data, client, server, etc. are pretty darn specific. You can always turn a blind eye to those and just make it work for you, however. I believe that is how it is already done in the OpenDaylight project.

Community
  • 1
  • 1
predi
  • 5,528
  • 32
  • 60
  • thanks, but I still have some confusions, is yang used to only define a data schema which will be instantiated by another language like XML, JSON. or can it do both (define the schema, and instantiate or write the actual data in compliance to that schema) ? – Mheni Jan 19 '17 at 14:46
  • @M'heniMerzouki, YANG is a schema definition language. It describes the rules that instance documents (datastores, payloads) must follow in order for the latter to be recognized as valid. It can be used to validate an instance document directly, provided you have the necessary tools to do so. The instance documents are encoded as XML or JSON, so YANG may be used to check validity of XML or JSON directly (no need to generate an intermediate schema, though some tools do just that in order to leverage existing technologies). – predi Jan 19 '17 at 15:12
  • 1
    To this date, YANG validates [XML](https://tools.ietf.org/html/rfc7950#section-1), and [JSON](https://tools.ietf.org/html/rfc7951#section-1). – Ariel Otilibili Dec 12 '17 at 15:16