Closed Baiyu-cmd closed 10 months ago
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.
I think this was because local-routing in OpenConfig is now within network instances.
r.
On Thu, 21 Dec 2023 at 14:52, xavier-contreras @.***> wrote:
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.
— Reply to this email directly, view it on GitHub https://github.com/robshakir/pyangbind/issues/334#issuecomment-1866975657, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE43VJN3MCLLTRH3OCMJK3YKSVRBAVCNFSM6AAAAABA55DCGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRWHE3TKNRVG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>
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.
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
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
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?
I follow the steps of the project completely. When I run the "docs/example/oc-local-routing/generate_bindings.sh" command, there is no corresponding attribute in the binding file's class.The following is the binding document content produced by me.
I assumed that it was legal to continue the operation and found that subsequent steps showed that the file was missing corresponding attributes at that location. I don't know if there is anything wrong with my previous steps, if you need to post it.