0

I have the following simple yang files. I was trying to get a tree output that consolidates the module and submodule, but, cant get.

    module modA {
        yang-version 1.1;
        namespace "http://www.example.com/";
        prefix ma;    

        container c {
            leaf l {
              type string;            
           }
        }
    }

and

submodule sub1 {
    yang-version 1.1;        

    belongs-to "modA" {
        prefix mA;
    }

    container sub-container {
        leaf l {
            type string;            
        }
    }
}

I tried the libyang/yanglint but, it failed with the following error :

add sub1.yang libyang[0]: Unable to parse submodule, parse the main module instead.

earlier, I tried with pyang too, but, not seeing a single tree that combines both yang files.

And, I tried a duplicate node in the submodule, like so:

module a {
  container c {}
}

submodule b {
  belongs-to a;
  container c {}; // I was expecting this to fail because this will clash 
             // with the container c in the module.  But, pyang compilation went through without error. Is my expectation wrong?
}
Neeraj Sewani
  • 3,952
  • 6
  • 38
  • 55
user19937
  • 587
  • 1
  • 7
  • 25
  • 1
    I've not checked pyang's progress in a while, but at least a year ago, YANG 1.1 submodules were not supported by it (due to new "everyone sees everything" rules). Your expectation is valid - there cannot be two data nodes named the same way within a single namespace at the same nesting level. – predi May 28 '18 at 06:34
  • For people to adapt yang there should be at least one very strong compiler implementation that is keeping pace with the spec. What are the options for someone implementing yang based solution to test their understanding or even experiment yang models ? I usually test with pyang to cross check my understanding. What other options are there ? thank you – user19937 May 28 '18 at 14:05
  • I made a mistake in my module yang file. I did not 'include' the sub module. After correcting that, I am seeing a consolidated tree. that is nice. But, it still does not flag error for the duplicate node case. – user19937 May 28 '18 at 21:46

0 Answers0