Re: [netmod] YANG 'must' Xpaths, predicates and wildcards

Alex Campbell <Alex.Campbell@Aviatnet.com> Wed, 28 March 2018 01:56 UTC

Return-Path: <Alex.Campbell@Aviatnet.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 031E8120724 for <netmod@ietfa.amsl.com>; Tue, 27 Mar 2018 18:56:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.91
X-Spam-Level:
X-Spam-Status: No, score=-1.91 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 8-hd66FNr2v1 for <netmod@ietfa.amsl.com>; Tue, 27 Mar 2018 18:56:54 -0700 (PDT)
Received: from mail-send.aviatnet.com (mail-send.aviatnet.com [192.147.115.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AC463126BF7 for <netmod@ietf.org>; Tue, 27 Mar 2018 18:56:54 -0700 (PDT)
From: Alex Campbell <Alex.Campbell@Aviatnet.com>
To: "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com>, "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: YANG 'must' Xpaths, predicates and wildcards
Thread-Index: AdPGKRar8qf0qVjUQtmgVwXGx31jZQACPNCk
Date: Wed, 28 Mar 2018 01:56:52 +0000
Message-ID: <1522202212651.39558@Aviatnet.com>
References: <AM3PR07MB112461BED4C88FDC4343C4F39BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
In-Reply-To: <AM3PR07MB112461BED4C88FDC4343C4F39BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
Accept-Language: en-NZ, en-US
Content-Language: en-NZ
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.15.6.10]
Content-Type: multipart/alternative; boundary="_000_152220221265139558Aviatnetcom_"
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/S-fMzfSSlJ7fbDT3ggmmCI4Bcek>
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 01:56:56 -0000

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> on behalf of Sterne, Jason (Nokia - CA/Ottawa) <jason.sterne@nokia.com>
Sent: Wednesday, 28 March 2018 1:10 p.m.
To: 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