The mandatory statement in that case is ignored (I’ve pointed out the RNG and 
Schematron lack of enforcement).
WHEN trumps the mandatory status (via explicit mandatory or implicit mandatory 
via min-elements 1)

Thanks
Mike

From: Robert Wilton [mailto:[email protected]]
Sent: Friday, October 12, 2018 12:06 PM
To: Michael Rehder <[email protected]>
Cc: Andy Bierman <[email protected]>; Walker, Jason 
([email protected]) <[email protected]>; [email protected]
Subject: Re: [netmod] WHEN statement within mandatory objects doesn't ensure 
presence of the mandatory object


Hi Mike,

On 11/10/2018 19:05, Andy Bierman wrote:


On Thu, Oct 11, 2018 at 11:00 AM, Michael Rehder 
<[email protected]<mailto:[email protected]>> wrote:
I think the wording is relevant - something can be conditional but still 
required.
Yes, but I think that this is already expressed by a node that has both a when 
condition and mandatory statement.



container a {

  container x {

    when "some condition";

    leaf foo {

      mandatory true;

    }

    leaf bar {

      ...

    }

  }

  container y {

    leaf baz {

      mandatory true;

    }

    leaf tee {

      ...

    }

  }

}



a/x/foo is conditional (due to when) but required (if the when condition is 
met).

a/x/bar is conditional (due to when) but optional (if the when condition is 
met).

a/y/baz is unconditional but required.

a/y/tee is unconditional but optional.




It should be clarified that elements become implicitly “mandatory false” when a 
“when” statement is used.
But they don't.



I would like to see an enhancement to YANG to control this behavior, to allow 
the mandatory status to be enforced.
That is, support also “conditionally required” instead of only the current 
“conditionally optional”.
I'm trying to understand what this would even mean.

Taking your original example, but with "enforce-mandatory-status":

         leaf AssignmentMechanism {

            type enumeration {

              enum "DHCP";

              enum "Static";

            }

            mandatory true;

            description "The address assignment mechanism.";

          }

          list IPAddresses {

            when "../AssignmentMechanism = 'Static'" {

              enforce-mandatory-status;

            }  key Address;

            min-elements 1;



            leaf Address {

              type capit:IPv4Address;

              description "An ipv4 address.";

            }

           }

So this means that list IPaddresses must have at least one element regardless 
of whether the when condition holds.  I.e. no matter whether the assignment is 
DHCP or Static there must always be at least one 1 address configured.  But I 
don't understand what this actually means - it seems like a contradiction.  
What am I missing?  Please can you give a concrete example (in YANG) of what 
behaviour you are looking for.

Thanks,
Rob
“Amdocs’ email platform is based on a third-party, worldwide, cloud-based 
system. Any emails sent to Amdocs will be processed and stored using such 
system and are accessible by third party providers of such system on a limited 
basis. Your sending of emails to Amdocs evidences your consent to the use of 
such system and such processing, storing and access”.
_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to