Comments (6)
from pyangbind.
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.
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.
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.
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.
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)
- Add async as a reserved Python name. HOT 1
- Pyangbind PYPI release does not have pybindIETFXMLEncoder class HOT 1
- How to inspect yang model HOT 2
- pyangbind is not taking care of "when" statement in yang definitions. HOT 2
- Problem with list's key made of multiple leaf identifiers HOT 3
- Is pyangbind still maintained? HOT 3
- RuntimeError when importing an older revision of a YANG file HOT 1
- Failure on OpenConfig BFD Model HOT 3
- Fix binary type representation HOT 2
- Integration and Sample UnitTests using BGP are broken
- __add_metadata is not adding the @metadata object to JSON or XML HOT 2
- 0.8.3 - TypeError: cannot pickle 'lxml.etree.XMLSchema' object HOT 8
- Support `bits` type HOT 1
- pyangbind fails processing typedef union with default value
- pyangbind-0.8.4 installation failed HOT 2
- Can not be directly used in ncclient? HOT 2
- TypeError: unhandled keyword with children case HOT 3
- How to filter by leaf? HOT 3
- Process for moving a list element HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyangbind.