05-22-2018 02:27 PM
Hi !
i tried to reproduce whole procedure, described here NetconfServiceProvider is not able to establish ssh tunnel once again.I performed the same steps (as I believe), but now I get such error :
"
Traceback (most recent call last):
File "../../ydk/trash/1.py", line 80, in <module>
xml_payload = codec.encode(provider, configuration)
File "/home/alex-limonov/ydk0.7.1_py3.5/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 112, in helper
return func(self, provider, entity, *args, **kwargs)
File "/home/alex-limonov/ydk0.7.1_py3.5/lib/python3.5/site-packages/ydk/services/codec_service.py", line 78, in encode
return self._encode(provider, entity_holder, pretty, subtree)
File "/home/alex-limonov/ydk0.7.1_py3.5/lib/python3.5/site-packages/ydk/services/codec_service.py", line 110, in _encode
return result
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/alex-limonov/ydk0.7.1_py3.5/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/home/alex-limonov/ydk0.7.1_py3.5/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 54, in _raise
exec("raise exc from None")
File "<string>", line 1, in <module>
ydk.errors.YInvalidArgumentError: ancestor for entity cannot be nullptr as one of the ancestors is a list. Path: inet
"
Here (https://github.com/CiscoDevNet/ydk-gen/issues/629) i found information that this problem was already fixed and merged you
Could plz help to find may be the problem ?
Many thanks !
05-23-2018 11:33 AM
The fix for #629 was for presence container inside a list. The error you are seeing can also occur if one of the ancestor lists is not populated. Can you please provide the YDK version info, your python script and any logs?
pip list|grep ydk
05-23-2018 01:02 PM
05-24-2018 10:54 AM
Please refer to this developer guide: http://ydk.cisco.com/py/docs/guides/crud_guide.html#creating-a-configuration-with-a-list-and-a-presence-class
The below code worked for me:
configuration = junos_configuration.Configuration() ge000 = configuration.interfaces.Interface() ge000.name = "ge-0/0/0" ge000unit0 = ge000.Unit() ge000unit0.name = "0" # Create presence node ge000unit0.family.inet = ge000unit0.family.Inet() ge000unit0inetaddress = ge000unit0.family.inet.Address() ge000unit0inetaddress.name = "10.10.10.103/24" ge000unit0.family.inet.address.append(ge000unit0inetaddress) ge000.unit.append(ge000unit0) configuration.interfaces.interface.append(ge000)
print(codec.encode(codec_p,configuration))
<configuration xmlns="http://yang.juniper.net/yang/1.1/jc">
<interfaces>
<interface>
<name>ge-0/0/0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>10.10.10.103/24</name>
</address>
</inet>
</family>
</unit>
</interface>
</interfaces>
</configuration>
05-24-2018 12:47 PM
Which version of vendor yang models did you use ?
I used 17.1R1, and there container "Inet" has prorperty of Presence=True, and Class Family() has no instruction in constructor method Init() to create non-zero inet attribute ( in my configureation.py file it is self.inet = None )
That is why such code
configuration = junos_configuration.Configuration()
ge000 = configuration.interfaces.Interface()
ge000.name = "ge-0/0/0"
configuration.interfaces.interface.append(ge000)
ge000unit0 = ge000.Unit()
ge000unit0.name = "0"
ge000.unit.append(ge000unit0)
pprint.pprint(dir(ge000unit0.family))
pprint.pprint(vars(ge000unit0.family))
returns the output from attachment, where inet attribute of Famiy object is unassigned, consequently this format of use
does not work for me =((
Thanks !
05-24-2018 01:03 PM
Sorry I left out one line where I created the .inet presence node. Please see the above code.
I am using 17R1 also
05-24-2018 01:10 PM
I found one interesting thing about constructor method for class Family()
In old bundle, which I prepared couple weeks ago all child classes are listed within the same ordered dict
def __init__(self):
super(Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family, self).__init__()
self.yang_name = "family"
self.yang_parent_name = "unit"
self.is_top_level_class = False
self.has_list_ancestor = True
self.ylist_key_names = []
self._child_classes = OrderedDict([("inet", ("inet", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Inet)), ("iso", ("iso", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Iso)), ("inet6", ("inet6", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Inet6)), ("mpls", ("mpls", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Mpls)), ("mlppp", ("mlppp", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Mlppp)), ("mlfr-end-to-end", ("mlfr_end_to_end", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.MlfrEndToEnd)), ("mlfr-uni-nni", ("mlfr_uni_nni", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.MlfrUniNni)), ("ccc", ("ccc", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Ccc)), ("tcc", ("tcc", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Tcc)), ("vpls", ("vpls", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Vpls)), ("bridge", ("bridge", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Bridge)), ("ethernet-switching", ("ethernet_switching", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.EthernetSwitching)), ("any", ("any", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Any))])
self._leafs = OrderedDict()
and in new bundle, which I made couple of days ago there separate ordred dicts for container classes and for list classes
def __init__(self):
super(Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family, self).__init__()
self.yang_parent_name = "unit"
self.is_top_level_class = False
self.has_list_ancestor = True
self.ylist_key_names = []
self._child_container_classes = OrderedDict([("inet", ("inet", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Inet)), ("iso", ("iso", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Iso)), ("inet6", ("inet6", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Inet6)), ("mpls", ("mpls", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Mpls)), ("mlppp", ("mlppp", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Mlppp)), ("mlfr-end-to-end", ("mlfr_end_to_end", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.MlfrEndToEnd)), ("mlfr-uni-nni", ("mlfr_uni_nni", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.MlfrUniNni)), ("ccc", ("ccc", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Ccc)), ("tcc", ("tcc", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Tcc)), ("vpls", ("vpls", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Vpls)), ("bridge", ("bridge", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Bridge)), ("ethernet-switching", ("ethernet_switching", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.EthernetSwitching)), ("any", ("any", Configuration.DynamicProfiles.Interfaces.Interface.Unit.Family.Any))])
self._child_list_classes = OrderedDict([])
self._leafs = OrderedDict()
It seems there was a ydk-gen code update during last 2-3 weeks and could that cause problems I face ?
Thanks !
05-24-2018 01:24 PM
Yes. There was an update in this, but I dont think that is causing this issue.
Can you try the updated code here:
05-24-2018 02:15 PM
Unfortunately result is the same =(
"
File "<string>", line 1, in <module>
ydk.errors.YInvalidArgumentError: ancestor for entity cannot be nullptr as one of the ancestors is a list. Path: inet
"
Also previously you mentioned that reason of trouble may be "if one of the ancestor lists is not populated" , i am sorry if am asking about something trivial, but what does it mean ? As I could conclude we always provide root object(Configuration() in my case ) to CRUD or CODEC service.Whether some of child object were created, but only part of them were appended to ancestor list-type attribute - we would receive only partial payload(those xml/json blocks which correspond to appended child jobjects).When we append no child objects to ancestor list-type attribute - we should simply see total absence of corresponding xml blocks. So why this message appear ?
05-24-2018 03:31 PM
That does not apply in this case.
Not sure what is going on as the same code with the same environment is working for me, but not for you.
05-25-2018 09:06 AM
05-25-2018 09:53 AM
I see you have ydk (0.7.1).
I have ydk (0.7.2-dev). To install this, can you please try the below?
pip uninstall ydk -y cd ydk-gen/sdk/python/core python setup.py sdist pip install dist/ydk-0.7.2*.tar.gz
05-26-2018 08:59 AM
I downloaded ydk 0.7.2 (git clone https://github.com/CiscoDevNet/ydk-gen.git -b master)
and native libydk package (wget http://devhub.cisco.com/artifactory/debian-ydk/0.7.1/artful/libydk_0.7.1-1_amd64.deb)
After that i could generate python ydk core package, vendor yang-based package
"
cd ydk-gen
./generate --python --core
./generate --python --bundle junos.json
pip install gen-api/python/ydk/dist/ydk-0.7.2.dev0.tar.gz
pip install gen-api/python/junos-bundle/dist/ydk-models-junos-17.1.1.tar.gz
"
and run my test code
That works pretty fine for both python2.7 and python3.6
Thanks for help !
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide