Re: [netmod] YANG 'must' Xpaths, predicates and wildcards
Martin Bjorklund <mbj@tail-f.com> Wed, 28 March 2018 17:27 UTC
Return-Path: <mbj@tail-f.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 2D4A3126C89 for <netmod@ietfa.amsl.com>; Wed, 28 Mar 2018 10:27:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.911
X-Spam-Level:
X-Spam-Status: No, score=-1.911 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 AsVY7UDHa-5n for <netmod@ietfa.amsl.com>; Wed, 28 Mar 2018 10:27:53 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id ADDF11243F3 for <netmod@ietf.org>; Wed, 28 Mar 2018 10:27:53 -0700 (PDT)
Received: from localhost (h-80-27.A165.priv.bahnhof.se [212.85.80.27]) by mail.tail-f.com (Postfix) with ESMTPSA id 368101AE00A0; Wed, 28 Mar 2018 19:27:51 +0200 (CEST)
Date: Wed, 28 Mar 2018 19:27:50 +0200
Message-Id: <20180328.192750.259736782775438140.mbj@tail-f.com>
To: jason.sterne@nokia.com
Cc: Alex.Campbell@Aviatnet.com, netmod@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <AM3PR07MB112427002EE13423DDA8A6E49BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
References: <AM3PR07MB112461BED4C88FDC4343C4F39BA30@AM3PR07MB1124.eurprd07.prod.outlook.com> <1522202212651.39558@Aviatnet.com> <AM3PR07MB112427002EE13423DDA8A6E49BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/kqigAG5jFWdiLh1zTNIcTVeGqpE>
Subject: Re: [netmod] YANG 'must' Xpaths, predicates and wildcards
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
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: Wed, 28 Mar 2018 17:27:56 -0000
"Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com> wrote: > Thanks Alex. Sorry about those sloppy mistakes. I agree about the > ../a-list and I should have said count > 0. > > In the 2nd part of my email, my intention was to only allow foo to be > configured if a-list has at least one entry configured. So I don't > think min-elements 1 would work. I don't want to always require an > entry in a-list. I only want to require one if foo is configured. > > I guess this also achieves the same thing right ? > must "../a-list[entry=*]"; Yes, if all a-list entries has a node called "entry". But if that't what you want, do: must "../a-list[entry]"; > If foo has a default value, then does that mean the "must" is > evaluated even if foo is deleted from the config ? > leaf foo { > must "../a-list"; <- always evaluated because of default ? > type uint16; > default 5; > } > If the must is always evaluated then it would be the equivalent of > having min-elements 1 in a-list. Correct. /martin > > Rgds, > Jason > > From: Alex Campbell [mailto:Alex.Campbell@Aviatnet.com] > Sent: Tuesday, March 27, 2018 9:57 PM > To: Sterne, Jason (Nokia - CA/Ottawa) <jason.sterne@nokia.com>; > netmod@ietf..org > Subject: Re: YANG 'must' Xpaths, predicates and wildcards > > > Hi, > > > > For one thing, it should be ../a-list since a-list is not a child of > foo. > > Also - if foo is not configured and has no default value, then any > must expressions in foo are not evaluated because it is not part of > the "accessible tree". (I tested this in ConfD) > > Apart from these issues, yes it will behave as you expect - it will > fail if a-list contains no entries. > > > > must "count(a-list) > 1"; is not equivalent since it requires at least > two entries. > > > > However, you can more simply add a min-elements 1; statement to a-list > to achieve the same goal - no XPath required. > > > > ________________________________ > From: netmod <netmod-bounces@ietf.org<mailto:netmod-bounces@ietf.org>> > on behalf of Sterne, Jason (Nokia - CA/Ottawa) > <jason.sterne@nokia.com<mailto:jason.sterne@nokia.com>> > Sent: Wednesday, 28 March 2018 1:10 p.m. > To: netmod@ietf.org<mailto:netmod@ietf.org> > Subject: [netmod] YANG 'must' Xpaths, predicates and wildcards > > Hi all, > > I'm pretty sure that this xpath (e.g. in a must statement) isn't > correct: > > (A) ../container-a/list-b[name=*]/some-leaf > > and should just be this instead: > > (B) ../container-a/list-b/some-leaf > > Or is the * an allowable wildcard for a key value in a predicate ? > > I also had a question about whether the following "must" correctly > checks that at least one entry exists in a-list. > > container c1 { > leaf foo { > must "a-list"; > type uint16; > } > list a-list { > key "entry"; > leaf entry { > type uint16; > } > leaf another-entry { > type uint32; > } > } > } > > I think I could also replace that must with the following: > must "count(a-list) > 1"; > but does must "a-list"; achieve the same thing ? > > Rgds, > Jason
- [netmod] YANG 'must' Xpaths, predicates and wildc… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Alex Campbell
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Ladislav Lhotka
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Alex Campbell