GithubHelp home page GithubHelp logo

Comments (6)

robshakir avatar robshakir commented on June 1, 2024 1

from pyangbind.

xavier-contreras avatar xavier-contreras commented on June 1, 2024 1

Thanks @robshakir for the pointer , that does seem to be the case here.

@Baiyu-cmd , the README will need quite a bit of updating since models moved around, but to unblock you, you should be able to do something like this.

$ git clone https://github.com/openconfig/public
$ export PYBINDPLUGIN=`/usr/bin/env python3 -c \
> 'import pyangbind; import os; print ("{}/plugin".format(os.path.dirname(pyangbind.__file__)))'`
$ pyang --plugindir $PYBINDPLUGIN -f pybind -o routingbinding.py public/release/models/network-instance/openconfig-network-instance.yang -p ./public/release/models/
$ python3
>>> from routingbinding import openconfig_network_instance
>>> oclr = openconfig_network_instance()
>>> oclr.network_instances.network_instance.add('a')
>>> oclr.network_instances.network_instance['a'].protocols
>>> oclr.network_instances.network_instance['a'].protocols.protocol.add(identifier='STATIC', name='DEFAULT')
>>> rt = oclr.network_instances.network_instance['a'].protocols.protocol['STATIC DEFAULT'].static_routes.static.add("192.0.2.1/32")
>>> rt.config.set_tag = 42
>>> print(rt.config.set_tag)
42

local-routes was removed a while back, so keep that in mind when reading the documentation for now: https://github.com/openconfig/public/blob/master/release/models/local-routing/openconfig-local-routing.yang#L56C36-L56C42

from pyangbind.

xavier-contreras avatar xavier-contreras commented on June 1, 2024

I just verified I am running into this as well, to get to the point of generating a binding file I also had to add some commands to the shell script in case someone can take a look:

curl https://raw.githubusercontent.com/openconfig/public/master/release/models/bfd/openconfig-bfd.yang -o $SDIR/yang/openconfig-bfd.yang
curl https://raw.githubusercontent.com/openconfig/public/master/release/models/optical-transport/openconfig-transport-types.yang -o $SDIR/yang/openconfig-transport-types.yang
curl https://raw.githubusercontent.com/openconfig/public/master/release/models/platform/openconfig-platform-types.yang -o $SDIR/yang/openconfig-platform-types.yang

I tried to generate other bindings for different models (interfaces & wifi/access-points) and those worked fine.

from pyangbind.

Baiyu-cmd avatar Baiyu-cmd commented on June 1, 2024

I tried to generate other bindings for different models (interfaces & wifi/access-points) and those worked fine.

Glad to receive your reply. Also sorry, I found the three files missing while running the instance, so I found the source address and added the three files myself, still not generating the correct binding.
I also tried using tests/base-test.yang (which is the file used in the previous example steps) to generate binding.py. It is also used to generate xml files, but the generated xml file content is only declarations.

from pyangbind.

Baiyu-cmd avatar Baiyu-cmd commented on June 1, 2024

In order to better solve the problem, I have posted my operations on the oc_local_routing.yang and base_test.yang files in two attachments, I wish I could use pyangding in ncclient.
base_test.txt
oc_local_routing.txt

from pyangbind.

Baiyu-cmd avatar Baiyu-cmd commented on June 1, 2024

Thanks @robshakir for the pointer , that does seem to be the case here.

@Baiyu-cmd , the README will need quite a bit of updating since models moved around, but to unblock you, you should be able to do something like this.

$ git clone https://github.com/openconfig/public
$ export PYBINDPLUGIN=`/usr/bin/env python3 -c \
> 'import pyangbind; import os; print ("{}/plugin".format(os.path.dirname(pyangbind.__file__)))'`
$ pyang --plugindir $PYBINDPLUGIN -f pybind -o routingbinding.py public/release/models/network-instance/openconfig-network-instance.yang -p ./public/release/models/
$ python3
>>> from routingbinding import openconfig_network_instance
>>> oclr = openconfig_network_instance()
>>> oclr.network_instances.network_instance.add('a')
>>> oclr.network_instances.network_instance['a'].protocols
>>> oclr.network_instances.network_instance['a'].protocols.protocol.add(identifier='STATIC', name='DEFAULT')
>>> rt = oclr.network_instances.network_instance['a'].protocols.protocol['STATIC DEFAULT'].static_routes.static.add("192.0.2.1/32")
>>> rt.config.set_tag = 42
>>> print(rt.config.set_tag)
42

local-routes was removed a while back, so keep that in mind when reading the documentation for now: https://github.com/openconfig/public/blob/master/release/models/local-routing/openconfig-local-routing.yang#L56C36-L56C42

@xavier-contreras Thanks again for your reply, I am very happy to see the implementation of the function, although I have tested some other yang files and there is still a problem of stably generating usable.py files, but this makes me see some possibilities and feel happy for this wonderful code. Am I correct in understanding that this 'local-routes' refers to the instance now used in the README?

from pyangbind.

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.