[netmod] yang nested list reference question

Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> Fri, 23 January 2015 11:56 UTC

Return-Path: <j.schoenwaelder@jacobs-university.de>
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 932161A90A1 for <netmod@ietfa.amsl.com>; Fri, 23 Jan 2015 03:56:07 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.26
X-Spam-Level:
X-Spam-Status: No, score=-2.26 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_EQ_DE=0.35, RCVD_IN_DNSWL_LOW=-0.7, 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 rYWcJYEf3xwG for <netmod@ietfa.amsl.com>; Fri, 23 Jan 2015 03:56:05 -0800 (PST)
Received: from atlas3.jacobs-university.de (atlas3.jacobs-university.de [212.201.44.18]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D5CEC1A9097 for <netmod@ietf.org>; Fri, 23 Jan 2015 03:56:04 -0800 (PST)
Received: from localhost (demetrius5.irc-it.jacobs-university.de [10.70.0.222]) by atlas3.jacobs-university.de (Postfix) with ESMTP id AB02AC3C for <netmod@ietf.org>; Fri, 23 Jan 2015 12:56:03 +0100 (CET)
X-Virus-Scanned: amavisd-new at jacobs-university.de
Received: from atlas3.jacobs-university.de ([10.70.0.220]) by localhost (demetrius5.jacobs-university.de [10.70.0.222]) (amavisd-new, port 10030) with ESMTP id noWGBWzX38ic for <netmod@ietf.org>; Fri, 23 Jan 2015 12:55:37 +0100 (CET)
Received: from hermes.jacobs-university.de (hermes.jacobs-university.de [212.201.44.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hermes.jacobs-university.de", Issuer "Jacobs University CA - G01" (verified OK)) by atlas3.jacobs-university.de (Postfix) with ESMTPS for <netmod@ietf.org>; Fri, 23 Jan 2015 12:56:03 +0100 (CET)
Received: from localhost (demetrius2.jacobs-university.de [212.201.44.47]) by hermes.jacobs-university.de (Postfix) with ESMTP id 0B7EB20036 for <netmod@ietf.org>; Fri, 23 Jan 2015 12:56:03 +0100 (CET)
X-Virus-Scanned: amavisd-new at jacobs-university.de
Received: from hermes.jacobs-university.de ([212.201.44.23]) by localhost (demetrius2.jacobs-university.de [212.201.44.32]) (amavisd-new, port 10024) with ESMTP id sG8hH6BRBaX8; Fri, 23 Jan 2015 12:48:08 +0100 (CET)
Received: from elstar.local (elstar.jacobs.jacobs-university.de [10.50.231.133]) by hermes.jacobs-university.de (Postfix) with ESMTP id 09A8D20035; Fri, 23 Jan 2015 12:56:02 +0100 (CET)
Received: by elstar.local (Postfix, from userid 501) id 7FB8F30E53E3; Fri, 23 Jan 2015 12:56:01 +0100 (CET)
Date: Fri, 23 Jan 2015 12:56:00 +0100
From: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
To: netmod@ietf.org
Message-ID: <20150123115600.GA39304@elstar.local>
Mail-Followup-To: netmod@ietf.org
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
User-Agent: Mutt/1.4.2.3i
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/I3_X7ywT90I4a6Qsm1vCwsha2uI>
Subject: [netmod] yang nested list reference question
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
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 11:56:07 -0000

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?

Alternatively, I could consider using an instance-identifier:

  list c {
    key x;
    leaf x;

    leaf bref { type instance-identifier; }
  }

  What is the best way to restrict the instance-identifier so that it
  has to point to a 'b' element?

Are there other approaches?

I think this is a rather common modeling problem and perhaps we can
come up with a best practice pattern for this? If so, I am happy to
add it to my pattern collection I-D.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>