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

YDK bundles #43

Closed
ghost opened this issue Apr 21, 2016 · 6 comments
Closed

YDK bundles #43

ghost opened this issue Apr 21, 2016 · 6 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Apr 21, 2016

Background

Currently, YDK covers all the YANG model APIs, including openconfig, IETF, Cisco etc under the same python package and this is published as the ydk-py python package. The main reason why bundles are needed is that there needs to be a way to separately generate python packages for YDK model APIs for various YANG module repositories like openconfig, IETF, Cisco XR, Cisco XE etc. This will have more real world uses.

Bundling is meant as a extension of and replacement to the profile mechanism, which ydk-gen currently makes use of. Currently, ydk-gen generates a set of model APIs based on a profile and combined with the runtime YDK components (providers & services), creates a pip installable package (model APIs + YDK providers & services) called ydk-py.

Proposal

With the introduction of bundles, ydk-gen will no longer generate a pip package called ydk-py. Instead the new pip package will only contain the model API's for a given set of YANG models which are specified in the bundle JSON file. For example, ydk-gen can generate a pip installable package (model APIs) called ietf-bundle.

Currently, ydk-gen operates in the below way:

  1. Parse profile JSON
  2. Download yang models
  3. Using pyang, parse YANG files and return modules which are trees of Statement python objects
  4. Generate expanded YDK API model Packages from the above Statement trees
  5. Pass the ydk Packages to the PythonModulePrinter to print the YDK model API files

Package structure looks like below:

ydk-py
 |
 |-ydk
    |-models
       |
       |- ietf_interface
       | - ietf_system
    |-providers
    |-services
 |-samples

By introducing the concept of bundling, the flow will be like the below:

Resolve bundle (This sub-task is tracked in #26)

  1. Parse bundle JSON
  2. Download yang models (e.g. openconfig yang models) specified in the bundle plus any dependent YANG models from a different bundle (e.g. IETF yang models) which can also be specified in the main bundle

Build API model for bundle(s)
3. Using pyang, parse YANG files and return modules which are trees of Statement python objects
4. Generate expanded YDK API model Packages from the above Statement trees. Here, each bundle may utilize different code generation strategies, depending on the YANG model structure of the models in the bundle. For example, bundles can make use of choice statement inheritance or collapse containers with single list
5. Assign the list of YDK Packages as children of Bundle objects (by making use of the bundle JSON file)

Print model APIs for bundle(s)
6. Pass the ydk Bundles to the YDK Printer to print the YDK model API files for each bundle and generate the pip installable bundle (can be a python package and in the future, can be C++ library/ Ruby gem)

Package structure will look like below:

ietf-bundle
 |
 |-models
    |
    |- ietf_interface
    | - ietf_system
 |-samples
@ghost ghost added this to the 0.4.1 milestone Apr 21, 2016
@ghost ghost added the enhancement label Apr 21, 2016
@ghost
Copy link
Author

ghost commented Apr 22, 2016

How the end user will use YDK and bundles

The end user will pip install the bundle which they are interested in. For example, if they are interested in the openconfig bundle:
pip install openconfig-bundle
The bundle will have ydk-py (which consists of the runtime components - services + providers - and is published separately) as a dependency. So, they will pip install ydk-py:
pip install ydk-py
To use the models in apps, the user will import the model they are interested in plus any YDK services/providers:

from openconfig-bundle.models.bgp import Bgp
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider

def main():
  bgp_obj = Bgp()
  crud = CRUDService()
  provider  = NetconfServiceProvider("1.2.3.4")
  result = crud.read(provider, bgp_obj)

@ghost ghost self-assigned this Apr 22, 2016
@einarnn
Copy link
Contributor

einarnn commented Apr 25, 2016

One initial question.

If the developer has two different bundles that both augment a common base module, what happens? E.g. If someone installs (openconfig-interfaces, openconfig-if-ip) and then tries to install (openconfig-interfaces, openconfig-if-ethernet, openconfig-if-aggregate, openconfig-lacp)?

@ghost
Copy link
Author

ghost commented Apr 25, 2016

Thanks, Einar. I agree we need to come up with a solution for this. So far, I think I had considered bundles to consist of the entire set of models published by IETF or openconfig, for example. But there needs to be some way of addressing smaller, more granular bundle profiles, consisting of fewer models.

@ghost
Copy link
Author

ghost commented Apr 25, 2016

Another consideration is to have the Vagrant files as part of the MANIFEST file in the pip packaging for each bundle

@einarnn
Copy link
Contributor

einarnn commented Apr 26, 2016

BTW, as we discussed, if we want to start with a smaller scope that is more tractable, that's also fine!

@ghost
Copy link
Author

ghost commented Apr 26, 2016

Imported comment from gitlab:

The profile mechanism needs to be extended to first validate the profile to check if all the models referenced by the models in the profile are included in the profile

@ghost ghost added ready and removed ready labels Apr 29, 2016
@ghost ghost assigned psykokwak4 and unassigned ghost May 10, 2016
@ghost ghost added the in progress label May 20, 2016
@ghost ghost modified the milestones: 0.4.1, 0.5.0 Jun 7, 2016
@ghost ghost added the bundle label Jun 9, 2016
@ghost ghost closed this as completed Aug 16, 2016
@ghost ghost removed the in progress label Aug 16, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants