Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yang uses's substatement when has no effect #218

Open
nowaits opened this issue May 8, 2021 · 5 comments
Open

yang uses's substatement when has no effect #218

nowaits opened this issue May 8, 2021 · 5 comments

Comments

@nowaits
Copy link
Contributor

nowaits commented May 8, 2021

In openconfig-if-ethernet.yang using augment add ethernet to interface, but now the when has not effect.
And ethernet can be add to interface which type is not ianaift:ethernetCsmacd

<interfaces xmlns="http://openconfig.net/yang/interfaces">      
       <interface>
       <name>local0</name>
       <config>
          <name>local0</name>
          <type>ianaift:softwareLoopback</type>
          <enabled>false</enabled>
          <unigw:l2-mode xmlns:unigw="http://www.xdja.com/unigw" xmlns="http://www.xdja.com/unigw">true</unigw:l2-mode>
       </config>
       <oc-eth:ethernet xmlns:oc-eth="http://openconfig.net/yang/interfaces/ethernet">
          <oc-eth:config>
             <oc-eth:mac-address>00:0c:29:f4:9c:a3</oc-eth:mac-address>
          </oc-eth:config>
       </oc-eth:ethernet>
    </interface>
 </interfaces>
@nowaits nowaits changed the title yang uses's substatement when no effect yang uses's substatement when has no effect May 8, 2021
@olofhagsand olofhagsand added the bug label May 8, 2021
olofhagsand added a commit that referenced this issue May 13, 2021
  * Several cases were not implemented fully according to RFC 7950
    * Do not extend default values if when statements evaluate to false
    * Do not allow edit-config of nodes if when statements evaluate to false (Sec 8.3.2)
    * If a key leaf is defined in a grouping that is used in a list, the "uses" statement MUST NOT have a "when" statement. (See 7.21.5)
  * See [yang uses's substatement when has no effect #218](#2
@olofhagsand
Copy link
Member

This led to quite a large rewrite and addition of code for features that should have been there that was not, not in the CLI primarily but in the core clixon system.
This includes:

  • Do not extend default values if when statements evaluate to false
  • Do not allow edit-config of nodes if when statements evaluate to false (Sec 8.3.2)
  • If a key leaf is defined in a grouping that is used in a list, the "uses" statement MUST NOT have a "when" statement. (See 7.21.5)
    Please verify

@nowaits
Copy link
Contributor Author

nowaits commented May 14, 2021

Now when has effect. But there is another question about when with cli.
When input set interfaces interface local0 <tab>, i got ethernet and when input set interfaces interface local0 ethernet switched-vlan config access-vlan 1, got cli error.

root@localhost (config) > set interfaces interface local0 <tab>
 aggregation          config               ethernet             ipv4                 ipv6                
 routed-vlan          subinterfaces
root@localhost (config) > set interfaces interface local0 ethernet switched-vlan config access-vlan 1
May 14 10:07:00: Editing configuration: application unknown-element Node 'ethernet' tagged with 'when' condition 'oc-if:config/oc-if:type = 'ianaift:ethernetCsmacd'' in module 'openconfig-if-ethernet' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2) <bad-element>ethernet</bad-element>
CLI command error

Cli shouldn't have ethernet suggestion, when input set interfaces interface local0 <tab>.

@olofhagsand
Copy link
Member

There is a problem here.
The when statement is one of few YANG constructs that act on "instances" which means they are dependent on the dynamic context of the datastore. This is not known at init time when the clispec @datamodel is generated from YANG. This means that the when statement should be evaluated in runtime, such as when the user types ?/TAB. But at that time the YANG is not available in the sense that the cligen algorithms only work on the generated clispec.
To solve this, either:

  1. @datamodel is re-generated when the user types ?/TAB. This is probably easiest but will likely cause latencies.
  2. @datamodel is annotated with whenstatements that are evaluated when the user types ?/TAB . There are some complexities here regarding how the when statements should be evaluated.

@andrei-mircescu
Copy link

was/ " vm ..

@andrei-mircescu
Copy link

ze. ),;: lioxmv. owuoX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants