Giter Club home page Giter Club logo

ydk-py's Introduction

image

Docker Automated build

## This project has been archived and the repository will no longer be updated.

YANG Development Kit (Python)

Table of Contents

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

Install gRPC

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:
  1. Choose non-system Python library installation and set CMAKE_LIBRARY_PATH before any YDK component installation. Example:
  1. Run YDK core package installation with '-v' flag to check that PythonLibs points to correct library path. Example:
  1. In 'cmake' log look for 'PythonLibs' and 'found version' settings line:
  1. Finally test you YDK core library installation from CLI, making sure there are no errors:

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.

ydk-py's People

Contributors

111pontes avatar adrienne-at-work avatar einarnn avatar manradhacisco avatar psykokwak4 avatar ygorelik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ydk-py's Issues

API to return raw xml data

Can we have an API to get raw xml data, when I try to run ydk for getting oper data from the router ?

There are multiple instances where xml output returned by the router is in-correct. Consequently, ydk returns 'YPYModelError: 0 already in list'. In such instances, it will be good to get the xml output in raw format.

OpenDaylightserviceprovider not working

Hi,

I'm running ODL 0.11.1 and the docker image of YDK (0.8.4).

When I run the service provider query I got the following error:

odl_provider = OpenDaylightServiceProvider(repo, "127.0.0.1", "admin", "admin", 8181, EncodingFormat.XML)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: type must be string, but is object

I noticed this happens only if my router is in connected state in my controller:


opendaylight-user@root>netconf:list-devices                                                                                                                                                                 
NETCONF ID          | NETCONF IP   | NETCONF Port | Status   
-------------------------------------------------------------
EDG-01-216.BRU1-IXN | 10.1.128.120 | 1830         | connected

When my router is in connecting state then the query succeeds without any issue

opendaylight-user@root>netconf:list-devices
NETCONF ID          | NETCONF IP   | NETCONF Port | Status    
--------------------------------------------------------------
EDG-01-216.BRU1-IXN | 10.1.128.120 | 1830         | connecting

I got the same result with ODL 0.8.3 and can't get it working.

The difference between connecting and connected state is the reply returned by ODL. In the first case it doesn't contains the capabilities of the router and the connected state the controller returns the full list of supported capabilities which (I think) leads to the above error.

Is this a bug ?

Thanks

using ydk

UPDATE: I had to install core, then ietf, to allow me to install the oc models. README should be updated.

Keep the original issue for others to see:

Can someone tell me how to get over this hump of a conversioning issue?

ERROR:

  Could not find a version that satisfies the requirement ydk>=0.5.0 (from ydk-models-openconfig==0.1.0) (from versions: )
No matching distribution found for ydk>=0.5.0 (from ydk-models-openconfig==0.1.0)
(ydkpy) jason@ubuntu:openconfig (master)$ 

FULL WORFKLOW

(ydkpy) jason@ubuntu:tools$ git clone https://github.com/CiscoDevNet/ydk-py
Cloning into 'ydk-py'...
remote: Counting objects: 3811, done.
remote: Total 3811 (delta 0), reused 0 (delta 0), pack-reused 3811
Receiving objects: 100% (3811/3811), 61.15 MiB | 904.00 KiB/s, done.
Resolving deltas: 100% (2520/2520), done.
Checking connectivity... done.
Checking out files: 100% (541/541), done.
(ydkpy) jason@ubuntu:tools$ cd ydk-py/
(ydkpy) jason@ubuntu:ydk-py (master)$ 
(ydkpy) jason@ubuntu:ydk-py (master)$ 
(ydkpy) jason@ubuntu:ydk-py (master)$ cd openconfig/
(ydkpy) jason@ubuntu:openconfig (master)$ python setup.py sdist
running sdist
running egg_info
creating ydk_models_openconfig.egg-info
writing requirements to ydk_models_openconfig.egg-info/requires.txt
writing ydk_models_openconfig.egg-info/PKG-INFO
writing namespace_packages to ydk_models_openconfig.egg-info/namespace_packages.txt
writing top-level names to ydk_models_openconfig.egg-info/top_level.txt
writing dependency_links to ydk_models_openconfig.egg-info/dependency_links.txt
writing manifest file 'ydk_models_openconfig.egg-info/SOURCES.txt'
reading manifest file 'ydk_models_openconfig.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'ydk_models_openconfig.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt

