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

leafref in new type no work in uion type #388

Open
nowaits opened this issue Dec 19, 2022 · 2 comments
Open

leafref in new type no work in uion type #388

nowaits opened this issue Dec 19, 2022 · 2 comments
Labels

Comments

@nowaits
Copy link
Contributor

nowaits commented Dec 19, 2022

Hi olof,
Currently if leafref used in new type and the new type also be used in uion type, the leafref not work. My test yang is:

module ex {
    yang-version 1.1;
    namespace "http://www.xdja.com/ex";
    prefix ex;

    container c1 {
        leaf l1 {
            type string;
        }
    }

    container c2 {
        leaf l2 {
            type string;
        }
    }

    typedef ref1 {
        type leafref {
            path "/c1/l1";
            require-instance true;
        }
    }

    typedef ref2 {
        type leafref {
            path "/c2/l2";
            require-instance true;
        }
    }

    leaf test {
        type union {
            type ref1;
            type ref2;
        }
    }
}

My config is:

<configuration>
   <c1 xmlns="http://www.xdja.com/ex">
      <l1>test1</l1>
   </c1>
   <c2 xmlns="http://www.xdja.com/ex">
      <l2>test2</l2>
   </c2>
   <test xmlns="http://www.xdja.com/ex">xxx</test>
</configuration>

Leafref validation in ref1 and ref2 not work,but if replace the test yang like this.

module ex {
    yang-version 1.1;
    namespace "http://www.xdja.com/ex";
    prefix ex;

    container c1 {
        leaf l1 {
            type string;
        }
    }

    container c2 {
        leaf l2 {
            type string;
        }
    }

    leaf test {
        type union {
            type leafref {
                path "/c2/l2";
                require-instance true;
            }

            type leafref {
                path "/c1/l1";
                require-instance true;
            }
        }
    }
}

Leafref validation will work fine.

@nowaits
Copy link
Contributor Author

nowaits commented Dec 30, 2022

if add type enumeration {enum "0.0.0.0";} to type union, leafref and enum check will failed
yang like this:

module ex {
    yang-version 1.1;
    namespace "http://www.xdja.com/ex";
    prefix ex;

    container c1 {
        leaf l1 {
            type string;
        }
    }

    container c2 {
        leaf l2 {
            type string;
        }
    }

    typedef ref1 {
        type leafref {
            path "/c1/l1";
            require-instance true;
        }
    }

    typedef ref2 {
        type leafref {
            path "/c2/l2";
            require-instance true;
        }
    }

    leaf test {
        type union {
            type ref1;
            type ref2;
            type enumeration {enum "0.0.0.0";}
        }
    }
}

The test config:

<configuration>
   <c1 xmlns="http://www.xdja.com/ex">
      <l1>test1</l1>
   </c1>
   <c2 xmlns="http://www.xdja.com/ex">
      <l2>test2</l2>
   </c2>
   <test xmlns="http://www.xdja.com/ex">xxx</test>
</configuration>

all check will failed

shmuelhazan added a commit to shmuelhazan/clixon that referenced this issue Jan 31, 2023
This commit adds support for defining a
different table/list keys for snmp and
yang lists.

The definition is being done using the
cx-snmp:table-key extension.

Solves clicon#388
@olofhagsand
Copy link
Member

need to reevaluate this

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

No branches or pull requests

2 participants