Re: [netmod] YANG 'when' with absolute path

Italo Busi <Italo.Busi@huawei.com> Fri, 28 January 2022 11:12 UTC

Return-Path: <Italo.Busi@huawei.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 09BA03A0C32; Fri, 28 Jan 2022 03:12:35 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.197
X-Spam-Level:
X-Spam-Status: No, score=-4.197 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=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 MZFmg3ZwRX7C; Fri, 28 Jan 2022 03:12:30 -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 0CF1C3A0C2D; Fri, 28 Jan 2022 03:12:30 -0800 (PST)
Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JlZSJ52mCz67x4F; Fri, 28 Jan 2022 19:08:00 +0800 (CST)
Received: from fraeml715-chm.china.huawei.com (10.206.15.34) by fraeml711-chm.china.huawei.com (10.206.15.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 28 Jan 2022 12:12:25 +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.021; Fri, 28 Jan 2022 12:12:25 +0100
From: Italo Busi <Italo.Busi@huawei.com>
To: 'Michal Vaško' <mvasko@cesnet.cz>, "netmod@ietf.org" <netmod@ietf.org>, "yang-doctors@ietf.org" <yang-doctors@ietf.org>
CC: Ladislav Lhotka <ladislav.lhotka@nic.cz>, Martin Björklund <mbj+ietf@4668.se>, "'draft-ietf-ccamp-flexigrid-yang@ietf.org'" <draft-ietf-ccamp-flexigrid-yang@ietf.org>
Thread-Topic: [netmod] YANG 'when' with absolute path
Thread-Index: AQHYABNidMQeleH48EKxhSayhVME56xndDzwgADu7ICAD/PpQA==
Date: Fri, 28 Jan 2022 11:12:25 +0000
Message-ID: <150e7ecee5d24bbb9ddc77cf7c71929d@huawei.com>
References: <010ba32d4f934498be4a032b864a65bc@huawei.com> <49b-61e66700-61-555dec00@38936218>
In-Reply-To: <49b-61e66700-61-555dec00@38936218>
Accept-Language: it-IT, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.81.205.68]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/_T5BSVb-zcgyD53vt5BXshL93gY>
Subject: Re: [netmod] YANG 'when' with absolute path
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 28 Jan 2022 11:12:35 -0000

Thanks Michal for the clarification

We have discussed this issue among the co-authors of draft-ietf-ccamp-flexigrid-yang and we are not sure about how to address a WG LC comment we have received on this topic

While the YANG code using the ancestor instead of relative paths looks easier to read and understand to an human code writer/reader, we are concerned about whether it is worthwhile standardizing in IETF a YANG data model which fails compilation with yanglint

The YANG code is correct (at least it passes pyang validation) but it fails yanglint validation just because yanglint does not support axes, so we expect that as soon as we upload the updated draft, the IETF datatracker will signal yang validation errors

Is there any guideline/suggestion from Netmod WG and YANG doctors on how to deal with such a case?

Thanks, Italo (on behalf of co-authors)

