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

Add PathStruct definition and child ctor generating code for ypathgen #315

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

wenovus
Copy link
Collaborator

@wenovus wenovus commented Sep 26, 2019

This is the first step to a generating library (ypathgen) alongside ygen
which generates an API for creating YANG paths given a set of YANG
schema files. While ygen creates a set of structs for storing the data
of a YANG tree, ypathgen creates a set of structs for generating paths
denoting nodes in a YANG tree. This avoids any manual construction of
paths.

Envisioned API example:
oc.Interface("eth0").Counters().InOctets()

Each selector constructs and returns a child struct that keeps track of
the absolute path it represents.

This change includes the generation of these child constructors.

List of primary changes:

  • ygot/path_types.go defines the base struct and interface to be
    implemented by every path struct node.
  • KeyValueAsString() is enhanced to allow ygen.Binary to be converted to
    a string for use by gNMI as a list key value.
  • A GetDirectories() call is added to ygen for retrieving a parsed map of
    Directory elements for use by the ypathgen generation library. The
    output of this function is very similar to part of what ygen uses for
    its generation.
  • The configuration struct for ygen code generation is reorganized.
  • pathgen.go contains the child path struct constructor generation code.

…pathgen.

This is the first step to a generating library (ypathgen) alongside ygen
which generates an API for creating YANG paths given a set of YANG
schema files. While ygen creates a set of structs for storing the data
of a YANG tree, ypathgen creates a set of structs for generating paths
denoting nodes in a YANG tree. This avoids any manual construction of
paths.

Envisioned API example:
oc.Interface("eth0").Counters().InOctets()

Each selector constructs and returns a child struct that keeps track of
the absolute path it represents.

This change includes the generation of these child constructors.

List of primary changes:
- ygot/path_types.go defines the base struct and interface to be
implemented by every path struct node.
- KeyValueAsString() is enhanced to allow ygen.Binary to be converted to
a string for use by gNMI as a list key value.
- A GetDirectories() call is added to ygen for retrieving a parsed map of
Directory elements for use by the ypathgen generation library. The
output of this function is very similar to part of what ygen uses for
its generation.
- The configuration struct for ygen code generation is reorganized.
- pathgen.go contains the child path struct constructor generation code.
@googlebot googlebot added the cla: yes This PR author has signed the CLA label Sep 26, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 90.803% when pulling a930971 on wenbli-ypathgen-childctor into 5b5bc6b on master.

@wenovus wenovus marked this pull request as ready for review September 26, 2019 04:44
Copy link
Contributor

@robshakir robshakir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change here Wen -- LGTM, please go ahead and merge!

@wenovus wenovus merged commit 338f4a6 into master Oct 1, 2019
@wenovus wenovus deleted the wenbli-ypathgen-childctor branch October 1, 2019 00:32
@wenovus wenovus added this to Done in ypathgen creation Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR author has signed the CLA
Projects
No open projects
ypathgen creation
  
Implementation
Development

Successfully merging this pull request may close these issues.

None yet

4 participants