netmod-wg / yang-next

Feature requests for future versions of YANG
6 stars 0 forks source link

A general way to add stmts to any part of a schema #51

Open rgwilton opened 6 years ago

rgwilton commented 6 years ago

As a vendor we sometimes want to extend a YANG model by annotating it with extra metadata information. E.g. perhaps mappings to internal data-structures, or adding additional constraints.

Various vendors have their own implementations of an "annotation" extension that is used to add annotations to an existing YANG model.

In some cases, deviations can be used, but it doesn't work everywhere, and has a negative connotations.

Perhaps this should be considered in the next version of YANG? At least this would mean that generic tools would be able to understand these annotations, if required.

llhotka commented 6 years ago

Isn't it exactly what extensions are good for?

rgwilton commented 6 years ago

I want a way to annotation an existing module with extension statements without having to modify the source YANG module. I.e. put all of the extension statements in another YANG file.

llhotka commented 6 years ago

OK, I understand, this wasn't clear from the original description. I agree it would be useful.

immibis commented 6 years ago

As an example of a vendor-specific implementation, Tail-f has:

tailf:annotate /mod:path/mod:to/mod:schema/mod:node {
    extmod:extension argument;
    extmod:other-extension other-argument;
}

It works like augment essentially, but instead of adding new schema nodes it adds metadata extensions.

rovarga commented 5 years ago

OpenDaylight has some outstanding work in this regard -- https://jira.opendaylight.org/browse/YANGTOOLS-575 is about defining an extension which can mutate declared YANG in pretty much arbitrary ways, the scope is limited to adding because that's all we need.

mbj4668 commented 5 years ago

I think this is better done with extensions. No need to have it in the language.

rgwilton commented 5 years ago

@mbj4668 can you explain why?

It seems that are a few different implementations achieving the same thing. Putting this directly in the language may make it easier for tooling. Defining standard common extensions to achieve this is another alternative.

rovarga commented 5 years ago

@mbj4668 @rgwilton as an implementor, I do prefer standardized extensions over language revisions, as such extensions, by definition, do not change the language metamodel. With respect to functionality, it seems that tailf:annotate-statement is really what we need.

mbj4668 commented 5 years ago

I think it adds noise to the language, but doing this as standard extensions could work.

kwatsen commented 5 years ago

Important to users. Seems like all vendors have their own solutions. The term "deviation" has bad stigma.

kwatsen commented 5 years ago

Issues #46 and #52 were closed in part with the assumption that this issue would be supported.

kwatsen commented 5 years ago

Martin: this can likely be done just with extensions

jgcumming commented 3 weeks ago

The naming is confusing here with rfc7952 metadata annotations