Re: [netmod] evaluating 'when' statements with unconfigured leafs

Ladislav Lhotka <lhotka@nic.cz> Thu, 26 September 2019 07:02 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 B99131200F6 for <netmod@ietfa.amsl.com>; Thu, 26 Sep 2019 00:02:45 -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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] 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 k_OiPx0HVz7I for <netmod@ietfa.amsl.com>; Thu, 26 Sep 2019 00:02:44 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id 4710512004C for <netmod@ietf.org>; Thu, 26 Sep 2019 00:02:44 -0700 (PDT)
Received: by trail.lhotka.name (Postfix, from userid 109) id 30FDA1821292; Thu, 26 Sep 2019 09:04:17 +0200 (CEST)
Received: from localhost (nat-1.nic.cz [217.31.205.1]) by trail.lhotka.name (Postfix) with ESMTPSA id 1DB871821290; Thu, 26 Sep 2019 09:04:16 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com>, "netmod@ietf.org" <netmod@ietf.org>
In-Reply-To: <VI1PR07MB3981888B6E7B657DD0E97F219B870@VI1PR07MB3981.eurprd07.prod.outlook.com>
References: <VI1PR07MB3981888B6E7B657DD0E97F219B870@VI1PR07MB3981.eurprd07.prod.outlook.com>
Mail-Followup-To: "Sterne\, Jason \(Nokia - CA\/Ottawa\)" <jason.sterne@nokia.com>, "netmod\@ietf.org" <netmod@ietf.org>
Date: Thu, 26 Sep 2019 09:02:42 +0200
Message-ID: <87ef034k19.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/rSnSqcW7Sp87SCgacbRBNOU4wus>
Subject: Re: [netmod] evaluating 'when' statements with unconfigured leafs
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
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: Thu, 26 Sep 2019 07:02:46 -0000

"Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com> writes:

> Hi all,
>
> I saw some recent questions about 'when' statements. I had another one related to evaluating 'when' statements that involve leafs that don't currently have a value at all.
>
> leaf foo {
>     type enumeration {
>         enum val1;
>         enum val2;
>     }
> }
>
> leaf bar {
>     when "../foo != 'val2'";
>     type uint8;
> }
>
> Notice that foo does not have a default statement. So if no manager has set leaf foo, it doesn't exist in the config.
>
> In that case, does the "when" statement evaluate to 'true'  (i.e. leaf bar is allowed to have a value) ?
>
> i.e. assuming leaf foo is not set at all, is this accepted?
> <bar>23</bar>
>
> Or is there something special here because of the non-existence of leaf foo?
>
> If the "when" evaluates to 'false', then does the following "when" evaluate differently than the one above?
>     when "not(../foo = 'val2')";

Indeed it does. If the "foo" instance doesn't exist, then this expression evaluates to true.

Lada

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

-- 
Ladislav Lhotka 
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67