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 qui fournit l'API pour le modèle YANG
--YDK Provider Module .. NetconfServiceProvider uniquement pour le moment
Mec facile. Si une erreur se produit en fonction de l'environnement, organisez-la de manière appropriée.
Cette fois, c'est principal.
pip install ydk-models-cisco-ios-xe
Au fait, je vais le mettre.
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()
~ $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#
C'était un simple contrôle de fonctionnement.
Recommended Posts