• This repository has been archived on 02/Nov/2023
  • Stars
    star
    184
  • Rank 207,952 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This project has been archived and the repository will no longer be updated. Python SDK generated from YANG data models.
https://travis-ci.com/CiscoDevNet/ydk-py.svg?branch=master Docker Automated build

YANG Development Kit (Python)

Overview

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.

Backward Compatibility

The Python YDK-0.8.4 core package is compatible with all model bundles generated previously with ydk-gen releases starting from 0.7.3. Please see the release notes for details.

Docker

A docker image is automatically built with the latest ydk-py installed. This be used to run ydk-py without installing anything natively on your machine.

To use the docker image, install docker on your system and run the below command. See the docker documentation for more details:

docker run -it ydkdev/ydk-py

System Requirements

Linux

Ubuntu (Debian-based)

The following packages must be present in your system before installing YDK-Py:

# Install Third-party software
sudo apt-get install gdebi-core python3-dev python-dev libtool-bin
sudo apt-get install libcurl4-openssl-dev libpcre3-dev libssh-dev libxml2-dev libxslt1-dev cmake

Download and install YDK core library libydk. You can install the library using prebuilt debian packages for Xenial and Bionic LTS distributions. For other Ubuntu distributions it is recommended to build core library from source.

For Xenial (Ubuntu 16.04.4):

# Upgrade compiler to gcc 5.*
sudo apt-get install gcc-5 g++-5 -y > /dev/null
sudo ln -sf /usr/bin/gcc-5 /usr/bin/cc
sudo ln -sf /usr/bin/g++-5 /usr/bin/c++

wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/xenial/libydk-0.8.4-1.amd64.deb
sudo gdebi libydk-0.8.4-1.amd64.deb

For Bionic (Ubuntu 18.04.1):

wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/bionic/libydk-0.8.4-1.amd64.deb
sudo gdebi libydk-0.8.4-1.amd64.deb

Centos (Fedora-based)

The following packages must be present in your system before installing YDK-Py. Currently, only Centos7/RHEL7 are known to work:

# Install Third-party software
sudo yum install epel-release
sudo yum install libssh-devel gcc-c++ python-devel python3-devel

# Upgrade compiler to gcc 5.*
sudo yum install centos-release-scl -y > /dev/null
sudo yum install devtoolset-4-gcc* -y > /dev/null
sudo ln -sf /opt/rh/devtoolset-4/root/usr/bin/gcc /usr/bin/cc
sudo ln -sf /opt/rh/devtoolset-4/root/usr/bin/g++ /usr/bin/c++

# Install YDK core library
sudo yum install https://devhub.cisco.com/artifactory/rpm-ydk/0.8.4/libydk-0.8.4-1.x86_64.rpm

MacOS

It is required to install Xcode command line tools, homebrew and the following homebrew packages on your system before installing YDK-Py:

xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install pkg-config libssh xml2 libxml2 curl pcre cmake pybind11 doxygen libgcrypt

curl -O https://devhub.cisco.com/artifactory/osx-ydk/0.8.4/libydk-0.8.4-Darwin.pkg
sudo installer -pkg libydk-0.8.4-Darwin.pkg -target /

Libssh Installation

The libssh-0.8.0 does not support separate threading library, which is required for YDK. If after installation of libssh package the libssh_threads.a is missing, please downgrade the installation to libssh-0.7.6, or upgrade to libssh-0.8.1 or higher.

Note for MacOS Before installing libssh make sure the environment for openssl is setup:

brew reinstall openssl
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl

Download libssh-0.7.6 source code, compile it and install:

wget https://git.libssh.org/projects/libssh.git/snapshot/libssh-0.7.6.tar.gz
tar zxf libssh-0.7.6.tar.gz && rm -f libssh-0.7.6.tar.gz
mkdir libssh-0.7.6/build && cd libssh-0.7.6/build
cmake ..
sudo make install

gNMI Requirements

In order to enable YDK support for gNMI protocol, which is optional, the following third party software must be installed prior to gNMI YDK component installation.

Install protobuf and protoc
wget https://github.com/google/protobuf/releases/download/v3.5.0/protobuf-cpp-3.5.0.zip
unzip protobuf-cpp-3.5.0.zip
cd protobuf-3.5.0
./configure
make
sudo make install
sudo ldconfig
Install gRPC
git clone -b v1.9.1 https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
sudo make install
sudo ldconfig
Instal YDK gNMI library

