The YANG Development Kit (YDK) is a Software Development Kit that provides API’s that are modeled in YANG. The main goal of YDK is to reduce the learning curve of YANG data models by expressing the model semantics in an API and abstracting protocol/encoding details. YDK is composed of a core package that defines services and providers, plus one or more module bundles that are based on YANG models.
--SDK that provides API for YANG model --Abstract protocols (SSH and Netconf) and encodings (XML) --You can concentrate on the operation of the YANG model and greatly reduce the learning time. --Created and published by Cisco ydk.io ydk.cisco.com --YANG?-> Get used to the YANG model with YANG Explorer
--YANG Explorer and Pyang is useful for understanding YANG model, but when writing code, you will use NCClient or YDK. --Reference for using NCClient: get_config in Python 1 --YDK has been popularized mainly by IOS-XR users, but the IOS-XE bundle API was released around June 6, 2017, and you can easily try it with IOS-XE.
--YDK Provider Module .. NetconfServiceProvider only for now --YDK Service Module --CRUDService .. CRUD (Create / Read / Update / Delete) operation of Entity created by YDK module --NetconfService .. Netconf Operation operations --CodecService .. Entity encoding, payload decoding --ExecutionorService .. RPC Execution
-IOS Config --IOS-XE version uses 16.5
Easy guy. If an error occurs depending on the environment, arrange it appropriately.
This time's main.
pip install ydk-models-cisco-ios-xe
By the way, I'll put it in.
pip install ydk-models-cisco-ios-xe
pip install ydk-models-openconfig
pip install ydk-models-ietf
ydk_test.py
import sys
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_native
provider = NetconfServiceProvider(address="10.71.130.57",port=830,username="cisco",password="cisco",protocol="ssh")
crud = CRUDService()
native = xe_native.Native()
native.hostname = sys.argv[1]
native.banner.motd.message = sys.argv[2]
crud.create(provider, native)
provider.close()
exit()
--Create Netconf Provider (device access information) --Create Entity (hostname and banner settings) using YDK-IOS-XE API --Enter Provider and Entity in Create method of CRUD service object
~ $python3 ydk_test.py CSR1KV-1 "Hello, YDK"
cisco
Router#sh run | i banner
banner motd ^CHi, good morning^C
Router#
Router#
Router#
CSR1KV-1#
CSR1KV-1#sh run | i banner
banner motd ^CHello, YDK^C
CSR1KV-1#
CSR1KV-1#
It was a simple operation check.
Recommended Posts