[YANGTOOLS-1356] Introduce model.api.stmt.DataNodeIdentifier Created: 26/Oct/21  Updated: 10/Apr/22  Resolved: 31/Oct/21

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Highest
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Won't Do Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
is blocked by YANGTOOLS-1358 Move SchemaNodeIdentifier to yang-common Resolved
Duplicate
is duplicated by YANGTOOLS-832 Add instance-identifier and leaf-refe... Resolved
Relates
relates to YANGTOOLS-1295 Add support for yang-ext:mount instan... Resolved
relates to YANGTOOLS-1114 Reconsider DefaultEffectiveStatement ... Confirmed

 Description   

We are faced again and again with the problem of interfacing various constructs which boil down to addressing YANG-modeled data.

The usual solution involves YangInstanceIdentifier, but that has non-trivial mapping to YANG due to its addressing mode of operation, which takes into account keyed list entries as well as augmentations. It also accumulated weird things like:

  • wildcards, i.e. the use of NodeIdentifier to say 'match all MapEntryNodes'
  • partial matches, i.e. NodeIdentifierWithPredicates without all the keys corresponding to schema present

In yang-model-api we have had a similar (but different) problem with SchemaPath, which we solved through introduction of SchemaNodeIdentifier and EffectiveStatementInference, each of which has a narrow scope of what it solves and how it operates.

At the end of the day, at least where NETCONF/RESTCONF is concerned, we really need an identifier which works strictly on YANG data tree addressing, pure and simple. At the heart of it is something like:

class DataTreeStep {
  QName nodeId;
  Map<QName, Object> predicates; // may be empty
}

class DataTreeIdentifier {
  List<DataTreeStep> steps; // at least one
}

Taking the YangInstanceIdentifier/wildcard case to heart, though, we need two dedicated specializations of that structure:

  1. one for read requests, where it is treated like a NETCONF subtree filter
  2. one for read responses, where it is treated like a proper instance identifier, i.e. predicates for list keys are fully populated.
    The specializations must not share a (publicly visible) superclass, so that there is no way of confusing the request and response side. The DataTreeIdentifier -> DataTreeFilter conversion is trivial.

We then should provide schema-assisted utilities to covert:

  • DataTreeFilter -> DataTreeIdentifier, which validates the filter specifies all key list predicates
  • DataTreeIdentifier <-> exact YangInstanceIdentifier
  • DataTreeFilter -> wildcard YangInstanceIdentifier which matches the superset of the DataTreeFilter (plus a structure describing what are the parts where a DataTreeChangeListener is providing a superset)
  • partial/wildcard YangInstanceIdentifier -> DataTreeFilter

This toolkit should make life a lot easier for our downstreams.



 Comments   
Comment by Robert Varga [ 26/Oct/21 ]

So we first need DataTreeIdentifier, as it is a direct counterpart to SchemaNodeIdentifier. Both should live in yang.common.

Comment by Robert Varga [ 27/Oct/21 ]

Since SchemaNodeIdentifier already exists, it takes precedence and will be the first to land in yang-common.

Comment by Robert Varga [ 30/Oct/21 ]

Actually no, these things do should not live in yang.common.
First of all, the use case for DataNodeFilter is already filled in by use of restricted yang-xpath-api construct – so we actually have to correct representation with all the flexibility we will ever need.
That leaves DataNodeIdentifier, whcih is a counterpart to yang-data-api's YangInstanceIdentifier, really. For that simple reason we should not be exposing it in yang.common, as it will cause confusion to yang-data-api's users.
Users who overlap the two already get exposure to SchemaNodeIdentifier and a yang-model-api construct, so it is only fair they get the DataNodeIdentifier visibility as well.

Comment by Robert Varga [ 31/Oct/21 ]

As it turns out we have the correct contract available in yang-xpath-api, and we have a instance-identifier parser available in YangXPathExpression.interpretAsInstanceIdentifier().
All we need to do is expose it as a separate parsing construct.

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