running check
creating ydk-models-openconfig-0.1.0
creating ydk-models-openconfig-0.1.0/ydk
creating ydk-models-openconfig-0.1.0/ydk/models
creating ydk-models-openconfig-0.1.0/ydk/models/_deviate
creating ydk-models-openconfig-0.1.0/ydk/models/openconfig
creating ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
creating ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying files to ydk-models-openconfig-0.1.0...
copying MANIFEST.in -> ydk-models-openconfig-0.1.0
copying README.md -> ydk-models-openconfig-0.1.0
copying setup.py -> ydk-models-openconfig-0.1.0
copying ydk/__init__.py -> ydk-models-openconfig-0.1.0/ydk
copying ydk/models/__init__.py -> ydk-models-openconfig-0.1.0/ydk/models
copying ydk/models/_deviate/__init__.py -> ydk-models-openconfig-0.1.0/ydk/models/_deviate
copying ydk/models/openconfig/__init__.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/_yang_ns.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/bgp.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/bgp_policy.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/bgp_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_if_aggregate.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_if_ethernet.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_if_ip.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_interfaces.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_inventory.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_inventory_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_mpls.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_mpls_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_rpc_api.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_telemetry.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_terminal_device.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_transport_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/openconfig_vlan.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/policy_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/routing_policy.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig
copying ydk/models/openconfig/_meta/__init__.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_bgp.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_bgp_policy.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_bgp_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_if_aggregate.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_if_ethernet.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_if_ip.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_interfaces.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_inventory.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_inventory_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_mpls.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_mpls_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_rpc_api.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_telemetry.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_terminal_device.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_transport_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_openconfig_vlan.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_policy_types.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk/models/openconfig/_meta/_routing_policy.py -> ydk-models-openconfig-0.1.0/ydk/models/openconfig/_meta
copying ydk_models_openconfig.egg-info/PKG-INFO -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying ydk_models_openconfig.egg-info/SOURCES.txt -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying ydk_models_openconfig.egg-info/dependency_links.txt -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying ydk_models_openconfig.egg-info/namespace_packages.txt -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying ydk_models_openconfig.egg-info/requires.txt -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
copying ydk_models_openconfig.egg-info/top_level.txt -> ydk-models-openconfig-0.1.0/ydk_models_openconfig.egg-info
Writing ydk-models-openconfig-0.1.0/setup.cfg
creating dist
Creating tar archive
removing 'ydk-models-openconfig-0.1.0' (and everything under it)
(ydkpy) jason@ubuntu:openconfig (master)$ pip install dist/ydk-*.tar.gz
Processing ./dist/ydk-models-openconfig-0.1.0.tar.gz
  Requirement already satisfied (use --upgrade to upgrade): ydk-models-openconfig==0.1.0 from file:///home/jason/tools/ydk-py/openconfig/dist/ydk-models-openconfig-0.1.0.tar.gz in /home/jason/.virtualenvs/ydkpy/lib/python2.7/site-packages/ydk_models_openconfig-0.1.0-py2.7.egg
Collecting ecdsa==0.13 (from ydk-models-openconfig==0.1.0)
  Using cached ecdsa-0.13-py2.py3-none-any.whl
Collecting enum34==1.1.3 (from ydk-models-openconfig==0.1.0)
  Using cached enum34-1.1.3-py2.py3-none-any.whl
Collecting lxml==3.4.4 (from ydk-models-openconfig==0.1.0)
  Using cached lxml-3.4.4.tar.gz
Collecting paramiko==1.15.2 (from ydk-models-openconfig==0.1.0)
  Using cached paramiko-1.15.2-py2.py3-none-any.whl
Collecting pyang==1.6 (from ydk-models-openconfig==0.1.0)
  Using cached pyang-1.6-py2.py3-none-any.whl
Collecting pycrypto==2.6.1 (from ydk-models-openconfig==0.1.0)
Collecting Twisted>=16.0.0 (from ydk-models-openconfig==0.1.0)
  Using cached Twisted-16.3.2.tar.bz2
Collecting protobuf==3.0.0b2.post2 (from ydk-models-openconfig==0.1.0)
  Using cached protobuf-3.0.0b2.post2-py2-none-any.whl
Collecting ncclient>=0.4.7 (from ydk-models-openconfig==0.1.0)
  Using cached ncclient-0.5.2.tar.gz
Collecting ydk>=0.5.0 (from ydk-models-openconfig==0.1.0)
  Could not find a version that satisfies the requirement ydk>=0.5.0 (from ydk-models-openconfig==0.1.0) (from versions: )
No matching distribution found for ydk>=0.5.0 (from ydk-models-openconfig==0.1.0)
(ydkpy) jason@ubuntu:openconfig (master)$ 

