mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 343 forks source link

submodule augmenting main module #794

Closed apoorvashastry closed 2 years ago

apoorvashastry commented 2 years ago

Pyang throws error if a submodule is augmenting a node from main module

- CRITICAL ERROR line 13: node module1::test is not found
- CRITICAL ERROR line 16: module1-sub:test in the path for ref-id at /home/owner/tmp/yangsuite/yangsuite/users/owner/repositories/test-circular/module1-sub@2017-10-02.yang:14 is not found

I think in YANG 1.1 a submodule can augment main module. But still pyang reports error. Am I missing anything here or the model definition is wrong?

module1.yang:

module module1 {
    namespace "http://module1";
    prefix module1;
    yang-version 1.1;
    include module1-sub;
    revision 2017-09-30 {
        description "Initial release 1";
    }
    container test {
        leaf id {
            type enumeration {
                enum "option1";
                enum "option2";
            }
        }
        leaf copy-of-id {
            type leafref {
                path "../id";
            }
        }
    }
}

module1-sub.yang:

submodule module1-sub {
    belongs-to "module1" {
        prefix "module1";
    }
    yang-version 1.1;
    revision 2017-10-02 {
        description "Initial release 1";
    }
    augment /module1:test {
        leaf ref-id {
            type leafref {
                path "/module1:test/id";
            }
        }
    }
}
mbj4668 commented 2 years ago

This is a known issue. Closing as duplicate of #323.

apoorvashastry commented 2 years ago

@mbj4668 : What's the resolution or workaround for this? I looked into the #323 before opening this issue. I didn't quite understand what the workaround is. Can you please elaborate?