Re: [netmod] yang nested list reference question

Martin Bjorklund <mbj@tail-f.com> Fri, 23 January 2015 12:06 UTC

Return-Path: <mbj@tail-f.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DD4BC1A909B for <netmod@ietfa.amsl.com>; Fri, 23 Jan 2015 04:06:51 -0800 (PST)
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, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
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 R4z_NmewsGYm for <netmod@ietfa.amsl.com>; Fri, 23 Jan 2015 04:06:50 -0800 (PST)
Received: from mail.tail-f.com (mail.tail-f.com [83.241.162.140]) by ietfa.amsl.com (Postfix) with ESMTP id E26F31A19FA for <netmod@ietf.org>; Fri, 23 Jan 2015 04:06:49 -0800 (PST)
Received: from localhost (x15.tail-f.com [192.168.1.60]) by mail.tail-f.com (Postfix) with ESMTPSA id F218D1280052; Fri, 23 Jan 2015 13:06:48 +0100 (CET)
Date: Fri, 23 Jan 2015 13:06:48 +0100 (CET)
Message-Id: <20150123.130648.1464345748997979172.mbj@tail-f.com>
To: j.schoenwaelder@jacobs-university.de
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <20150123115600.GA39304@elstar.local>
References: <20150123115600.GA39304@elstar.local>
X-Mailer: Mew version 6.5 on Emacs 23.4 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/m0s9xAcDpJVm1a0-eWyTDvpXtZ0>
Cc: netmod@ietf.org
Subject: Re: [netmod] yang nested list reference question
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
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: <http://www.ietf.org/mail-archive/web/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, 23 Jan 2015 12:06:52 -0000

Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> Hi,
> 
> lets say I have a list 'a' (keyed by n) with a nested list 'b' (keyed
> by m):
> 
>   list a {
>     key n;
>     leaf n;
> 
>     list b {
>       key m;
>       leaf m;
>     }
>   }
> 
> I now want to refer to a list element of list 'b' within list 'a'.
> What is the best way to express this?
> 
> I could do this:
> 
>   list c {
>     key x;
>     leaf x;
> 
>     leaf aref { type leafref { path /a/n; } }
>     leaf bref { type leafref { path /a/b/m; } }
>   }
> 
>   What is the best way to constrain the leafrefs so that they are
>   forced to point to a 'b' within an 'a' element?


 leaf bref {
   type leafref {
     path "/a[n = current()/../aref]/b/m";
   }
 }

Note that this special syntax with current() is allowed by a leafref;
and the reason is to handle this common use case.

See RFC 6020, section 9.9.5.

With a third key (and more), this syntax still works, but gets
clumsy.  This is why I have suggested to use:

   path "deref(../aref)/../b/m";

as an optional syntax to leafref path.


/martin