[PYTHON] First YDK to try with Cisco IOS-XE

What is YDK?

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

background

--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.

For the time being, this is all

--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

Installation

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

Sample code

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

Run

~ $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

First YDK to try with Cisco IOS-XE
Try to factorial with recursion
[First API] Try to get Qiita articles with Python
Try to profile with ONNX Runtime
Try to output audio with M5STACK
Try to reproduce color film with Python
Try logging in to qiita with Python
Manipulating Cisco IOS-XE ACLs with RESTCONF (Python)
Try to predict cherry blossoms with xgboost
Try converting to tidy data with pandas
Try to generate an image with aliasing
When checking multiple Forms with is_valid, first try assigning them to variables.
Try to make your own AWS-SDK with bash
Try to solve the fizzbuzz problem with Keras
First steps to try Google CloudVision in Python
Try to solve the man-machine chart with Python
Try to extract Azure document DB document with pydocumentdb
Try to draw a life curve with python
How to try the friends-of-friends algorithm with pyfof
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
[Introduction to Udemy Python3 + Application] 9. First, print with print
Try to make client FTP fastest with Pythonista
[Statistics] First "standard deviation" (to avoid frustration with statistics)
Try to detect fish with python + OpenCV2.4 (unfinished)
Try posting to Qiita for the first time
Try to solve the programming challenge book with python3
Try to make a command standby tool with python
Getting Started with pandas: Basic Knowledge to Remember First
Try to dynamically create a Checkbutton with Python's Tkinter
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
The first algorithm to learn with Python: FizzBuzz problem
Try to operate DB with Python and visualize with d3
Try to predict forex (FX) with non-deep machine learning
Try to make RESTful API with MVC using Flask 1.0.2
[GCP] Try a sample to authenticate users with Firebase
Try to get the contents of Word with Golang
[Neo4J] ④ Try to handle the graph structure with Cypher
A sample to try Factorization Machines quickly with fastFM
Try to tamper with requests from iphone with Burp Suite
Try to automate pdf format report creation with Python
Try to specify the axis with PyTorch's Softmax function
Try scraping with Python.
Convert 202003 to 2020-03 with pandas
Try to implement yolact
Try SNN with BindsNET
Try regression with TensorFlow
How to make a Cisco Webex Teams BOT with Flask
Try to build a deep learning / neural network with scratch
[Evangelion] Try to automatically generate Asuka-like lines with Deep Learning
Try to display various information useful for debugging with python
The first API to make with python Djnago REST framework
When I try to push with heroku, it doesn't work
Try Fortran with VS Code up to debug settings. [Win10]
[AWS] Try adding Python library to Layer with SAM + Lambda (Python)
The first step to creating a serverless application with Zappa
Try to bring up a subwindow with PyQt5 and Python
Try to extract Azure SQL Server data table with pyodbc
Try to automate the operation of network devices with Python
Try to process Titanic data with preprocessing library DataLiner (Append)