04-15-2021 10:03 PM
04-15-2021 11:01 PM
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
04-17-2021 09:55 AM
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.
04-18-2021 05:53 PM
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
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