Ubuntu

For Xenial (Ubuntu 16.04.4):

wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/xenial/libydk_gnmi-0.4.0-4.amd64.deb
sudo gdebi libydk_gnmi-0.4.0-4.amd64.deb

For Bionic (Ubuntu 18.04.1):

wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/bionic/libydk_gnmi-0.4.0-4.amd64.deb
sudo gdebi libydk_gnmi-0.4.0-4.amd64.deb

CentOS:

sudo yum install https://devhub.cisco.com/artifactory/rpm-ydk/0.8.4/libydk_gnmi-0.4.0-4.x86_64.rpm

MacOS:

curl -O https://devhub.cisco.com/artifactory/osx-ydk/0.8.4/libydk_gnmi-0.4.0-4.Darwin.pkg
sudo installer -pkg libydk_gnmi-0.4.0-4.Darwin.pkg -target /
Runtime environment

There is an open issue with gRPC on Centos/Fedora, which requires an extra step before running any YDK gNMI application. See this issue on GRPC GitHub for details. As a workaround, the YDK based application runtime environment must include setting of LD_LIBRARY_PATH variable:

PROTO="/Your-Protobuf-and-Grpc-installation-directory"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PROTO/grpc/libs/opt:$PROTO/protobuf-3.5.0/src/.libs:/usr/local/lib64

Python Requirements

YDK supports both Python2 and Python3 versions. At least Python2.7 or Python3.4 must be installed on your system.

It is also required for Python installation to include corresponding shared library. As example:

python2.7  - /usr/lib/x86_64-linux-gnu/libpython2.7.so
python3.5m - /usr/lib/x86_64-linux-gnu/libpython3.5m.so

Please follow System Requirements to assure presence of shared Python libraries.

If you choose to install Python from source (need specific version), please include --enable-shared flag in configure command to include build of shared library:

cd Python3.4.1
./configure --prefix=/opt/python --enable-shared
make
make install

Here the /opt/python is your Python installation directory. If installation directory is different from the system path, you need to configure CMAKE_LIBRARY_PATH environment variable to assure that cmake uses correct Python library:

export CMAKE_LIBRARY_PATH=/opt/python/lib

Run pip install ydk command with -v option and in the console output note location of found PythonLibs. Make sure it matches with your installed Pyton dynamic library location:

-- Found PythonLibs: /opt/python/lib/libpython3.4m.so

In some OS configurations during YDK package installation the cmake fails to find C/C++ headers for previously installed YDK libraries. In this case the header location must be specified explicitly (in below commands the default location is shown):

export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include
Mac OS

The developers of Python2 on Mac OS might face an installation issue. This is well known and documented issue. Each developer might have different approaches for its resolution. One of them is to use Python2 virtual environment. See section Using Python virtual environment for details.

In addition it is required properly set CMAKE_LIBRARY_PATH environment variable to assure that cmake uses correct Python library. Follow these steps to find and set correct library path.

  1. Find installations of libpython2.7 library:
locate libpython2.7.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
/usr/lib/libpython2.7.dylib
/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
  1. Choose non-system Python library installation and set CMAKE_LIBRARY_PATH before any YDK component installation. Example:
export CMAKE_LIBRARY_PATH=/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib
  1. Run YDK core package installation with '-v' flag to check that PythonLibs points to correct library path. Example:
$ ./generate.py --core
$ pip install -v gen-api/python/ydk/dist/ydk*.tar.gz
  1. In 'cmake' log look for 'PythonLibs' and 'found version' settings line:
-- Found PythonLibs: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (found version "2.7.15")
  1. Finally test you YDK core library installation from CLI, making sure there are no errors:
$ python -c "import ydk.types"

How to install

Using Python virtual environment

You may want to perform the installation under Python virtual environment (virtualenv/virtualenvwrapper). The virtual environment allows you to install multiple versions of YDK if needed. In addition, it prevents any potential conflicts between package dependencies in your system.

To install virtual environment support in your system, execute:

pip install virtualenv virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh

To create and activate new virtual environment:

mkvirtualenv -p python2.7 ydk-py

To activate existing virtual environment:

source ~/.virtualenvs/py2/bin/activate

To exit virtual environment:

deactivate

Once Python virtual environment is activated, you can perform quick installation or installation from source described above. Take into consideration that you must not attempt to install YDK as root user under virtual environment.

Quick Install

