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

Autocli does not offer completions for leafref to identityref #254

Closed
pheller opened this issue Aug 5, 2021 · 2 comments
Closed

Autocli does not offer completions for leafref to identityref #254

pheller opened this issue Aug 5, 2021 · 2 comments

Comments

@pheller
Copy link
Contributor

pheller commented Aug 5, 2021

Given the yang module openconfig-bgp, where a bgp neighbor may have multiple afi-safis configured, the afi-safi list is defined like so:

list afi-safi {
      key "afi-safi-name";

      description
        "AFI,SAFI configuration available for the
        neighbour or group";

      leaf afi-safi-name {
        type leafref {
          path "../config/afi-safi-name";
        }
        description
          "Reference to the AFI-SAFI name used as a key
          for the AFI-SAFI list";
      }

And, the leafref for afi-safi-name points to:

leaf afi-safi-name {
      type identityref {
        base oc-bgp-types:AFI_SAFI_TYPE;
      }
      description "AFI,SAFI";
    }

Ideally, the leafref would offer the same completions as offered by the identityref leaf, and furthermore would not allow non-conforming entries.

clixon> set bgp neighbors neighbor 1.2.3.4 afi-safis afi-safi ?
  <afi-safi-name>       Reference to the AFI-SAFI name used as a key
                        for the AFI-SAFI list
clixon> set bgp neighbors neighbor 1.2.3.4 afi-safis afi-safi foo config afi-safi-name ?
  <afi-safi-name>                    AFI,SAFI
  oc-bgp-types:IPV4_FLOWSPEC         AFI,SAFI
  oc-bgp-types:IPV4_LABELED_UNICAST  AFI,SAFI
  oc-bgp-types:IPV4_UNICAST          AFI,SAFI
  oc-bgp-types:IPV6_LABELED_UNICAST  AFI,SAFI
  oc-bgp-types:IPV6_UNICAST          AFI,SAFI
  oc-bgp-types:L2VPN_EVPN            AFI,SAFI
  oc-bgp-types:L2VPN_VPLS            AFI,SAFI
  oc-bgp-types:L3VPN_IPV4_MULTICAST  AFI,SAFI
  oc-bgp-types:L3VPN_IPV4_UNICAST    AFI,SAFI
  oc-bgp-types:L3VPN_IPV6_MULTICAST  AFI,SAFI
  oc-bgp-types:L3VPN_IPV6_UNICAST    AFI,SAFI
  oc-bgp-types:LINKSTATE             AFI,SAFI
  oc-bgp-types:LINKSTATE_SPF         AFI,SAFI
  oc-bgp-types:LINKSTATE_VPN         AFI,SAFI
  oc-bgp-types:SRTE_POLICY_IPV4      AFI,SAFI
  oc-bgp-types:SRTE_POLICY_IPV6      AFI,SAFI
  oc-bgp-types:VPNV4_FLOWSPEC        AFI,SAFI
clixon> set bgp neighbors neighbor 1.2.3.4 afi-safis afi-safi foo config afi-safi-name foo
clixon> show
...
             afi-safis {
                afi-safi {
                    afi-safi-name foo;
                    config {
                        afi-safi-name foo;
...
@olofhagsand olofhagsand added the bug label Aug 5, 2021
olofhagsand added a commit that referenced this issue Aug 16, 2021
  * Closer adherence to RFC 7950. Some of this is changed behavior, some is new feature.
  * Essentially instead of looking at the referring leaf, context is referred(target) node
  * Validation uses referred node
    * Validation changed to use type of referred node, instead of just "string"
  * Auto-cli
    * Changed to use type of referred node for typecheck
    * Completion uses referred node
  * Required instance / less strict validation
    * New: Leafrefs must refer to existing data leaf ONLY IF YANG `required-instance` is true
    * Previous: All leafrefs must refer to existing data leaf node
* Fixed: [Autocli does not offer completions for leafref to identityref #254](#254)
@olofhagsand
Copy link
Member

After reading RFC 7950 more thoroughly, several leafref issues needed to be modified, where the problem reported in this issue is a sub part. The larger issue was to move the typecheck/validation/completion from the "referring" node (the leafref) to the "referred node) (the identityref in this example.

@pheller
Copy link
Contributor Author

pheller commented Aug 17, 2021

Looks good, thanks!

@pheller pheller closed this as completed Aug 17, 2021
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

2 participants