Subject: Re: [netmod] yang-04: when-stmt and rpc/input

From: Andy Bierman <[email-masked]>
Date: Sat, 23 May 2009 18:36:55 -0700

Martin Bjorklund wrote:
.....
> Any discriminated union, such as:
> 
>   input {
>       leaf ip-version {
>           type inet:ip-version;
>       }
>       container ipv4-params {
>           when "../ip-version = 'ipv4'";
>           ...
>       }
>       container ipv6-params {
>           when "../ip-version = 'ipv6'";
>           ...
>       }
>       ...
>   }
> 
> Or any case where "when" is used in a grouping which is used in "rpc".
> 

Going back to Martin's original example for false-when deletion:

What if the example above was config data instead of /rpc/input data?

    container ip-params {
        leaf ip-version {
            type inet:ip-version;
        }
        container ipv4-params {
            when "../ip-version = 'ipv4'";
            ...
        }
        container ipv6-params {
            when "../ip-version = 'ipv6'";
            ...
        }
        ...
    }

Here is the existing config:

  <ip-params>
     <ip-version>ipv4</ip-version>
     <ipv4-params> ... </ipv4-params>
  </ip-params>

An <edit-config> operation is received:

   <edit-config>
      ...
      <config>
         <ip-params>
            <!-- ok to put these elements out of order -->
            <!-- the agent can process in any order anyway -->
            <ipv6-params> ... </ipv6-params>
            <ip-version>ipv6</ip-version>
         </ip-params>
      </config>
   </edit-config>

Is it clear why the agent should not reject the
request with an 'unknown-element' error (because
ipv6-params does not exist when the PDU is received)?

IMO, the correct behavior is to let false-when-nodes
be created and then immediately delete them if the
when expression does not change to true by the
time all of the <edit-config> contents are applied.

This will not produce an error like a false 'if-feature',
but there is no standard way to enable/disable features,
let alone to do it on-the-fly inside an <edit-config>.

> /martin

Andy