clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
208 stars 70 forks source link

Choice and Leafref #469

Closed temabeloglinski closed 7 months ago

temabeloglinski commented 9 months ago

Hi Olof I have a question about choice function and leafref. For example I have this yang structure:

        choice myChoice {
            description "Fruit or Flowers";
            case fruit {
               leaf fruit-name {
                 description "Fruit name";
                 type leafref {
                  path "../../fruits/name";
                 }
              }
            }
            case flower {
               leaf flower-name {
                 description "Flower name";
                 type leafref {
                  path "../../flowers/name";
                 }
              }
          }
        }

But if I call commit, clixon returns an error - Nov 30 22:01:44: Commit failed. Edit and try again or discard changes: application operation-failed No referred YANG node found for leafref path ../../flowers/name. In this case, the names of objects are called up when I click on the question mark, i.e. the paths are correct. What could be the problem?

olofhagsand commented 9 months ago

Can you please complete your example with YANG rules for "flowers/name" and "fruits/name"? There are so many combinations of choice/leafref etc that my guess is that it is not covered by regressions.

temabeloglinski commented 9 months ago

Yes of course. I simplified the configuration:

list fruits { key "name"; leaf name { type string; } }

list flowers { key "name"; leaf name { type string; } }

        choice myChoice {
            description "Fruit or Flowers";
            case fruit {
               leaf fruit-name {
                 description "Fruit name";
                 type leafref {
                  path "../fruits/name";
                 }
              }
            }
            case flower {
               leaf flower-name {
                 description "Flower name";
                 type leafref {
                  path "../flowers/name";
                 }
              }
          }
        }

root@cli/> show configuration cli set flowers 123 set flowers 2345

root@cli/> set flower-name ? 123 Flower name 2345 Flower name

Flower name root@cli/> set flower-name 123 root@cli/> show configuration cli set flowers 123 set flowers 2345 set flower-name 123 root@cli/> commit Nov 30 23:16:42: Commit failed. Edit and try again or discard changes: application operation-failed No referred YANG node found for leafref path ../flowers/name root@cli/>
olofhagsand commented 9 months ago

Thanks, will have a look

temabeloglinski commented 8 months ago

Hi Olof! Did you manage to reproduce this error?

khromenokroman commented 7 months ago

Hi, I have such a problem, is there a solution to it?

olofhagsand commented 7 months ago

Sorry, been busy, will try to look at it tomorrow

olofhagsand commented 7 months ago

Confirmed this issue

olofhagsand commented 7 months ago

Should be fixed now. I dont think the combination of choice and leafref has ever worked. Added regression test. @temabeloglinski @khromenokroman please verify and if it works, close the issue

temabeloglinski commented 7 months ago

Hi Olof! Thank's a lot! Everything is working.