Re: [netmod] 'when' statement in edit-config payload parsing

Vladimir Vassilev <vladimir@transpacket.com> Wed, 14 September 2016 12:29 UTC

Return-Path: <vladimir@transpacket.com>
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 ADF0812B6C1 for <netmod@ietfa.amsl.com>; Wed, 14 Sep 2016 05:29:16 -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, HTML_MESSAGE=0.001, SPF_PASS=-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 UEFnmw9pTSf3 for <netmod@ietfa.amsl.com>; Wed, 14 Sep 2016 05:29:14 -0700 (PDT)
Received: from mail.transpacket.com (s91205186171.blix.com [91.205.186.171]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 58BAC12B6C2 for <netmod@ietf.org>; Wed, 14 Sep 2016 05:29:09 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id 228601440D7C; Wed, 14 Sep 2016 14:29:07 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iette1rfeJKN; Wed, 14 Sep 2016 14:29:07 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id EBFCC1440D74; Wed, 14 Sep 2016 14:29:06 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id b0n8KWE7sFfC; Wed, 14 Sep 2016 14:29:06 +0200 (CEST)
Received: from [192.168.209.141] (s1853520235.blix.com [185.35.202.35]) by mail.transpacket.com (Postfix) with ESMTPSA id C459C1440D61; Wed, 14 Sep 2016 14:29:06 +0200 (CEST)
Message-ID: <57D94292.9000104@transpacket.com>
Date: Wed, 14 Sep 2016 14:29:06 +0200
From: Vladimir Vassilev <vladimir@transpacket.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0
MIME-Version: 1.0
To: Andy Bierman <andy@yumaworks.com>, netmod@ietf.org
References: <0FF2F5A0-7E58-41AA-A0FA-463ABE94BE4F@nic.cz> <CABCOCHRGvzMtAYv9M-gL7_f8HbZhWWppPSYrvnoY_F_R8y5HSA@mail.gmail.com> <57D6E1EC.6070606@seguesoft.com> <CABCOCHTOgNdZDVBGPfRWNc8EXOq82OyCaggSGdfL=xQL5uDbPw@mail.gmail.com> <1cd5b1e3-4440-2635-c809-c709dcc6efd3@nokia.com> <D56F657D-1569-4E1C-937C-5FF4DEF53BF0@nic.cz> <20160913082526.GB44726@elstar.local> <57D7D7FF.9040603@transpacket.com> <20160913105710.GA44963@elstar.local> <57D7E0A6.6020806@transpacket.com> <20160913112648.GA45073@elstar.local> <57D7E651.9000706@transpacket.com> <CABCOCHShNEirNOH3xcMWuOz4bzMn=Rpx+B2AfHSJZf1+p+A5gA@mail.gmail.com>
In-Reply-To: <CABCOCHShNEirNOH3xcMWuOz4bzMn=Rpx+B2AfHSJZf1+p+A5gA@mail.gmail.com>
Content-Type: multipart/alternative; boundary="------------060308060300040009010803"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/i9rmVcCpwp9cCuf75fs0_2QcViU>
Subject: Re: [netmod] 'when' statement in edit-config payload parsing
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: Wed, 14 Sep 2016 12:29:17 -0000

On 09/13/2016 06:48 PM, Andy Bierman wrote:
> Hi,
>
> I am not in favor of changing when-stmt so it works like must-stmt.
> I prefer it work as designed.  It is like choice-stmt, where a new case
> will cause objects from the previously selected case to be 
> automatically deleted.
>
> There is no text in RFC 7950 that actually says an error is returned
> if a when-stmt is false because an anyxml or anydata input parameter
> was converted to top-level YANG nodes and reprocessed.
>
> The text only covers direct when-stmts like below:
>
>    rpc plot-point {
>       input {
>         leaf point-type {
>           type enumeration {
>               enum 2d;
>               enum 3d;
>           }
>           mandatory true;
>         }
>         leaf X { type int32; mandatory true; }
>         leaf Y { type int32; mandatory true; }
>         leaf Z {
>            when "../point-type = '3d';
>            mandatory true;
>            type int32;
>        }
>      }
>    }
>
>
> If the client sets point-type to '2d' and provides a Z leaf, then an 
> error is returned.
> This is the only type of usage the text in question actually covers.
It is <edit-config> RPC that has started the thread (the 'when' 
validation in <plot-point> is much clearer and I agree with all you say 
above). There was the original example by Yves (changed when "A" to when 
"../A"):

   container root {
     leaf A {
       type empty:
     }
     leaf B {
       when "../A";
       type uint32;
     }
   }
... and the netconf <edit-config>:

      <rpc message-id="101"
           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
        <edit-config>
          <target>
            <running/>
          </target>
          <config>
            <root xmlns="http://dummy.com">
              <A/>
              <B>
                3
              </B>
            </dummy>
          </config>
        </edit-config>
      </rpc>

There is consensus the 'when' statement is satisfied in this case which 
answers his original question.

However if we make change to the original example by assuming the target 
is not 'running' but 'candidate' and /root/A is already present before 
the following <edit-config> is processed:

      <rpc message-id="101"
           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
        <edit-config>
          <target>
            <candidate/>
          </target>
          <config>
            <root xmlns="http://dummy.com">
              <B>
                3
              </B>
            </dummy>
          </config>
        </edit-config>
      </rpc>

My interpretation of the relevant text in YANG 1.0 and YANG 1.1 is the 
'when' statement is satisfied since when the <edit-config> is applied to 
the 'candidate' configuration the result will be valid 'candidate' 
configuration state and this is what matters. If there is consensus on 
that I have nothing to add.

Vladimir

>
>
>
> Andy
>
>
> On Tue, Sep 13, 2016 at 4:43 AM, Vladimir Vassilev 
> <vladimir@transpacket.com <mailto:vladimir@transpacket.com>> wrote:
>
>     On 09/13/2016 01:26 PM, Juergen Schoenwaelder wrote:
>
>         On Tue, Sep 13, 2016 at 01:19:02PM +0200, Vladimir Vassilev wrote:
>
>                 I am wondering in which cases this is useful. Consider
>                 a candidate
>                 datastore - why would a 'when' expression have to true
>                 after each
>                 edit? Why do we force clients to send edits in such a
>                 way that 'when'
>                 expressions are true after each edit?
>
>             For example command line <TAB> completion in
>             /interfaces/interface can
>             evaluate all 'when' statements in child data nodes and
>             augmentations and
>             come up with relevant list of container and leaf child
>             completions based on
>             the already created /interfaces/interface/type (same
>             applies for the options
>             a user is presented with in a GUI after specifying the
>             'name' and 'type' of
>             the interface). It is the same with 'if-feature'
>             evaluations. The 'must'
>             statements however can be more complicated since they are
>             only checked when
>             the interactive incremental edit process is complete and
>             <commit> is
>             attempted.
>
>         I do not see what <TAB> completion has to do with the
>         processing of
>         edit-config on the server. Are people implementing <TAB>
>         completion by
>         sending edit-configs to a server? But yes, trying to enforce
>         constraints while doing <TAB> completion may lead to surprises for
>         people not understanding the constraints being enforced via
>         incremental <TAB> completion.
>
>     Well it means that the 'candidate' configuration can not be in a
>     state where any of the 'when' statements fail (since it is
>     modified only with <edit-config>). This is significant reduction
>     of the entropy and thus can be utilized for automation. In my
>     example that fact is used for <TAB> completion.
>
>     Vladimir
>
>     _______________________________________________
>     netmod mailing list
>     netmod@ietf.org <mailto:netmod@ietf.org>
>     https://www.ietf.org/mailman/listinfo/netmod
>     <https://www.ietf.org/mailman/listinfo/netmod>
>
>