[YANGTOOLS-575] Introduce amend extension with annotate semantics Created: 25/Jan/16  Updated: 09/Jul/21

Status: Confirmed
Project: yangtools
Component/s: parser
Affects Version/s: None
Fix Version/s: None

Type: New Feature
Reporter: Tony Tkacik Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
blocks YANGTOOLS-418 Deficiencies in current yangtool gene... Confirmed

 Description   

Define and implement extension which would allow amend existing definition in third party (imported) module and introduce additional extensions to such preexisting definition without need to modify original model.



 Comments   
Comment by Robert Varga [ 31/Mar/18 ]

Extension argument needs to be able to target any YANG statement, hence requires something like StatementPath in yang-model-api. A statement path is a slightly corrected SchemaPath, which will include information about the namespace in which the lookup needs to take place.

As a first cut, this could look like this:

amend:amend "/d:foo:foo/g:foo:foo/t:foo:foo" {
    units bar;
}

which would be targeting the inner-most statement of

module foo {
    prefix foo;

    container foo {
        grouping foo {
            typedef foo {
               type string;
            }
        }
    }
}

The argument syntax needs to allow for repetitive prefixes to be not need. The prefixes we need are:

  • 'c' case: nesting expands implicit cases
  • 'd' data: container, list, leaf, leaf-list, choice, rpc, action, notification, anyxml, anydata
  • 'e' extension
  • 'f' feature
  • 'g' grouping
  • 'i' identity
  • 't' typedef
  • 'u' union child type: child offset
  • 'x' deviate

The last of which deals with types defined in-line within a union definition, as its member subtypes can be anonymous.

Comment by Robert Varga [ 12/Apr/18 ]

After some prototyping, the structure of argument has changed. The extension will also need to be restricted to prepending extension statements. Furthermore the parser and maven plugin will need to be taught about models which are using this extension, because such models need to be pulled in from the library whenever their target(s) are requested – otherwise incremental builds, such as compile-time of downstreams which reference a model extended in this way would onlyt see the base model, but not the extensions.

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