Re: [yang-doctors] Question about absolute and relative paths in YANG
Martin Björklund <mbj+ietf@4668.se> Mon, 15 November 2021 16:55 UTC
Return-Path: <mbj+ietf@4668.se>
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 4C4453A0EAD
for <yang-doctors@ietfa.amsl.com>; Mon, 15 Nov 2021 08:55:50 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.101
X-Spam-Level:
X-Spam-Status: No, score=-2.101 tagged_above=-999 required=5
tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key)
header.d=4668.se header.b=kp2CJ9f4;
dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=AxknsmKU
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 7eGpNVOhh6D3 for <yang-doctors@ietfa.amsl.com>;
Mon, 15 Nov 2021 08:55:45 -0800 (PST)
Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com
[66.111.4.29])
(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by ietfa.amsl.com (Postfix) with ESMTPS id BADDF3A0ECE
for <yang-doctors@ietf.org>; Mon, 15 Nov 2021 08:55:42 -0800 (PST)
Received: from compute6.internal (compute6.nyi.internal [10.202.2.46])
by mailout.nyi.internal (Postfix) with ESMTP id 1823B5C027F;
Mon, 15 Nov 2021 11:55:40 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
by compute6.internal (MEProxy); Mon, 15 Nov 2021 11:55:40 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=4668.se; h=date
:message-id:to:cc:subject:from:in-reply-to:references
:mime-version:content-type:content-transfer-encoding; s=fm3; bh=
EpJmFxizNiWSTDkeeTf/Jwtaxy5E2SPVxiob2pKW5W4=; b=kp2CJ9f4hC2ZNIOe
Sd6wxL8I/iUxitD83SQhzxIa4+TcEPHmz+iQh/2USTFb1BvhsQatlf9LikCkaQJy
dXPzMNuF6BZDLeOy24dqgApLEV5xgKzQVERSfq4EbrOWJFzdaCfTnus4JhvL3P1c
L7k700oXBAG2c2u1YhCjGAE3LEOOy/z09L2L3eCTJpO4PV+CEQ3ns/zmftBk04kw
5Z9Pfx0XkrUh+PKlQSMRoSwz2DPmaWXUIHq5yZyVfcTxa3gmmRV/AADw6UY80nFf
ye5vle/QWs0tQ8QdiUs0kHMtMN3qe/z2Vv4bjcorDX7J2PGNptfL6EuQfFeGqCuQ
wXCEbA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:date:from:in-reply-to:message-id:mime-version:references
:subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
:x-sasl-enc; s=fm1; bh=EpJmFxizNiWSTDkeeTf/Jwtaxy5E2SPVxiob2pKW5
W4=; b=AxknsmKUxnQrro3ga2cztnBod1Bz2FSmmwpToK7v4S6i7694Gz21VzV52
2nmCBqICmYhphCpY1Al+NfhnU1l2w4vuwFlBA6B3zv0XWo9S/apS+Z1jzbPozPPz
NT8bok/Blmq9fmPvn/VPrGWVIB89af2T2VqIhEhCS6Q8HC3UcUQ3tlDswYKwknBF
SD2by5eGx0OMJVjARo8n9wqSluKqJgc+bXw1WhyEIvKl+71qiJttxyRVAYuZ+f7y
cQB/9xtdiDRfLuHysHbHUWYUi7bSe1TI41mVYU7aP8BeeYq2QRflO3lDsZEuExpg
5E7yJ1JPzibyZM113bLd0xKLvom2w==
X-ME-Sender: <xms:C5GSYXLpiqRp3E5AdqdjiQNIIlI_eJIStAB7raQZjq5Tx_r4ESn2KA>
<xme:C5GSYbLt7zWhtiTo2opprQgNw05brQ3HxTdsdW4W8DhKJa0rnwVGEJwdg4ivm92ro
I6M_1YLEyJWkOWpDvs>
X-ME-Received: <xmr:C5GSYft4Lvpa1hXrRLtBSIcw59HrQxUnKY7caeZ1Dytay3FV-MZsTaotbWujVtdidLkRb4n73rjpDliihvnNJV9AU-bB9B3M8Q>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfedtgdeikecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecunecujfgurhepfffkvffuhfgjfhfogggtgfesthhqre
dtredtudenucfhrhhomhepofgrrhhtihhnuceujhpnrhhklhhunhguuceomhgsjhdoihgv
thhfseegieeikedrshgvqeenucggtffrrghtthgvrhhnpeeitdethfdthfekteelteekve
eifefhudduueekvdefleegtdevgefgteefjefgleenucevlhhushhtvghrufhiiigvpedt
necurfgrrhgrmhepmhgrihhlfhhrohhmpehmsghjodhivghtfhesgeeiieekrdhsvg
X-ME-Proxy: <xmx:C5GSYQZxwryvZq1SQAUWGJAstZMOv08Q-kFezBjt2mfW4yFdm7bqJA>
<xmx:C5GSYeZHIbLOUTHMrJvsoFcSeTfWdMS05AXpM5CnjFUpVswCUQh08g>
<xmx:C5GSYUDdsvvQGijzIre9KUTu5aKSgrgQotW7iSePSnyXq_gGUNj3Qw>
<xmx:DJGSYdkr-5wpPieiJhBD-31rVu6ZtNlxC5awZey1PDCBij_081E7pg>
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
15 Nov 2021 11:55:38 -0500 (EST)
Date: Mon, 15 Nov 2021 17:55:37 +0100 (CET)
Message-Id: <20211115.175537.1719961127066875828.id@4668.se>
To: Italo.Busi@huawei.com
Cc: yang-doctors@ietf.org, aihuaguo@futurewei.com, zhenghaomian@huawei.com
From: Martin =?iso-8859-1?Q?Bj=F6rklund?= <mbj+ietf@4668.se>
In-Reply-To: <9ed9adedd20543eeaf4d6f5f6d1e3d7c@huawei.com>
References: <72a905a18a334460864bfc95be778150@huawei.com>
<9ed9adedd20543eeaf4d6f5f6d1e3d7c@huawei.com>
X-Mailer: Mew version 6.8 on Emacs 26.3
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/57AhHNrSTzxSwwCo8FKcMbBmZ6I>
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:55:50 -0000
Hi, Italo Busi <Italo.Busi@huawei.com> wrote: > 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 I don't recognize this preference. Also I don't know if you refer to XPath paths in must/when or something else. I assume you mean XPath paths. IMO, a short relative path is often easier to read and understand, and easier to get right. In some cases it truly doesn't matter, and in some other cases you must use one and not the other. In the examples below, I'd use a relative path. /martin > 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 >
- [yang-doctors] Question about absolute and relati… Italo Busi
- Re: [yang-doctors] Question about absolute and re… Italo Busi
- Re: [yang-doctors] Question about absolute and re… Martin Björklund
- Re: [yang-doctors] Question about absolute and re… Ladislav Lhotka
- Re: [yang-doctors] Question about absolute and re… Italo Busi
- Re: [yang-doctors] Question about absolute and re… Ladislav Lhotka