Problems executing python script in this specific lab of DEVASC training course, when you instantiate CRUDService() it fails with messages: "TypeError: ydk_.services.CRUDService.__init__() must be called when overriding __init__"
Ive tried to make changes inside of the crud_service, executor_service and netconf_service python files as mentioned here https://github.com/ygorelik/ydk-gen/commit/2c53f5dc736d73064c03dc1c404982d1c9011d64 actually the previous issue dissapear but now is showing issus related with the read method of the CRUDService object.
The python script executed is attached.
Someone knows which steps we have to take in account to make this script suscessfully work?
When building model you must always start from the top level entity and keep in mind that container and list classes has already been instantiated in parent class. Your script should be:
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_model # you had error in this line
# CSR1kv1 Credentials
ip = '10.0.0.20'
port_n = 830
user = 'cisco'
paswd = 'cisco'
proto = 'ssh'
if __name__ == '__main__':
# open the connection with Netconf server
provider = NetconfServiceProvider(address=ip, port=port_n, username=user, password=paswd, protocol=proto)
# initialize CRUD Service
crud = CRUDService()
# create a new instance of Native object
xe_native = xe_model.Native() # always start from top level entity
xe_interfaces = xe_native.interfaces # object 'interfaces' has already been instantiated
# read the interfaces with the help of read function
interfaces_data = crud.read(provider, xe_interfaces)
# print the primary address of the fifth gigabitethernet interface
Have the same problem when initializing CRUDService:
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
>>> from ydk.services import CRUDService
>>> crud = CRUDService()
TypeError: ydk_.services.CRUDService.__init__() must be called when overriding __init__
Please your help to solve this problem.
I made the changes inside of the crud_service.py file suggested and that solve the issue
Thanks Yan i tried again only modifying the crud_service.py file as mentioned here https://github.com/ygorelik/ydk-gen/commit/2c53f5dc736d73064c03dc1c404982d1c9011d64 and without any change in the code the scritp works as expected
Hello Luis and Jose
Since the 0.8.5 merge to upstream (still officially not released) I have fixed few bugs including the above one. Therefore I suggest you to use master branch from my fork. The installation is very simple:
git clone https://github.com/ygorelik/ydk-gen.git
For YDK test drive I suggest to use docker:
docker run -it ydksolutions/ydk-gen