Subject: [netmod] question on leafref path.

From: Christian Hopps <[email-masked]>
Date: Sat, 28 Feb 2015 17:09:39 -0500

Hi,

I need to use a “path” in a leafref to refer to a router id inside 1 of 2 possible containers. The 2 choices are “left” or “right” sides of a lambda. The lambda is identified by the channel.

I’ve tried the following with “|” (I believe this is the valid xpath) and “*” (a guess) and neither works. 

              //path "../../../lambda[channel=current()/../channel]/left/router-id | ../../../lambda[channel=current()/../channel]/right/router-id”;

              path "../../../lambda[channel=current()/../channel]/*/router-id”;

If I pick “left” or “right” only it works, but that’s not what I need. Any help on how to do this properly?

Thanks,
Chris.

The actual yang is below:

    list link {
      key "link-name";
      leaf link-name {
        type inet:uri;
      }
      list lambda {
        key "channel";
        leaf channel {
          type uint8;
        }
        container left {
          leaf router-id {
            type leafref {
              path "../../../../router/router-id";
            }
          }
        }
        container right {
          leaf router-id {
            type leafref {
              path "../../../../router/router-id";
            }
          }
        }
      }
      list site {
        key "site-id";
        leaf site-id {
          type inet:uri;
        }
        list connection {
          key "channel";
          leaf channel {
            type leafref {
              path "../../../lambda/channel";
            }
          }
          // Is there a way to xpath refer to left or right containers of the lambda?
          leaf router-id {
            type leafref {
              //path "../../../lambda[channel=current()/../channel]/left/router-id | ../../../lambda[channel=current()/../channel]/right/router-id";
              path "../../../lambda[channel=current()/../channel]/*/router-id";
            }
          }
        }
      }