Giter VIP home page Giter VIP logo

Comments (4)

robshakir avatar robshakir commented on August 24, 2024

ygot generates structures based on compiled data tree of the YANG model, not its logical constructs. This means that it resolves uses statements and includes the contents of the specified grouping within the struct. In your case then containers a and b - and thus the structs Top_A and Top_B - are only identical because only one grouping is used. If two were used, then the two would differ, and hence we couldn't generate a single struct. This approach would also be very fragile to internal refactoring of the YANG schema that would not affect the data tree structure.

Our design philosophy is that users need to know as little about YANG as possible to consume the models. Thus, I don't expect that there is a case whereby we want to generate code for grouping statements ever. What would the use case for this be? Could you elaborate on how it would overcome the above issues?

r.

from ygot.

ishidawataru avatar ishidawataru commented on August 24, 2024

@robshakir Thanks for your answer.

I'm having trouble with the following model.

module test {
   yang-version 1;
   namespace "http://example.com";
   prefix "test";

   grouping g {
      container c {
          leaf value {
             type uint8;
          }
      }
   }

   container top {
      container config {
         uses g;
      }
      container state {
         uses g;
      }
   }
}

If I use generator with -compress_paths option, generator generates two structures named Top_C and Top_C_ which corresponds to /test/top/config/c or /test/top/state/c but which corresponds to which is not deterministic and changes occasionally ( I think it is caused by the fact that map iteration is not ordered ).

This behavior causes trouble to the application which uses the generated go file since I need to change the structure name manually every time the naming changes.

I thought if we can use the same structure for grouping g, we can solve this problem.
Another solution would be adding some naming scheme or config/state structure when -compress_paths is used. WDYT?

from ygot.

robshakir avatar robshakir commented on August 24, 2024

from ygot.

ishidawataru avatar ishidawataru commented on August 24, 2024

I see. Thanks a lot for your answer.

from ygot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.