Subject: [netmod] Yang 1.1 Extension Validation?

From: "Peyman Owladi -X (powladi - Ensoft Ltd at Cisco)" <[email-masked]>
Date: Tue, 6 May 2014 21:49:17 +0000

Hi folks,

I've been discussing Yang ideas and pain points with a few teams who have been applying the language in multiple scenarios over the last few years, and based on our usage experiences, we've come up with a few ideas/questions which we think are valuable and I haven¹t seen other people bring up on the alias or in Yang 1.1 discussions.

So I'll post a few threads, and would welcome your thoughts :-) The first is relating to how extensions are specified.

Issue:

Yang has a clean/simple grammar that allows for a simple domain-specific description. In particular, (almost) all of the ABNF boils down to:

  fixed-keyword variable-argument?;

  fixed-keyword variable-argument? { fixed-child-keyword variable-argument? ...}

where the set of valid keywords to use as "fixed-child-keyword" depend on what "fixed-keyword" is.

This can be used when defining extensions, allowing a strict grammar to be specified in the extension description. This has the following benefits:

- It helps ensure that the usage of extensions is defined clearly and comprehensively.

- It encourages Yang extensions to follow the grammar patterns of the base language.

- It allows automated validation of extended grammar.

Note that AFAICS basically all of the base Yang grammar can also be defined in this way. (FWIW the set of rules is derived from Pyang's grammar checking.)

Solution:

"extension-validation.yang", attached, describes the extra grammar needed to perform this validation.

It's described there in the form of a Yang extension, but IMO it would be better as a part of the base Yang syntax to use as a recommended way of defining extensions in Yang 1.1. (And doing so would allow for example the use of "description" and "pattern" keywords within the "argument" subblock.)

The "extension-validation-self-validating.yang" module (also attached) illustrates the usage of these extensions (-; by applying them to the module itself ;-).

Alternative solution:

This could be implemented as an extension rather than as part of the base grammar, as per the attached example (though this has disadvantages as noted above).

Cheers,

Peyman

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 07 May 2014 09:27:01 +0200 (CEST)

Hi,

Added as Y50.

/martin