cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
202
Views
5
Helpful
3
Replies

I have the same issue with Luis Perez when I run very very simple YDK python script to get the hostname

Hello Leader,
 
Today I run very simple pilot YDK Python script.  But It seems there is the same issue with Luis.
 
 
 
ydk (0.8.5)
ydk-models-cisco-ios-xe (16.9.3)
ydk-models-ietf (0.1.5.post2)
 
#######################Error Message################################
jzhang/virtualenv/ydk-gen-envir/coding/1.py
Traceback (most recent call last):
File "/home/jzhang/virtualenv/ydk-gen-envir/coding/1.py", line 14, in <module>
crud = CRUDService()
TypeError: ydk_.services.CRUDService.__init__() must be called when overriding __init__
 
 
######################Code###############################################
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_model

 

if __name__ == "__main__":
    """Main execution path"""

 

    # create NETCONF session
    provider = NetconfServiceProvider(address="10.2.1.25",
                                      port=830,
                                      username="lznwfdf",
                                      password="cisco,
                                      protocol="ssh")
    crud = CRUDService()
    xe_native = xe_model.Native()
    hostname = xe_native.hostname
    myhostname = crud.read(provider,hostname)
    print(myhostname)
 
 
 
Jacky Zhang
Global Telecom
3 REPLIES 3

Hi Team,

 

Can you have a check if I am wrong.   I changed the "_CrudService"  to "object" in crud_service.py

Is that all ?     But it still doesn't work.  When I run the script, it was hang.

 

Can you give me some advice ?   

Thank you

 

/python/core/ydk/services/crud_service.py
from ydk.filters import YFilter

 

class CRUDService(_CrudService
class CRUDService(object

Jacky Zhang
Global Telecom
yangorelik
Participant

Hi Jacky

The type of error that you have tells me that you are running YDK-0.8.5 based on CiscoDevNet repository. That is outdated and out of sync. For the latest working well YDK please clone it from my fork.

Also. You have an error in the script. The 'hostname' is a value of leaf, you cannot pass it to the CRUD, which expects an Entity object.

Here is working script:

from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_model
from ydk.filters import YFilter
import logging

def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(level)
handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
log.addHandler(handler)

if __name__ == "__main__":
"""Main execution path"""
enable_logging(logging.INFO)

# create NETCONF session
provider = NetconfServiceProvider(address="ios-xe-mgmt.cisco.com",
port=10000,
username="developer",
password="C1sco12345",
protocol="ssh")
crud = CRUDService()
xe_native = xe_model.Native()
xe_native.hostname = YFilter.read
native = crud.read(provider, xe_native)
print(native.hostname)

I suggest you to go over documentation regarding basic CRUD operations.

Yan Gorelik
YDK Solutions

Hi Yan,

 

I have one issue when I install it.  Can you have a look and give me some advice ?

 

I attached installation log in the attachment.

 

Thanks a lot

 

My Virtual Environment: 
(ydk-gen-yan) root@CNPDGWNCP142F0K:/home/jzhang/virtualenv/ydk-gen-yan/ydk-gen-master#
(ydk-gen-yan) root@CNPDGWNCP142F0K:/home/jzhang/virtualenv/ydk-gen-yan/ydk-gen-master# pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
pkg-resources (0.0.0)
setuptools (39.0.1)

 

#####################################Installation error################################################

(ydk-gen-yan) root@CNPDGWNCP142F0K:/home/jzhang/virtualenv/ydk-gen-yan/ydk-gen-master# ./install_ydk.sh --core

 

*** Mon Apr 19 08:18:04 DST 2021 *** dependencies_ubuntu.sh | Running: sudo apt-get update -y
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Hit:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Reading package lists... Done
/usr/bin/gcc
*** Mon Apr 19 08:18:26 DST 2021 *** dependencies_ubuntu.sh | Current gcc/g++ version is 5.5.0
*** Mon Apr 19 08:19:12 DST 2021 *** dependencies_ubuntu.sh | Current Go version is 1.9.2
*** Mon Apr 19 08:19:12 DST 2021 *** dependencies_ubuntu.sh | Installing confd

 

Archive: confd-basic-6.2.linux.x86_64.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of confd-basic-6.2.linux.x86_64.zip or
confd-basic-6.2.linux.x86_64.zip.zip, and cannot find confd-basic-6.2.linux.x86_64.zip.ZIP, period.
*** Mon Apr 19 08:32:39 DST 2021 *** dependencies_ubuntu.sh | Running: ./confd-basic-6.2.linux.x86_64.installer.bin /root/confd
/root/ydk-gen/test/dependencies_ubuntu.sh: line 35: ./confd-basic-6.2.linux.x86_64.installer.bin: No such file or directory
*** Mon Apr 19 08:32:39 DST 2021 *** dependencies_ubuntu.sh | Exiting './confd-basic-6.2.linux.x86_64.installer.bin /root/confd' with status=127
*** Mon Apr 19 08:32:39 DST 2021 *** install_ydk.sh | Exiting '/root/ydk-gen/test/dependencies_ubuntu.sh' with status=127

 

Jacky Zhang
Global Telecom
Content for Community-Ad

This widget could not be displayed.