Subject: [netmod] Augment with a when and an action

From: Michal Vaško <[email-masked]>
Date: Wed, 23 Sep 2020 10:11:39 +0200

Hi,
I would like to ask for some clarification on what exactly the following (valid, I think) YANG snippet means:

container cont {
  container cont2 {
    leaf l2 {
      type string;
    }
  }
  leaf l1 {
    type uint32;
  }
}

augment /cont/cont2 {
  when "/cont/l1 == '5'";
  action act;
}

What exactly is the effect of the when statement? Is there any, since action cannot have a when directly? Or it actually makes the action conditional and if the when evaluates to false, the action should be treated as not defined?

Regards,
Michal

---

From: Michal Vaško <[email-masked]>
Date: Fri, 25 Sep 2020 12:18:43 +0200

Hi,
since no one replied am I to understand this is an unforeseen use-case? In that case there could at least be an agreement on what the behavior should be because I want to know what to implement in our tools.

Maybe at least warn about an unsupported use-case and ignore the "when" with respect to the action (there still could be other nodes in the augment for which the condition can be valid)? Or be more strict and forbid this use-case with an error? Or this is really just a corner case when there is only a node(s) in the augment with "when", for which the condition is not taken into consideration and it should be ignored with no additional messages?

Also, there is a similar use-case with a notification instead of an action and the behavior should be the same.

Regards,
Michal

On Wednesday, September 23, 2020 10:11 CEST, Michal Vaško <[email-masked]> wrote: 
 
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

---

From: tom petch <[email-masked]>
Date: Fri, 25 Sep 2020 10:57:07 +0000

From: netmod <[email-masked]> on behalf of Michal Vaško <[email-masked]>
Sent: 25 September 2020 11:18

Hi,

<tp>
As it stands I think that the YANG is invalid but taking the general question, I see no problem.
'when' makes its parent conditional, what comes after is irrelevant, so if the 'when' is true, the augment happens, if the 'when' is false, the augment does not happen.

There are constraints on the placement of an action and these determine its validity.  Whether it got there with the help of a augment or not I do not think makes any difference.

Tom Petch

Regards,
Michal

---

From: Michal Vaško <[email-masked]>
Date: Fri, 25 Sep 2020 13:18:33 +0200

> There are constraints on the placement of an action and these determine its validity.  Whether it got there with the help of a augment or not I do not think makes any difference.

I beg to differ on this point. The difference is that "action" cannot have "when" as a substatement. However, in my use-case (is defined in "augment" with "when"), the behavior would be similar to "action" having a "when" condition directly (you have to evaluate it to decide whether the "action" can be executed or not). Now, I believe there is some reason why "when" is forbidden for an "action" although I do not know what it is.

Regards,
Michal

---

From: tom petch <[email-masked]>
Date: Fri, 25 Sep 2020 11:49:47 +0000

From: Michal Vaško <[email-masked]>
Sent: 25 September 2020 12:18

<tp>
Well, I differ:-)  
augment when
action
I see as quite different to
augment
action when
that is that the 'when' only affects the preceding statement as RFC7950 s.7.21.5 says.  What comes after is of no concern to the 'when'  Note too the comments about 'augment when' in s.7.21.5..
More generally, 'when' is troublesome and the e-mail archives are full of issues thereto with one comment asking why 'when' is 10X harder to implement than anything else in YANG:-)

Tom Petch

Regards,
Michal

---

From: Kent Watsen <[email-masked]>
Date: Fri, 25 Sep 2020 17:19:06 +0000

Hi Michal,

> Now, I believe there is some reason why "when" is forbidden for an "action" although I do not know what it is.

Note that Martin supports, and a room full of YANG-next-ers agreed to put it in the "Definitely Dos (MUST Solve)" category.

	https://github.com/netmod-wg/yang-next/issues/16 <https://github.com/netmod-wg/yang-next/issues/16>

K.

---

From: Michal Vaško <[email-masked]>
Date: Tue, 29 Sep 2020 08:33:00 +0200

Hi Kent,
okay, thanks. Then it seems it should be normally supported and made conditional. Just to make certain, the same goes for notification, right?

Regards,
Michal

---

From: tom petch <[email-masked]>
Date: Tue, 29 Sep 2020 11:13:29 +0000

From: Kent Watsen <[email-masked]>
Sent: 25 September 2020 18:19

Hi Michal,

<tp>

Kent,

An action is an action node, not a data node or a schema node, and the context node and accessible tree for XPath evaluation are not defined for an action node.  An action node is a bit weird, somewhere in the middle of operational state but also a top level node when it comes to invoking it with XML.  The question of its placement did get asked during the development of YANG 1.1 but no one responded.

Andy has always been clear about the problems of processing 'when' so he may have a more definite view on this.  It might be to do with what a server has to do when I receives and processes an action.

Tom Petch

https://github.com/netmod-wg/yang-next/issues/16

K.

---

From: Kent Watsen <[email-masked]>
Date: Tue, 29 Sep 2020 13:49:50 +0000

Hi Machal,

> okay, thanks. Then it seems it should be normally supported

Yes, and note the “workaround” mentioned in the GItHub issue is essentially the solution in your OP.   

> and made conditional.

Supporting “when” under “action” would be getting ahead of the curve, so a conditional is reasonable.

> Just to make certain, the same goes for notification, right?

I would think so. Please scan the GitHub issue list and, if you don’t see it mentioned already, create a new issue for it.

Thanks,
K.

---

From: Michal Vaško <[email-masked]>
Date: Tue, 29 Sep 2020 16:21:15 +0200

Hi Kent,

> Yes, and note the “workaround” mentioned in the GItHub issue is essentially the solution in your OP.   

Well, not exactly. It is a solution for model authors who want to make their action conditional. I am trying to learn how to behave in case a module with "augment" with both "when" and "action" is being loaded, the opposite position of a YANG module reader.

> I would think so. Please scan the GitHub issue list and, if you don’t see it mentioned already, create a new issue for it.
 
Will do.

Regards,
Michal