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

Italo Busi <Italo.Busi@huawei.com> Thu, 23 September 2021 16:56 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 2D4A93A132B for <yang-doctors@ietfa.amsl.com>; Thu, 23 Sep 2021 09:56:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 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] 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 OHpQ5Q666Q1S for <yang-doctors@ietfa.amsl.com>; Thu, 23 Sep 2021 09:56:23 -0700 (PDT)
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 02E9C3A1327 for <yang-doctors@ietf.org>; Thu, 23 Sep 2021 09:56:23 -0700 (PDT)
Received: from fraeml710-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HFh8058yMz67PN6; Fri, 24 Sep 2021 00:53:52 +0800 (CST)
Received: from fraeml715-chm.china.huawei.com (10.206.15.34) by fraeml710-chm.china.huawei.com (10.206.15.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 23 Sep 2021 18:56:19 +0200
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.008; Thu, 23 Sep 2021 18:56:19 +0200
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+MN5B2Vq4mbA==
Date: Thu, 23 Sep 2021 16:56:19 +0000
Message-ID: <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.47.81.55]
Content-Type: multipart/alternative; boundary="_000_72a905a18a334460864bfc95be778150huaweicom_"
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/8EHiqGRcAxJkv2OtSLcU9a7i848>
Subject: [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: Thu, 23 Sep 2021 16:56:26 -0000

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