Re: [yang-doctors] Question about absolute and relative paths in YANG

Italo Busi <Italo.Busi@huawei.com> Mon, 15 November 2021 16:36 UTC

Return-Path: <Italo.Busi@huawei.com>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3F1EE3A0E4C for <yang-doctors@ietfa.amsl.com>; Mon, 15 Nov 2021 08:36:12 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.896
X-Spam-Level:
X-Spam-Status: No, score=-1.896 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vm0GWUQzSIud for <yang-doctors@ietfa.amsl.com>; Mon, 15 Nov 2021 08:36:07 -0800 (PST)
Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3651A3A0E48 for <yang-doctors@ietf.org>; Mon, 15 Nov 2021 08:36:07 -0800 (PST)
Received: from fraeml713-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HtF8d4flMz6875y; Tue, 16 Nov 2021 00:32:17 +0800 (CST)
Received: from fraeml715-chm.china.huawei.com (10.206.15.34) by fraeml713-chm.china.huawei.com (10.206.15.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 15 Nov 2021 17:35:58 +0100
Received: from fraeml715-chm.china.huawei.com ([10.206.15.34]) by fraeml715-chm.china.huawei.com ([10.206.15.34]) with mapi id 15.01.2308.020; Mon, 15 Nov 2021 17:35:58 +0100
From: Italo Busi <Italo.Busi@huawei.com>
To: "yang-doctors@ietf.org" <yang-doctors@ietf.org>
CC: Zhenghaomian <zhenghaomian@huawei.com>, 'Aihua Guo' <aihuaguo@futurewei.com>
Thread-Topic: Question about absolute and relative paths in YANG
Thread-Index: Adewm28iyulrueZ7Rp+MN5B2Vq4mbApo15Lw
Date: Mon, 15 Nov 2021 16:35:58 +0000
Message-ID: <9ed9adedd20543eeaf4d6f5f6d1e3d7c@huawei.com>
References: <72a905a18a334460864bfc95be778150@huawei.com>
In-Reply-To: <72a905a18a334460864bfc95be778150@huawei.com>
Accept-Language: it-IT, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.203.246.111]
Content-Type: multipart/alternative; boundary="_000_9ed9adedd20543eeaf4d6f5f6d1e3d7chuaweicom_"
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/KQycgH7DTfA-XGHbLque09LudBk>
Subject: Re: [yang-doctors] Question about absolute and relative paths in YANG
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 15 Nov 2021 16:36:12 -0000

Any feedbacks/comments about this question?

Thanks, Italo

From: Italo Busi
Sent: giovedì 23 settembre 2021 18:56
To: yang-doctors@ietf.org
Cc: Zhenghaomian <zhenghaomian@huawei.com>om>; 'Aihua Guo' <aihuaguo@futurewei.com>
Subject: Question about absolute and relative paths in YANG

Hi YANG doctors,

I am quite active within the IETF CCAMP and TEAS WGs on YANG models for optical transport networks

We are having some discussions about the use of absolute and relative paths in some of the drafts we are developing for IETF

I have been told that YANG doctors prefer absolute paths to relative paths

We think it makes a lot of sense to use absolute paths whenever possible but there are some cases where we are not sure whether and how we could use absolute paths

We would appreciate your opinions and suggestions about how to address these cases

One case could be one of the augment statements defined in RFC8795 (TE Topology model):

  augment "/nw:networks/nw:network/nw:node/tet:te/"
        + "tet:te-node-attributes/tet:connectivity-matrices/"
        + "tet:label-restrictions/tet:label-restriction" {
    when "../../../../../../nw:network-types/tet:te-topology/"
       + "example-topology" {

The intention is to say that this augmentation applies only to a specific network-types of this network instance. Using an absolute path the code could become:

  augment "/nw:networks/nw:network/nw:node/tet:te/"
        + "tet:te-node-attributes/tet:connectivity-matrices/"
        + "tet:label-restrictions/tet:label-restriction" {
when "/nw:networks/nw:network[nw:network-id=current()../../../../../../nw:network-id]/"
   + "nw:network-types/tet:te-topology/"
       + "example-topology" {

It seems that using the absolute path is moving the issue on requiring a relative path to get the value of the network-id of this network

Is there an alternative solution to avoid using relative path in this case?

Another case we have considered is the definition of a grouping with a leaf that references another node within the same network. In this case, using a relative path or an absolution path embedding a relative path required to get the network-id of this network, would make quite difficult to re-use this grouping in multiple places within the YANG tree

One work-around could be to use the refine statement, such as:

grouping node-reference {
  leaf network-ref {
    type leafref {
      path "/nw:networks/nw:network/nw:network-id"
    }
  }

  leaf node-ref {
    type leafref {
      path "deref(../network-ref)/../nw:node/nw:nw:node-id"
    }
  }
}

augment "/nw:networks/nw:network/nw:node/tet:te/"
      + "tet:te-node-attributes/tet:connectivity-matrices/"
      + "tet:label-restrictions/tet:label-restriction" {
  uses node-reference {
    refine network-ref {
      default current()/../../../../../../network-id;
      must current() = current()/../../../../../../network-id;
   }
  }

This work-around seems a bit weird but at least it should the need to use relative paths within the grouping but keep the requirement to use the relative paths in the refine statements

Is there a better solution to avoid using relative path within the grouping?

Thanks in advance for your help

Italo