cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
153
Views
1
Helpful
6
Replies

pyang when on oper data (config false)

New pyang version produces a warning if when statements are checking operational data (config false)
... "is config false and is not part of the accessible tree"
https://github.com/mbj4668/pyang/issues/918

I have a setup with:
config false and 
tailf:cdb-oper {
        tailf:persistent true;
      }


It seems to work fine in NSO 6.3.8.1
is this something that will continue to work in NSO and we can ignore this warning or is it something that will stop working in the future?

 

1 Accepted Solution

Accepted Solutions

cohult
Cisco Employee
Cisco Employee

While you will continue to be able to do this, it is recommended against as it is not allowed per this section of RFC 7950 - The YANG 1.1 Data Modeling Language :

   The accessible tree depends on where the statement with the XPath
   expression is defined:

   o  If the XPath expression is defined in a substatement to a data
      node that represents configuration, the accessible tree is the
      data in the datastore where the context node exists.  The root
      node has all top-level configuration data nodes in all modules as
      children.

 And https://datatracker.ietf.org/doc/html/rfc7950#section-8.1

   o  If the constraint is defined on configuration data, it MUST be
      true in a valid configuration data tree.

You can continue to ignore the warnings, but it may not be a good idea - if a when expression (or must expression or leafref path) for config references state data, it means that the validity of the configuration depends on state, and thus that a validated and committed configuration can become invalid if some state data is changed (this is of course the reason for the requirements in the RFCs).

View solution in original post

6 Replies 6

cohult
Cisco Employee
Cisco Employee

While you will continue to be able to do this, it is recommended against as it is not allowed per this section of RFC 7950 - The YANG 1.1 Data Modeling Language :

   The accessible tree depends on where the statement with the XPath
   expression is defined:

   o  If the XPath expression is defined in a substatement to a data
      node that represents configuration, the accessible tree is the
      data in the datastore where the context node exists.  The root
      node has all top-level configuration data nodes in all modules as
      children.

 And https://datatracker.ietf.org/doc/html/rfc7950#section-8.1

   o  If the constraint is defined on configuration data, it MUST be
      true in a valid configuration data tree.

You can continue to ignore the warnings, but it may not be a good idea - if a when expression (or must expression or leafref path) for config references state data, it means that the validity of the configuration depends on state, and thus that a validated and committed configuration can become invalid if some state data is changed (this is of course the reason for the requirements in the RFCs).

Ok, good to know the reasoning behind it and as such we shouldn't have a generic ignore of such warnings.

In this case it would probably be fine since I'm using the when expression to show/hide a grouping of actions that are only relevant during some operational conditions.

If all that is there are actions then maybe this does not need to be config data. Maybe if you have a when on the enclosing container, all you need is to add 'config false' on that container.

All that is controlled by the when statement is actions.
Enclosing it inside a container wouldn't change much since we want to control it related to a specific value/state in a oper leaf.
It would give us the option to create/delete that container as we change the state of the oper leaf, but I think currently we prefer the actions to be on top level rather then inside a container

Ah OK, you had mentioned that a 'when' statement (singular) was controlling the existence of actions (plural), so I was trying to understand how that was done, and was guessing that the 'when' statement was on an enclosing container. If there are when statements written directly under each action, then should the action be considered as part of the configuration? Is it really an error to refer to non-config nodes in that case, if the 'when' is directly on the action?

Actions do not allow when statements inside them, so the way I did it is to create a grouping with only the actions defined inside it.
Then in the uses statement where I bring the grouping in I can place the when expression there.

Hence compiler probably has a hard time to determine if when expression can be safe or not