Re: [netmod] a question about 'when'

Ladislav Lhotka <lhotka@nic.cz> Mon, 05 August 2019 09:49 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 1F97812015D for <netmod@ietfa.amsl.com>; Mon, 5 Aug 2019 02:49:01 -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 S5JV9QlduM8B for <netmod@ietfa.amsl.com>; Mon, 5 Aug 2019 02:48:59 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id EDE5C1200B6 for <netmod@ietf.org>; Mon, 5 Aug 2019 02:48:58 -0700 (PDT)
Received: by trail.lhotka.name (Postfix, from userid 109) id 5F56D182048C; Mon, 5 Aug 2019 11:51:02 +0200 (CEST)
Received: from localhost (unknown [195.113.220.121]) by trail.lhotka.name (Postfix) with ESMTPSA id 2B597182004A; Mon, 5 Aug 2019 11:50:59 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: "Fengchong (frank)" <frank.fengchong@huawei.com>, "netmod@ietf.org" <netmod@ietf.org>
Cc: "Zhangxiaoping (C)" <zhang.xiaoping@huawei.com>, liuzhiying <liuzhiying@huawei.com>
In-Reply-To: <5756FB984666AD4BB8E1D63E2E3AA3D001EE95B1@DGGEMM533-MBS.china.huawei.com>
References: <5756FB984666AD4BB8E1D63E2E3AA3D001EE95B1@DGGEMM533-MBS.china.huawei.com>
Mail-Followup-To: "Fengchong \(frank\)" <frank.fengchong@huawei.com>, "netmod\@ietf.org" <netmod@ietf.org>, "Zhangxiaoping \(C\)" <zhang.xiaoping@huawei.com>, liuzhiying <liuzhiying@huawei.com>
Date: Mon, 05 Aug 2019 11:48:52 +0200
Message-ID: <87o914gcxn.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/JSK92MH1xMh61j7zwkIPppnrT-k>
Subject: Re: [netmod] a question about 'when'
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: Mon, 05 Aug 2019 09:49:01 -0000

"Fengchong (frank)" <frank.fengchong@huawei.com> writes:

> Hi all,
>
> I encounter a question about 'when', when I implement yang model associated when condition.
>
> Yang model:
>
> leaf password-type {
>    type enumeration {
>       enum null;
>       enum simple;
>       enum cipher;
>    }
> }
>
> leaf password-text {
> type string;
> when "../password-type != null";
> }
>
> I config these two leafs as below:
> <password-type>simple</password-type>
> <password-text>123456</password-text>
>
> And I changed password-type to null, I get the config like below:
> <password-type>null</password-type>
>
> And then, I reconfig the password-type to simple, what data should be returned?
>
> Is
>   <password-type>simple</password-type>

According to RFC 7950, sec. 8.2, the server deleted "password-text" after you changed "password-type" to null but the original value isn't recovered after you change the type back.

This server behaviour means that a typo or similar trivial error may have catastrophic consequences such as auto-deletion of entire configuration subtrees. That's why our RESTCONF implementation (jetconf) does something else: it won't permit you to change "password-type" to null as long as the "password-text" exists.

Lada

>
> Or
>
>   <password-type>simple</password-type>
>   <password-text>123456</password-type>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod

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