Re: [YANG] deep keys and unique statements

Ladislav Lhotka <lhotka@cesnet.cz> Mon, 21 January 2008 10:20 UTC

Return-path: <yang-bounces@ietf.org>
Received: from [127.0.0.1] (helo=stiedprmman1.va.neustar.com) by megatron.ietf.org with esmtp (Exim 4.43) id 1JGtlc-0000U1-5A; Mon, 21 Jan 2008 05:20:36 -0500
Received: from yang by megatron.ietf.org with local (Exim 4.43) id 1JGtla-0000Th-HP for yang-confirm+ok@megatron.ietf.org; Mon, 21 Jan 2008 05:20:34 -0500
Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1JGtla-0000TV-3h for yang@ietf.org; Mon, 21 Jan 2008 05:20:34 -0500
Received: from office2.cesnet.cz ([195.113.144.244]) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1JGtlW-0000gW-PC for yang@ietf.org; Mon, 21 Jan 2008 05:20:34 -0500
Received: from [172.29.2.201] (asus-gx.lhotka.cesnet.cz [195.113.161.161]) by office2.cesnet.cz (Postfix) with ESMTP id AB279D80098 for <yang@ietf.org>; Mon, 21 Jan 2008 11:20:27 +0100 (CET)
Subject: Re: [YANG] deep keys and unique statements
From: Ladislav Lhotka <lhotka@cesnet.cz>
To: yang@ietf.org
In-Reply-To: <20080121.101727.102844599.mbj@tail-f.com>
References: <4790D279.3070804@andybierman.com> <1200906348.6914.97.camel@missotis> <20080121.101727.102844599.mbj@tail-f.com>
Content-Type: text/plain; charset=utf-8
Organization: CESNET
Date: Mon, 21 Jan 2008 11:20:27 +0100
Message-Id: <1200910827.6914.145.camel@missotis>
Mime-Version: 1.0
X-Mailer: Evolution 2.12.1
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Scan-Signature: c83ccb5cc10e751496398f1233ca9c3a
X-BeenThere: yang@ietf.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: YANG modeling Language for NETCONF <yang.ietf.org>
List-Unsubscribe: <https://www1.ietf.org/mailman/listinfo/yang>, <mailto:yang-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www1.ietf.org/pipermail/yang>
List-Post: <mailto:yang@ietf.org>
List-Help: <mailto:yang-request@ietf.org?subject=help>
List-Subscribe: <https://www1.ietf.org/mailman/listinfo/yang>, <mailto:yang-request@ietf.org?subject=subscribe>
Errors-To: yang-bounces@ietf.org

Martin Bjorklund píše v Po 21. 01. 2008 v 10:17 +0100:
> Ladislav Lhotka <lhotka@cesnet.cz> wrote:
> > Andy Bierman píše v Pá 18. 01. 2008 v 08:23 -0800:
> > > On the other hand, the unique-stmt allows arbitrary combinations
> > > of leaf instances anywhere within the list.  The complexity
> > > built into the unique-stmt is extensive, as even a 2-d table shows:
> > 
> > I am thinking about an alternative "upside-down" implementation of both
> > key and unique properties, namely to declare these properties with the
> > leaf. The semantics would be that these properties always pertain to the
> > nearest ancestor list (if any, otherwise it is noop). Example:
> > 
> > list aaa {
> >   container bbb {
> >     leaf c {
> >       type c-type;
> >       unique;
> >     }
> >   }
> > }
> 
> This doesn't work if it is the combination of two leafs that is
> unique.  In this example, the name has to be unique, and also the
> ip/port combination:

In RELAX NG we enclose the two elements in a group pattern and attach
the property to that group. Perhaps grouping statement could be used for
this purpose in YANG?

> 
>   list server {
>     key "idx";
>     unique "ip port";
>     unique "name";
> 
>     leaf idx { ... }
>     leaf ip { ... }
>     leaf port { ... }
>     leaf name { ... }
>   }
> 
> [Side note: In our current DML we took the approach you describe, but
> in order to handle the combinations, the unique statement took an
> argument which was a tag.  All leafs with the same tag would be
> checked in combination.  I think the YANG statement is more clear.]
> 
> > There are two advantages:
> > 1. The scope of the property - nearest ancestor list - is always unique,
> > so no XPath expressions are needed here.
> > 2. At the time when the declaration is read the entire ancestor chain is
> > known, i.e., no buffering is needed.
> 
> I don't understand these advantages.  Are you talking about buffering
> in the compiler?

I mean this: If the validator is checking a configuration value and
finds in the schema that it is declared as unique, it can immediately
tell whether the value is unique within the configuration read so far.
In a YANG-like implementation with deep keys, it would have to buffer
all unique declarations as long as it is inside the list and determine
first for each leaf instance in the configuration whether it was
previously declared as unique. I assume the validator walks down the
hierarchies of configuration data and the schema in parallel, it may not
be an issue if you compile the schema into another representation.
 
> 
> 
> > 
> > If I remember correctly, the main objection against this implementation
> > is that it would be difficult to declare keys a posteriori for standard
> > groupings, but I think it could be handled by extending the augment
> > statement, e.g, like this:
> >
> > module inet-extra {
> >   ...
> >   grouping endpoint {
> >     leaf address {
> >       type inet:address;
> >     }
> >     leaf port {
> >       type uint16;
> >     }
> >   }
> >   ...
> 
> I think it would be the uses refinement that would be used (not augment):
> 
>   list foo {
>     uses iex:endpoint {
>       leaf address {
>         key true;
>       }
>     }
>   }
> 
Yes, this looks nice.

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C



_______________________________________________
YANG mailing list
YANG@ietf.org
https://www1.ietf.org/mailman/listinfo/yang