> -----Original Message-----
> From: Michal Vaško [mailto:mvasko@cesnet.cz]
> Sent: martedì 18 gennaio 2022 08:07
> To: Italo Busi <Italo.Busi@huawei.com>
> Cc: Ladislav Lhotka <ladislav.lhotka@nic.cz>; Martin Björklund
> <mbj+ietf@4668.se>; netmod@ietf.org
> Subject: Re: [netmod] YANG 'when' with absolute path
> 
> Hi,
> 
> yanglint uses its own XPath implementation, which unfortunately does not
> support axes, hence the error.
> 
> Regards,
> Michal
> 
> On Monday, January 17, 2022 16:59 CET, Italo Busi
> <Italo.Busi=40huawei.com@dmarc.ietf.org> wrote:
> 
> > Lada, Martin,
> >
> > Thanks for your suggestion and thanks Tom for having raised this issue
> > to Netmod WG
> >
> > We have tried to follow your suggestion and replaced the relative paths with:
> >       when "ancestor::nw:network/nw:network-types/tet:te-topology"
> >
> > You can find the updated YANG module on github:
> >
> > https://github.com/ietf-ccamp-wg/draft-ietf-ccamp-flexigrid-yang/tree/
> > wg-lc-resolution
> >
> > However, we have found some issues when compiling the new code with
> yanglint. This is the error that we have got from the on-line YANG validator:
> >
> >       libyang err : Invalid character 'a'[1] of expression
> 'ancestor::nw:network/nw:network-types/tet:te-topology/flexgt:flexi-grid-
> topology'. (/ietf-flexi-grid-
> topology:{augment='/nw:networks/nw:network/nt:link/tet:te/tet:te-link-
> attributes/tet:underlay/tet:primary-path/tet:path-
> element/tet:type/tet:label/tet:label-hop/tet:te-label/tet:technology'})
> >       YANGLINT[E]: Processing schema module from
> /var/yang/tmp/yangvalidator/yangvalidator-v2-workdir-tNQJZOjI/ietf-flexi-
> grid-topology.yang failed.
> >
> > Is this an issue with yanglint or with the updated code?
> >
> > Pyang compilation does not return any error/warning
> >
> > Thanks in advance
> >
> > Aihua, Sergio and Italo
> >
> > > -----Original Message-----
> > > From: Ladislav Lhotka [mailto:ladislav.lhotka@nic.cz]
> > > Sent: domenica 2 gennaio 2022 10:58
> > > To: Martin Björklund <mbj+ietf@4668.se>
> > > Cc: cabo@tzi.org; netmod@ietf.org
> > > Subject: Re: [netmod] YANG 'when' with absolute path
> > >
> > >
> > >
> > > On 02. 01. 22 10:43, Martin Björklund wrote:
> > > > Hi,
> > > >
> > > > Ladislav Lhotka <ladislav.lhotka@nic.cz<mailto:ladislav.lhotka@nic.cz>>
> wrote:
> > > >> Carsten Bormann <cabo@tzi.org<mailto:cabo@tzi.org>> writes:
> > > >>
> > > >>> On 2021-12-30, at 13:29, tom petch
> <ietfc@btconnect.com<mailto:ietfc@btconnect.com>> wrote:
> > > >>>>
> > > >>>>        when
> > > >>>> "../../../../../../nw:network-types/tet:te-topology/“
> > > >>>
> > > >>> I’m probably showing my ignorance about YANG again, but what is
> > > >>> the reason this is not phrased as
> > > >>>
> > > >>>        when "./ancestor::nw:network-types/tet:te-topology/“
> > > >>
> > > >> Yes, this would work, with a minor correction:
> > > >>
> > > >>      when "./ancestor::node()/nw:network-types/tet:te-topology"
> > > >>
> > > >> because 'nw:network-types' isn't an ancestor of the context node.
> > > >> Also, the initial './' isn't actually needed, hence
> > > >>
> > > >>      when "ancestor::node()/nw:network-types/tet:te-topology"
> > > >
> > > > Or the more direct:
> > > >
> > > >      when "ancestor::nw:network/nw:network-types/tet:te-topology"
> > >
> > > Right, this is the best option.
> > >
> > > >
> > > > This style works if we can guarantee that there will be exactly
> > > > one node "nw:network" among our ancestors.
> > > >
> > > > It is perhaps easier to get this style right w/o a YANG compiler
> > > > (which would detect if the number of ".." in the relative path is
> > > > wrong), but the relative path might be easier to understand for a
> > > > casual reader.
> > >
> > > +1
> > >
> > > Lada
> > >
> > > >
> > > >
> > > >
> > > > /martin
> > > >
> > > >
> > > >
> > > >>
> > > >> Lada
> > > >>
> > > >>>
> > > >>> ?
> > > >>>
> > > >>> Grüße, Carsten
> > > >>>
> > > >>> _______________________________________________
> > > >>> netmod mailing list
> > > >>> netmod@ietf.org<mailto:netmod@ietf.org>
> > > >>> https://www.ietf.org/mailman/listinfo/netmod
> > > >>
> > > >> --
> > > >> Ladislav Lhotka
> > > >> Head, CZ.NIC Labs
> > > >> PGP Key ID: 0xB8F92B08A9F76C67
> > > >>
> > > >> _______________________________________________
> > > >> netmod mailing list
> > > >> netmod@ietf.org<mailto:netmod@ietf.org>
> > > >> https://www.ietf.org/mailman/listinfo/netmod
> > >
> > > --
> > > Ladislav Lhotka
> > > Head, CZ.NIC Labs
> > > PGP Key ID: 0xB8F92B08A9F76C67
> > >
> >
> >