Re: [netmod] How to constrain a leaf to a read-only list of supported values?

Ladislav Lhotka <lhotka@nic.cz> Fri, 09 September 2016 13:33 UTC

Return-Path: <lhotka@nic.cz>
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 BFA5912B0B0 for <netmod@ietfa.amsl.com>; Fri, 9 Sep 2016 06:33:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] 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 Pic_0wJ8in4x for <netmod@ietfa.amsl.com>; Fri, 9 Sep 2016 06:33:55 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id A0A1C12B19C for <netmod@ietf.org>; Fri, 9 Sep 2016 06:33:55 -0700 (PDT)
Received: from localhost (unknown [195.113.220.110]) by trail.lhotka.name (Postfix) with ESMTPSA id B0C1D1CC02AB; Fri, 9 Sep 2016 15:34:05 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: "Dale R. Worley" <worley@ariadne.com>, Balazs Lengyel <balazs.lengyel@ericsson.com>
In-Reply-To: <8737lm2vv2.fsf@hobgoblin.ariadne.com>
References: <8737lm2vv2.fsf@hobgoblin.ariadne.com>
User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.4.51.2 (x86_64-apple-darwin14.0.0)
Date: Fri, 09 Sep 2016 15:33:58 +0200
Message-ID: <m2bmzx9ozd.fsf@birdie.labs.nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/hNaJQ6MzT9UTlSaizh4B23dhJ44>
Cc: netmod@ietf.org
Subject: Re: [netmod] How to constrain a leaf to a read-only list of supported values?
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.17
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: Fri, 09 Sep 2016 13:33:58 -0000

"Dale R. Worley" <worley@ariadne.com> writes:

> Balazs Lengyel <balazs.lengyel@ericsson.com> writes:
>> Problem: how do you restrict values for (3) - file-compression so that 
>> it is one of the nodes-supported-compression-types. The natural solution 
>> would be to use a must expression or a leaf-ref, but as 
>> nodes-supported-compression-types is config-false data, it is not 
>> allowed to constrain the config=true leaf, file-compression, with it.
>
> I'm no expert at this, but it seems to me that the way to do it is to
> have the overall data structure be config-true but make the contained
> supported-compression-types be config-false.  You can nest config-false
> nodes in a config-true structure.  The Yang would be something like
> this:
>
> typedef Compression-Method {
>   ...
> }
>
> list node {
>   config true;
>   key name;
>
>   string name;
>
>   leaf-list supported-compression-methods {
>     type Compression-Method;
>     config false;
>   }
>
>   Compression-Method compression-method;
>   must "compression-method ... supported-compression-methods";
> }

I think this is a good idea. It would have to be done on ad hoc basis
but, on the other hand, not all enumerations permit implementations to
choose a subset of enums.

The only technical problem with your mock-up is that "must" expressions
on config nodes cannot refer to state data.

Lada

>
> Dale
>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C