ConfD User Community

Annotate special case of choice


#1

Hi,

I’m trying to annotate this “special” construct:

                container s-vlan {                    
                    choice mode {
                        leaf c-vlan {
                            type vlan-list;
                        }
                        case default-case {
                            leaf default {
                                type empty;
                            }
                        }
                    }
                }

`

    tailf:annotate "/avif:s-vlan/avif:mode/avif:c-vlan" {
        tailf:info "Set the C-VLANs to map to the S-VLAN";
    }

I get
error: The statement tailf-common:info cannot be annotated into a case.

I do not know why the source yang is using such logic for c-vlan leaf. Is it possible to annotate this thing? What is the outcome of such choice definition?

BRj


#2

I made it work by using annotate-statement and a “position predicate”.
Is there a way with “tailf:annotate” ?


#3

This is the “shorthand” usage for case that is described in https://tools.ietf.org/html/rfc7950#section-7.9.2 - if there is only a single node in the case, you don’t have to actually write the case statement. Effectively, the compiler or other tool synthesizes a case statement with the same name as the node. I.e. in this snippet, the leaf c-vlan is actually inside an “invisible” case c-vlan.

This is handy since “single node in a case” is quite common - the strange thing with the snippet is that it isn’t used consistently - they could have omitted the case default-case too (which would have resulted in the “shorthand” case being called default, maybe they didn’t “like” that…).

Yes, but you need to spell out the “invisible” case in the path: /avif:s-vlan/avif:mode/avif:c-vlan/avif:c-vlan.

See above.


#4

Using annotate-statement is fine, but there is no need for a “position predicate” as far as I can see - i.e. annotate-statement leaf[name='c-vlan'] should work. And this way you are saying that you want to annotate the leaf and not the “invisible” case.


#5

It was under the augmentation statement. I ommited it for readability.