You can install the latest model packages from the Python package index. Note that, in some systems, you need to install the new package as root. You get a fully operational YDK environment by installing the cisco-ios-xr and/or cisco-ios-xe bundle(s) (depending on whether you're developing for an IOS XR or IOS XE platform), which automatically installs all other YDK-related packages (ydk, openconfig and ietf packages):

pip install ydk-models-cisco-ios-xr
pip install ydk-models-cisco-ios-xe

Alternatively, you can perform a partial installation. If you only want to install the openconfig bundle and its dependencies (ydk and ietf packages), execute:

pip install ydk-models-openconfig

If you only want to install the ietf bundle and its dependencies (ydk package), execute:

pip install ydk-models-ietf

To installation of model bundles on CentOS/RedHat platforms require special handling; please follow the below steps.

Python2.7:

pip install ydk
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-openconfig
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xr
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xe

Python3.4:

pip install ydk
pip install --install-option="--install-purelib=/usr/lib64/python3.4/site-packages" --no-deps ydk-models-ietf
pip install --install-option="--install-purelib=/usr/lib64/python3.4/site-packages" --no-deps ydk-models-openconfig
pip install --install-option="--install-purelib=/usr/lib64/python3.4/site-packages" --no-deps ydk-models-cisco-ios-xr
pip install --install-option="--install-purelib=/usr/lib64/python3.4/site-packages" --no-deps ydk-models-cisco-ios-xe

Python3.6:

pip install ydk
pip install --install-option="--install-purelib=/usr/lib64/python3.6/site-packages" --no-deps ydk-models-ietf
pip install --install-option="--install-purelib=/usr/lib64/python3.6/site-packages" --no-deps ydk-models-openconfig
pip install --install-option="--install-purelib=/usr/lib64/python3.6/site-packages" --no-deps ydk-models-cisco-ios-xr
pip install --install-option="--install-purelib=/usr/lib64/python3.6/site-packages" --no-deps ydk-models-cisco-ios-xe

Installing from Source

If you prefer not to use the YDK packages in the Python package index, you need to install manually the ydk core package and then the model bundles you plan to use. To install the ydk core package, execute:

$ cd core
core$ python setup.py sdist
core$ pip install dist/ydk*.gz

Once you have installed the ydk core package, you can install one more model bundles. Note that some bundles have dependencies on other bundles. Those dependencies are already captured in the bundle package. Make sure you install the desired bundles in the order below. To install the ietf bundle, execute:

core$ cd ../ietf
ietf$ python setup.py sdist
ietf$ pip install dist/ydk*.gz

To install the openconfig bundle, execute:

ietf$ cd ../openconfig
openconfig$ python setup.py sdist
openconfig$ pip install dist/ydk*.gz

To install the cisco-ios-xr bundle, execute:

openconfig$ cd ../cisco-ios-xr
cisco-ios-xr$ python setup.py sdist
cisco-ios-xr$ pip install dist/ydk*.gz
cisco-ios-xr$ cd ..

Documentation and Support

Release Notes

The current YDK release version is 0.8.4. YDK-Py is licensed under the Apache 2.0 License.

More Repositories

1

netprog_basics

Code, Examples, and Resources for the Network Programmability Basics Video Course
Python
738
star
2

python_code_samples_network

A collection of Python Code Samples for Network Management. Includes samples to run on-box and off-box.
Python
609
star
3

yang-explorer

An open-source Yang Browser and RPC Builder Application
Python
438
star
4

awesome-webex

A curated list of Cisco Webex resources for developers
239
star
5

yangsuite

Cisco YANG Suite provides a set of tools and plugins to learn, test, and adopt YANG programmable interfaces such as NETCONF, RESTCONF, gNMI and more.
Shell
237
star
6

coding-skills-sample-code

Sample code for the Cisco DevNet Coding Skills Learning Labs
Python
217
star
7

cml-community

Community Contributed Content and Resources for Cisco Modeling Labs
Shell
188
star
8

roomdevices-macros-samples

Macros samples for Cisco CE Video Endpoints
JavaScript
166
star
9

bigmuddy-network-telemetry-pipeline

bigmuddy-network-telemetry-pipeline
162
star
10

dne-dna-code

Provides code examples for DevNet Test Drive Catalyst (DNA) series
Python
161
star
11

virlutils

A collection of utilities for interacting with Cisco VIRL / Cisco Modeling Labs (CML)
Python
151
star
12

ydk-gen

Generate model-driven APIs from YANG models
C++
134
star
13

ansible-aci

Cisco ACI Ansible Collection
Python
134
star
14

CiscoUIKit

The Cisco Brand-approved user interface kit. A modern, lightweight, responsive and programmable presentation layer that can be used to style HTML primitive elements and UI-framework independent.
CSS
122
star
15

api-design-guide

Guidelines for designing REST APIs at Cisco
109
star
16

ydk-py-samples

Sample apps for YDK-Py
Python
101
star
17

pathman-sr

Pathman SR is an open-source app to compute paths and deploy routes in Segment Routing-enabled network.
Python
96
star
18

python-viptela

Cisco Viptela vManage Python CLI/SDK
Python
95
star
19

terraform-provider-aci

Terraform Cisco ACI provider
Go
84
star
20

finesse-sample-code

Sample Gadgets and code for use with Finesse
83
star
21

pyats-sample-scripts

Various pyATS-based Test Automation Scripts
Python
82
star
22

sdwan-devops

SD-WAN DevOps Tools
Jinja
78
star
23

Getting-started-with-Cisco-SD-WAN-REST-APIs

Getting started with Cisco SD-WAN REST APIs
Python
72
star
24

cvd-config-templates

Contains Cisco Validated Design (CVD) Configuration Management Templates
Python
69
star
25

OpenDaylight-Openflow-App

JavaScript
68
star
26

sastre

Cisco-SDWAN Automation Toolset
Python
67
star
27

ncc

ncclient scripts and helpers
Jupyter Notebook
66
star
28

awesome-xapi

A curated list of developer resources to integrate with Webex Devices
63
star
29

meraki-code

Code for All Meraki Labs
Python
63
star
30

netconf-examples

NETCONF examples for learning labs
Python
61
star
31

axl-python-zeep-samples

Python
61
star
32

opendaylight-sample-apps

Sample applications for use with OpenDaylight (https://www.opendaylight.org/)
HTML
58
star
33

cloud-security

Python
57
star
34

postman-xapi

Postman collections for Webex Devices
57
star
35

ansible-meraki

Cisco Meraki Ansible Collection
Python
57
star
36

virl2-client

Client library for the Cisco VIRL 2 Network Simulation Platform
Python
57
star
37

apic-em-samples-aradford

This is a collection of sample scripts and tools for APIC-EM
Python
53
star
38

appdynamics-docker-images

Build repository for AppDynamics certified Docker Store images
Dockerfile
53
star
39

terraform-provider-iosxe

Terraform Cisco IOS-XE Provider
Go
53
star
40

devasc-code-examples

Provides the example Python and Ansible code and dependencies configuration for the Cisco DevNet Associate Fundamentals course.
Python
50
star
41

bigmuddy-network-telemetry-stacks

A batteries-included docker-based collection of demo stacks adapting network streaming telemetry to common consumer formats.
49
star
42

devnet-express-code-samples

Archived: This repository holds code samples for DevNet Express DNA Track
JavaScript
47
star
43

ansible-pyats

Python
46
star
44

botkit-template

Botkit template for Webex Teams
JavaScript
46
star
45

restconf-examples

RESTconf examples for learning labs and sample code
Python
45
star
46

uniq

A Python API client library for Cisco's Application Policy Infrastructure Controller Enterprise Module (APIC-EM) Northbound APIs.
Python
45
star
47

xapi-samples

Examples of UI Extensions, Macros and Node.js scripts for Webex devices and Cisco Collaboration Endpoints
HTML
45
star
48

botkit-webex-samples

Chatbot samples for Webex Teams built with Botkit
JavaScript
45
star
49

pyats-coding-101

pyATS Coding 101 - Python & automation tutorial
Python
45
star
50

bigmuddy-network-telemetry-collector

44
star
51

NeXt

Mirror of the OpenDaylight NeXt UI Toolkit gerrit project
JavaScript
44
star
52

merakibeat

Elastic Beat input plugin for Meraki health and location metrics collection
Python
40
star
53

catalyst9k-network-automation

Sample python scripts for automation workflows for feature sets present in Catalyst Switching using openly available YANG data models
Python
40
star
54

aci-learning-labs-code-samples

JavaScript
39
star
55

netdevops-live-0213

Sample Scripts from NETDEVOPS LIVE! S02E13 - Container Networking
Shell
39
star
56

BRKDEV-1368

Code used for the Cisco Live Session BRKDEV-1368
HTML
38
star
57

FTDAnsible

FTD Ansible module
Python
37
star
58

NX-SDK

NX-OS SDK
C++
37
star
59

g2p_seq2seq_pytorch

Grapheme to phoneme model for PyTorch
Python
37
star
60

ansible-dcnm

Python
37
star
61

Opendaylight-BGP-Pathman-apps

BGP and PCEP apps for Opendaylight, with the backend written in Python and the UI in JavaScript for NeXt
Python
37
star
62

code-exchange-repo-template

Template for creating a repo for software related to Cisco technologies to be shared with the DevNet community via Code Exchange
36
star
63

DNAC-AURA

Python
36
star
64

grpc-getting-started

Guide to get started with gRPC in Cisco IOS XR
Protocol Buffer
35
star
65

wcae

WCAE Troubleshooting tool
34
star
66

catalystwan

Cisco Catalyst WAN SDK
Python
33
star
67

ppe-detection

Python
33
star
68

dne-security-code

Python
32
star
69

fmc-rest-api

Learning labs for firepower management center REST APIs
HTML
30
star
70

ciscodevnet.github.io

Source for https://ciscodevnet.github.io
JavaScript
30
star
71

sd-wan-ansible-pipeline-code

SD-WAN Ansible CI/CD pipeline Code
Python
30
star
72

thousandeyes-kubernetes-operator

A Kubernetes operator to manage ThousandEyes tests
Go
30
star
73

secure-firewall

This is a place for various teamplates and automation resources for Cisco Secure Firewall
HCL
30
star
74

openconfig-getting-started

Getting started guides for OpenConfig in Cisco IOS XR
30
star
75

awesome-merakiapis

Collection point for all the awesome Meraki APIs.
29
star
76

DNAC-onboarding-tools

Cisco DNA Center PnP-BulkConfig app allows uploading of "predefined" rules to onboard network devices.
Python
28
star
77

iOAM

Java
28
star
78

Postman-for-Cisco-SD-WAN

Postman environment and collection for Cisco SD-WAN powered by Viptela
28
star
79

ContainerLabs

JavaScript
28
star
80

Hyperflex-Hypercheck

Perform pro-active self checks on your Hyperflex cluster to ensure stability and resiliency
Python
26
star
81

DNAC-Top5

Simple scripts to get started with Cisco DNA Center API.
Python
26
star
82

pyats-ios-sample

pyATS Example script for Cisco IOS Testbed
Python
25
star
83

webex-contact-center-widget-starter

WebEx Contact Center widget starter
JavaScript
25
star
84

uccx-sample-code

Sample code for use with Unified Contact Center Express
Java
24
star
85

node-sparkbot

Build Webex ChatBots in JavaScript
JavaScript
24
star
86

ansible-mso

Cisco MSO Ansible Collection
Python
24
star
87

devnet-express-cloud-collab-code-samples

Public repo that contains code samples for the DevNet Express Cloud Collaboration tracks
JavaScript
24
star
88

socialminer-sample-code

Sample code using Cisco SocialMiner APIs
JavaScript
23
star
89

webex-integration-sample

Node.js example of OAuth Integration for Webex Teams
JavaScript
23
star
90

webex-meetings-python-samples

This project contains sample scripts demonstrating usage of the Webex Meetings API, using Python
Python
23
star
91

ydk-go

This project has been archived and the repository will no longer be updated. Go SDK generated from YANG data models.
Go
23
star
92

bigmuddy-network-telemetry-proto

22
star
93

ansible-viptela

An Ansible Role for automating a Viptela Overlay Network
Python
22
star
94

iPSK-Manager

Identity PSK (IPSK) Manager for Cisco ISE provides an example of how to manage the full Life Cycle of Wi-Fi Pre Shared Keys for supported Hardware/Software through Cisco ISE.
PHP
22
star
95

logstash-codec-bigmuddy-network-telemetry-gpb

Logstash codec used to receive protobuf encoded network telemetry over UDP and produce logstash events.
22
star
96

dnac-apis-with-python-sample-codes

Python code to go with DNAC learning labs
Python
21
star
97

appdynamics-charts

Helm charts for AppDynamics
Mustache
21
star
98

node-sparkbot-samples

Chatbot samples leveraging the node-sparkbot library for Webex Teams
JavaScript
21
star
99

DNAC-TemplateProgrammer

Python
20
star
100

ansible-virl

Python
20
star