Re: [yang-doctors] Yang syntax for a globally-unique key?

Kent Watsen <kent@watsen.net> Thu, 27 August 2020 12:38 UTC

Return-Path: <010001742fecf818-d7acbe40-b835-47a9-a88f-35eb4c8ef9a9-000000@amazonses.watsen.net>
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 408F83A0C94 for <yang-doctors@ietfa.amsl.com>; Thu, 27 Aug 2020 05:38:59 -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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.com
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 h77grHGblRXW for <yang-doctors@ietfa.amsl.com>; Thu, 27 Aug 2020 05:38:54 -0700 (PDT)
Received: from a8-31.smtp-out.amazonses.com (a8-31.smtp-out.amazonses.com [54.240.8.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 945513A0C98 for <yang-doctors@ietf.org>; Thu, 27 Aug 2020 05:38:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1598531893; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:In-Reply-To:Cc:To:References:Feedback-ID; bh=C5qz2Fh5roHA00jbcsy1JdiKqYSdYJb0F+fxLcTHVIU=; b=Wk/GCLJiTOVB3EcU/iuTztvo79T+JCnKkcAdIBVO0vffs795PbbMPgeHNz7xRIop XxI1x8sEWZzZZvoamUm6gLA8ysCLjS7hQO/OLNdG3mwmVbzqMC1s4dDLAc9MrwyoAcD UVZft1LsPLBs+UQqTcnqKsCfcpQNSG6CCMR2Sl4k=
From: Kent Watsen <kent@watsen.net>
Message-ID: <010001742fecf818-d7acbe40-b835-47a9-a88f-35eb4c8ef9a9-000000@email.amazonses.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_2CB6FF42-6E31-45E9-AC53-0FFB0D0C2118"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\))
Date: Thu, 27 Aug 2020 12:38:13 +0000
In-Reply-To: <87lfi1hnyv.fsf@nic.cz>
Cc: yang-doctors@ietf.org
To: Ladislav Lhotka <ladislav.lhotka@nic.cz>
References: <0100017425c983cb-d9471cc6-34d3-4a49-ab7b-942bca5ae697-000000@email.amazonses.com> <CABCOCHRhE9EqpgKKHpvkCWrmE4JkQN6i5kAF4EMfXF=GA1EVQg@mail.gmail.com> <df41a832-7ebd-9abf-f9e5-d0838797ded0@nic.cz> <CABCOCHS-1XuWGf8U6z=r+WnTh4zH2qfDhbTX2YaPN2fcZt1twg@mail.gmail.com> <06a32179-128a-99f0-b489-56985679964d@nic.cz> <1dab12ae-1f41-10ad-789c-17a38f344efe@nic.cz> <01000174272e7b3e-8c389f49-635c-450a-b74d-6c71a890882d-000000@email.amazonses.com> <87lfi1hnyv.fsf@nic.cz>
X-Mailer: Apple Mail (2.3608.80.23.2.2)
X-SES-Outgoing: 2020.08.27-54.240.8.31
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/hCjYSf6NqkV4nmEhs2gw3hbFRc4>
Subject: Re: [yang-doctors] Yang syntax for a globally-unique key?
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, 27 Aug 2020 12:38:59 -0000


> On Aug 26, 2020, at 3:21 AM, Ladislav Lhotka <ladislav.lhotka@nic.cz> wrote:
> 
> Kent Watsen <kent@watsen.net> writes:
> 
>> Hi Lada,
>> 
>>>>>>     Assume data model:
>>>>>> 
>>>>>>       +—rw tenants
>>>>>>           +—rw tenant [key]
>>>>>>               +—rw  key        string
>>>>>>               +—rw admins
>>>>>>                   +—rw admin [name]
>>>>>>                        +—rw name     string
>>>> <snip>
>>>> I don't see any augmentation involved in either case. Anyway, I do agree
>>>> that the unique statement should work. Otherwise, section 12.16 of RFC
>>>> 6110 essentially gives what Kent asks for, which is in this case:
>>>> 
>>>>   must "not(preceding-sibling::tenant[current()/admins/admin/name])";
>>> 
>>> Sorry, it should be
>>> 
>>>   must "not(preceding-sibling::tenant[admins/admin/name  =
>>> current()/admins/admin/name])
>> 
>> I thought "preceding-sibling” was for selecting a sibling?  In my example, “tenant” doesn’t have a sibling, so what is selected?  You *are* putting the must  statement on the “tenant” node, right?
> 
> Yes. In your example, "tenant" is a list, and its instances/entries are sibling nodes in the XPath data model. So the rule states that there must not be two "tenant" entries containing admins/admin/leaf with the same value. If this condition is violated, it is reported for the second "tenant" entry.
> 
> The same rule can be written in other ways, too, but the advantage of preceding-sibling:: is that the check is performed only "above the diagonal" of all pairwise combinations of "tenant" entries.

I see, that makes sense now.  I didn’t realize that "preceding-sibling” selected all siblings.

Pyang validated the corrected expression above, but yanglint threw an error, as described by: https://github.com/CESNET/libyang/issues/1180 <https://github.com/CESNET/libyang/issues/1180>.

I have not yet tested with Yangson.  Is it known if Yangson supports "preceding-sibling”?  Looking at https://yangson.labs.nic.cz/xpath.html <https://yangson.labs.nic.cz/xpath.html> I see this:

    NotSupported – if the input XPath expression contains a feature that
    isn’t supported by the implementation, such as the preceding:: axis.


Kent


> Lada
> 
> -- 
> Ladislav Lhotka 
> Head, CZ.NIC Labs
> PGP Key ID: 0xB8F92B08A9F76C67
> 
> _______________________________________________
> yang-doctors mailing list
> yang-doctors@ietf.org
> https://www.ietf.org/mailman/listinfo/yang-doctors