05-15-2020 03:13 AM - edited 05-18-2020 03:05 AM
Update: I got the fix but still ran in to same issue. I have also attched the full set of files that I used to test along with host vars.
1. I cloned the git repo https://github.com/ygorelik/ydk-gen to my VM
2. cd ydk-gen
./generate.py --libydk -is
./generate.py --core -is
3. ./generate.py --python --bundle profiles/bundles/<name-of-profile>.json
4. Launched Python Virtual environment with python 3.6
5. sudo pip install gen-api/python/cisco_ios_xe-bundle/dist/ydk*.tar.gz
6. ran the python script I attached earlier.
I still got same issue as before.
File "ydk_config_gen_vlan.py", line 115, in <module>
native = xe_native.Native()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1330, in __init__
self.aaa = Native.Aaa()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1699078, in __init__
self.accounting = Native.Aaa.Accounting()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1707590, in __init__
self.onep = Native.Aaa.Accounting.Onep()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709446, in __init__
self.default = Native.Aaa.Accounting.Onep.Default()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709505, in __init__
self.start_stop = Native.Aaa.Accounting.Onep.Default.StartStop()
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709582, in __init__
self.logger = None
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709604, in __setattr__
self._perform_setattr(Native.Aaa.Accounting.Onep.Default.StartStop, [u'broadcast', u'logger'], name, value)
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/types/py_types.py", line 390, in _perform_setattr
_validate_value(self._leafs[name], name, value, self.logger)
File "/home/vagrant/ydk-gen/venv/lib/python3.6/site-packages/ydk/types/py_types.py", line 847, in _validate_value
raise _YModelError(err_msg)
ydk.errors.YModelError: Invalid value None for 'logger'. Got type: 'NoneType'. Expected types: 'Empty'
I am trying to build and run against YDK model with python for ISO XE 16121 . I was successfull in building and installing the API models .But when I try running the a python script I used in to issues. See error log below. Note that I tried with both Python 2.7 and 3.6 as well and got same issue . Any help is appreciated.
Below is my Bundle details. I built the bundle with 16121 Yang models
ydk 0.8.4
ydk-models-cisco-ios-xe 16.12.1
ydk-models-ietf 0.1.5.post2
File "ydk_config_gen_vlan.py", line 115, in <module>
native = xe_native.Native()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1328, in __init__
self.aaa = Native.Aaa()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1699076, in __init__
self.accounting = Native.Aaa.Accounting()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1707588, in __init__
self.onep = Native.Aaa.Accounting.Onep()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709444, in __init__
self.default = Native.Aaa.Accounting.Onep.Default()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709503, in __init__
self.start_stop = Native.Aaa.Accounting.Onep.Default.StartStop()
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709580, in __init__
self.logger = None
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/models/cisco_ios_xe/Cisco_IOS_XE_native.py", line 1709602, in __setattr__
self._perform_setattr(Native.Aaa.Accounting.Onep.Default.StartStop, [u'broadcast', u'logger'], name, value)
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/types/py_types.py", line 390, in _perform_setattr
_validate_value(self._leafs[name], name, value, self.logger)
File "/home/vagrant/venv/lib/python3.6/site-packages/ydk/types/py_types.py", line 847, in _validate_value
raise _YModelError(err_msg)
ydk.errors.YModelError: Invalid value None for 'logger'. Got type: 'NoneType'. Expected types: 'Empty'
.
05-15-2020 11:52 AM
Here are the bundle version, I built the bundle with 16121
ydk 0.8.4
ydk-models-cisco-ios-xe 16.12.1
ydk-models-ietf 0.1.5.post2
05-15-2020 03:35 PM
I am trying to build bundle for IOS XE 16.12.1 using published YANG models, but getting errors in Cisco-IOS-XE-bgp.yang. In this regards could you please share correct model and bundle profile.
Also, could you please share *.yaml files needed to run your script.
05-16-2020 10:24 AM - edited 05-18-2020 09:51 AM
Hi arsakthi
After in depth investigation I realized that this is a bug in python core package. I have opened GitHub issue #996 and then resolved it. The solution is part of YDK new release, which I am working on currently. It is located in my private fork. If this is critical for your work, I suggest to do the following after system requirements are met:
git clone https://github.com/ygorelik/ydk-gen.git -b 0.8.4.post1
cd ydk-gen
./generate.py --libydk -is
# switch to your Python virtual environment then install Python core package
./generate.py --core -i
05-18-2020 10:21 AM
Hi arsakthi
Based on your description, you have installed python core package and model bundle in Python2 system location. (I should be more precise in describing procedure, just wanted to make it look simple). Therefore you did not pickup the fixed code.
If you use python virtual environment, then you should switch to it BEFORE installing python core and bundle packages. Also, you should not use '-s' (or --sudo) option when installing in virtual environment. The procedure should look like this:
# 1. Clone the git repository to your working space:
git clone https://github.com/ygorelik/ydk-gen.git -b 0.8.4.post1
cd ydk-gen
# 2. Generate and install libydk library (needs sudo access):
./generate.py --libydk -is
# 3. Switch to Python virtual environment, then generate and install YDK Python core package:
source /your-venv-location/bin/activate
./generate.py --core -i
# 4. Generate and install Model API bundle package:
./generate.py --bundle profiles/bundles/<name-of-profile>.json -i
# 5. Run the python script.
05-18-2020 12:18 PM
Hi There,
Thanks for the steps.
I am now able to get past the logger issue and ran in to a new issue. See trace below.
i have attached the script and env files in the original thread .
Traceback (most recent call last):
File "ydk_config_gen_vlan.py", line 127, in <module>
locals()[model_function](native, config_models_cs[model])
File "ydk_config_gen_vlan.py", line 74, in config_layer2_global_sw_int_model
intf.device_tracking.attach_policy = input_intf["device_tracking_policy"]
AttributeError: 'NoneType' object has no attribute 'attach_policy'
(newenv) vagrant@devbox:~/ydk-gen_/ydk_config_vlan$
05-19-2020 09:22 AM
This does not look like YDK or Model API issue. I suggest put your script into debugger.
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