Shared Libraries Error while installing ydk

Hi,
While installing ydk through "pip install ydk", I am getting the following error:

/tmp/pip-install-5vc0wm56/ydk/python.cpp:541:39: warning: unused parameter ‘left’ [-Wunused-parameter]
             .def("__eq__", [](ydk::Empty& left, ydk::Empty& right)
                                           ^
    /tmp/pip-install-5vc0wm56/ydk/python.cpp:541:57: warning: unused parameter ‘right’ [-Wunused-parameter]
             .def("__eq__", [](ydk::Empty& left, ydk::Empty& right)
                                                             ^
    /tmp/pip-install-5vc0wm56/ydk/python.cpp:545:39: warning: unused parameter ‘left’ [-Wunused-parameter]
             .def("__ne__", [](ydk::Empty& left, ydk::Empty& right)
                                           ^
    /tmp/pip-install-5vc0wm56/ydk/python.cpp:545:57: warning: unused parameter ‘right’ [-Wunused-parameter]
             .def("__ne__", [](ydk::Empty& left, ydk::Empty& right)
                                                             ^
    [100%] Linking CXX shared module ../lib.linux-x86_64-3.6/ydk_.so
    /opt/rh/devtoolset-4/root/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/ld: /usr/local/lib/libpython3.6m.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libpython3.6m.a: error adding symbols: Bad value

Exception raised not all that helpful

I attempted what was, in some way, an invalid configuration operation, and received this exception:

Creating destination group...
Traceback (most recent call last):
  File "./ydk-mdt.py", line 313, in <module>
    prot=args.prot)
  File "./ydk-mdt.py", line 106, in xr_create_destination_group
    crud_service.create(session, dg)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/services/crud_service.py", line 56, in create
    self._execute_crud_operation_on_provider(provider, entity, 'CREATE', False)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/services/crud_service.py", line 145, in _execute_crud_operation_on_provider
    only_config
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/services/service.py", line 30, in execute_payload
    payload)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 91, in execute_operation
    return self._handle_rpc_reply(session_manager, payload, reply_str)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 112, in _handle_rpc_reply
    self._handle_rpc_ok(session_manager, payload, reply_str, separator)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 120, in _handle_rpc_ok
    self._handle_commit(session_manager, payload, reply_str, separator)
  File "/Users/einarnn/scratch/temp/ydk/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 133, in _handle_commit
    raise YPYError('Server reported an error while committing change!')
ydk.errors.YPYError: Server reported an error while committing change!

This is not a very helpful error. Looking into where the YPYError exception is raised:

    def _handle_commit(self, session_manager, payload, reply_str, separator):
        commit = session_manager.commit()
        if 'ok' not in commit.xml:
            self.netconf_sp_logger.error('%s\n%s\n%s\ncommit-reply\n%s\n%s', separator,
                                    payload, reply_str.xml, commit.xml, separator)
            raise YPYError('Server reported an error while committing change!')
        else:
            self.netconf_sp_logger.debug('%s\n%s\n%s\n\ncommit-reply\n%s\n%s', separator,
                                    payload, reply_str.xml, commit.xml, separator)

...we can see that, if enabled, logging will have better info, but the info needs to be present in the YPYError exception as well. In general, should examine the utility of the exceptions we re-raise as YDK exceptions that suppress the underlying exceptions and ensure that sufficient information is propagated to allow application developers to understand the error in a little more detail.

Probably also need to introduce enums, etc., for the YPYErrors to ensure developers don't start trying to parse the message strings we pass back.

Cheers,

Einar

Mac guidance

In the Mac/OSX guidance section, after recommending the install of Home Brew, you also need to recommend that brew is used to install Python:

brew install python

removing bgp asn with ydk-py

Trying to remove a BGP ASN with ydk-py using a crud.delete() method and it's saying an instance is already created (error coming from XR device).

Any examples you can share for updating / deleting router-id and ASN ?

Thanks,
Jason

Installing ydk-py on Ubuntu 19.04 disco

Hi, Python3 and Python3-pip installed successfully but when trying to install ydk-py using:

sudo -H pip3 install ydk-models-cisco-ios-xr

command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-l1f6352_/ydk/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-gwkg0f1j/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-l1f6352_/ydk/

Branching and versions

Hi

Are there any plans to create versioned releases and branches for ydk-py? This would help us baseline our environment for reproducibility and automated testing purposes.

Many thanks

Nathan

Problems in installing ydk-py in MacOS

I'm trying to install ydk-py in my machine, but unfortunately, It did not work. I followed every single instruction in here ydk-py installation guide and I have got the same error which is the following:

-- Build files have been written to: /tmp/pip-req-build-iLuIe4/build/temp.macosx-10.6-x86_64-2.7
    Scanning dependencies of target ydk_
    [ 50%] Building CXX object CMakeFiles/ydk_.dir/python.cpp.o
    /tmp/pip-req-build-iLuIe4/python.cpp:22:10: fatal error: 'ydk/path_api.hpp' file not found
    #include <ydk/path_api.hpp>
             ^~~~~~~~~~~~~~~~~~
    1 error generated.
    make[2]: *** [CMakeFiles/ydk_.dir/python.cpp.o] Error 1
    make[1]: *** [CMakeFiles/ydk_.dir/all] Error 2
    make: *** [all] Error 2
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-req-build-iLuIe4/setup.py", line 151, in <module>
        zip_safe=False,
      File "/Users/khalil/anaconda2/lib/python2.7/site-packages/setuptools/__init__.py", line 131, in setup
        return distutils.core.setup(**attrs)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/Users/khalil/anaconda2/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/Users/khalil/anaconda2/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/private/tmp/pip-req-build-iLuIe4/setup.py", line 74, in run
        self.build_extension(ext)
      File "/private/tmp/pip-req-build-iLuIe4/setup.py", line 107, in build_extension
        subprocess.check_call([cmake_executable, '--build', '.'], cwd=self.build_temp)
      File "/Users/khalil/anaconda2/lib/python2.7/subprocess.py", line 186, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '--build', '.']' returned non-zero exit status 2
    
    ----------------------------------------
Command "/Users/khalil/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-req-build-iLuIe4/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-o_eOQZ/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-req-build-iLuIe4/ 

Obviously the error is occured in 'ydk/path_api.hpp' where it is written that it is missed, but in fact, it is not. I double checked the folder /usr/local/include/ydk/ where the file path_api.hpp exists in there.

how to install the ydk environment offline

I want to install the ydk environment offline,so I installed the ydk in the virtual environment and run the code success, and then i copy the ydk packet to other environment ,and run the same code ,but get the error which is the following:

File "/sf/xz_remote1/code/netconf/drivers/huawei/CE6850/huawei_service.py", line 9, in from ydk.services import CodecService
File "/usr/lib/python2.7/site-packages/ydk/services/init.py", line 17, in from .codec_service import CodecService
File "/usr/lib/python2.7/site-packages/ydk/services/codec_service.py", line 21, in from ydk.entity_utils import get_data_node_from_entity as _get_data_node_from_entity
File "/usr/lib/python2.7/site-packages/ydk/entity_utils/init.py", line 17, in from ydk.ext.entity_utils import get_data_node_from_entity
File "/usr/lib/python2.7/site-packages/ydk/exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named ydk.ext.entity_utils

If this method is not right , what should I do to install ydk environment offline?

Read sample with pretty print

Hi

Is here a sample of a read operation with something equivalent to a pretty print of the configuration that has been read?

Many thanks

Nathan

client-side validation

So I was hoping to see better client side validation with the oc bgp model.

I first tried setting a bad ASN and that doesn't do a client side check, but it supports numbers way higher than the device supports, so it's deceiving.

I then tried a bad IP as a router id. But it's still making the request.

>>> bgp.global_.config.router_id = 'a300.1.1.1'
>>> crud.create(provider, bgp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 61, in create
    self._execute_crud_operation_on_provider(provider, entity, 'CREATE', False)
  File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 166, in _execute_crud_operation_on_provider
    operation
  File "/usr/local/lib/python2.7/dist-packages/ydk/services/service.py", line 37, in execute_payload
    reply = provider.execute(payload, operation)
  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/netconf_provider.py", line 90, in execute
    return self.sp_instance.execute_operation(payload, operation)
  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 224, in execute_operation
    return self._handle_rpc_reply(operation, payload, reply_str.xml)
  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 246, in _handle_rpc_reply
    self._handle_rpc_error(payload, reply_str, pathlist)
  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 262, in _handle_rpc_error
    raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_REJ, error_msg=reply_str)
ydk.errors.YPYServiceProviderError: Server rejected request.
        error-type: protocol
        error-tag: bad-element
        error-severity: error
        error-path: ns1:bgp/global/config/router-id
        bad-element: router-id

Is there anything that shows a better use case of client side validation with ydk-py using the oc bgp model?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.