go/

directory
v0.0.0-...-b5e1584 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0

README

Build Status GoDoc Docker Automated build

ydk-logo-128

YANG Development Kit (Go)

Table of Contents

Overview

YDK is a developer tool that allows generate YANG model API's in multiple languages and provides services to apply generated API over multiple communication protocols. Currently supported languages are: Python, Go and C++. Currently implemented protocols are: Netconf, Restconf, OpenDaylight and gNMI. YDK provides CRUD and protocol specific service over above protocols. YDK also provides Codec service to translate API models to/from XML and JSON encoded strings.

Backward Compatibility

The Go generated API starting from YDK-0.7.3 is fully compatible with YDK-0.9.0.

NOTE. Starting from release 0.8.5 the YDK does not support Python2 interpreter as it was deprecated.

Docker

Currently the docker image for ydk-go is not been generated. Please use docker image below, which has complete environment for ydk-go based development.

The docker image is automatically built with the latest ydk-gen commit to git repository. The docker image is used to run YDK based apps 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 ydksolutions/ydk-gen:0.8.6.6

System Requirements

The YDK is currently supported on the following platforms including native installations, virtual machines, and docker images:

  • Linux Ubuntu Xenial (16.04 LTS), Bionic (18.04 LTS), Focal (20.04 LTS), Jammy (22.04 LTS) and Noble (24.04 LTS)
  • Linux CentOS versions 7 and Centos Stream 8 (Centos 8.x has been EOL as of December 31 of 2021)
  • Linux RHEL version 7.x and 8.x
  • MacOS up to 11.7.2 (Big Sur)

On Windows 10 the Linux virtual machine can run using Windows Subsystem for Linux (WSL); check this for virtual machine installation procedure. The YDK has been tested in such environment on Ubuntu Bionic (18.04 LTS) and Focal (20.04 LTS) images obtained from Microsoft Store.

On supported platforms the YDK can be installed using installation script. On other platforms the YDK should be installed manually from source. For both the methods the user must install git package prior to the installation procedure.

All YDK core components are based on C and C++ code. These components compiled using default compilers for the supported platform. Corresponding binaries, libraries, and header files are installed in default locations, which are /usr/local/bin, /usr/local/lib, and /usr/local/include. The user must have sudo access in order to install YDK core components to these locations. Make sure the sudo package is installed on your platform prior to the YDK installation procedure.

Core Installation

Installation script

For YDK installation it is recommended to use script install_ydk.sh from ydk-gen git repository. The script detects platform OS, installs all the dependencies and builds complete set of YDK components for specified language. The user must have sudo access to these locations.

The YDK extensively uses Python scripts for building its components and model API packages (bundles). In order to isolate YDK Python environment from system installation, the script can build Python3 virtual environment. If built, the user must manually activate virtual environment when generating model bundles and/or running YDK based application. By default the Python virtual environment is installed under $HOME/venv directory. For different location the PYTHON_VENV environment variable should be set to that location.

NOTE. It is strongly recommended to use Python virtual environment on Centos/RHEL and Mac platforms.

When installing YDK for Go programming language, the third party dependencies and C++ packages must be installed first. These steps require sudo/root access to the installation platform. Here is simple example of core YDK installation for Go programming language and Python virtual environment:

git clone https://github.com/CiscoDevNet/ydk-gen.git
cd ydk-gen
export YDKGEN_HOME=`pwd`  # optional
export PYTHON_VENV=$HOME/ydk_vne  # optional
./install_ydk.sh --cpp --core --venv
./install_ydk.sh --go --core --venv

The script also allows to install individual components like dependencies, core, and service packages for specified programming language or for all supported languages. Full set of script capabilities could be viewed like this:

./install_ydk.sh --help
usage: install_ydk [ {--cpp|--py|--go|--all} ] [-c] [-s gnmi] [-h] [-n] [-v]
Options and arguments:
  --cpp                 install YDK for C++ programming language;
                        requires sudo access for dependencies and libraries installation
  --go                  install YDK for Go programming language
  --py|--python         install YDK for Python programming language
  --all                 install YDK for all available programming languages;
                        requires sudo access for dependencies and libraries installation
  -v|--venv             create python virtual environment
  -c|--core             install YDK core package
  -s|--service gnmi     install gNMI service package
  -n|--no-deps          skip installation of dependencies;
                        applicable only with --cpp and --all options
  -h|--help             print this help message and exit

Environment variables:
YDKGEN_HOME         specifies location of ydk-gen git repository;
                    if not set, $HOME/ydk-gen is assumed
PYTHON_VENV         specifies location of python virtual environment;
                    if not set, $HOME/venv is assumed
GOROOT              specifies installation directory of go software;
                    if not set, /usr/local/go is assumed
GOPATH              specifies location of go source directory;
                    if not set, $HOME/go is assumed
C_INCLUDE_PATH      location of C include files;
                    if not set, /usr/local/include is assumed
CPLUS_INCLUDE_PATH  location of C++ include files;
                    if not set, /usr/local/include is assumed
CMAKE_LIBRARY_PATH  Location of Python shared libraries;
                    if not set, default system library location is assumed

If user environment is different from the default one (different Python installation or different location of libraries) then building from source method should be used.

Building from source
Environment variables

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

When non-standard Python installation is used or there are multiple installations of Python on the platform, the PATH and CMAKE_LIBRARY_PATH environment variables must be set accordingly in order for the installation scripts to pick up correct Python binaries and shared libraries.

Installing third party dependencies

If user platform is supported one, it is recommended to use ydk-gen/install_ydk.sh script. The script will also install Python virtual environment in default or specified location, when '--venv' is specified.

# Clone ydk-gen from GitHub
git clone https://github.com/CiscoDevNet/ydk-gen.git
cd ydk-gen

# Define optional environment variables and install dependencies
export YDKGEN_HOME=`pwd`  
export PYTHON_VENV=$HOME/ydk_venv
./install_ydk.sh

For unsupported platforms it is recommended to follow logic of ydk-gen/test/dependencies-* scripts.

Installing core components

Please follow this procedure to install YDK core components for Go apps development:

# If created, activate Python virtual environment
source $PYTHON_VENV/bin/activate

# Generate and install YDK core library
python3 generate.py -is --core --cpp

# Generate and install YDK-Go core package
python3 generate.py -i --core --go

Adding gNMI Service

In order to enable YDK support for gNMI protocol, which is optional, the user need install third party software and YDK gNMI service package.

gNMI service installation

Here is simple example how gNMI service package for Go programming language and Python virtual environment could be added:

cd ydk-gen
./install_ydk.sh --cpp --service gnmi --venv  # requires sudo access
./install_ydk.sh --go --service gnmi --venv
Runtime environment

There is an open issue with gRPC on Centos/RHEL, 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:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib64

Documentation and Support

Release Notes

The current YDK release version is 0.8.6.6.

YDK is licensed under the Apache 2.0 License.

Directories

Path Synopsis
core
samples/bgp_codec_decode_encode
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/bgp_codec_encode
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/bgp_create
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/bgp_delete
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/bgp_read
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/cgo_path
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/aaa_lib_cfg/cd_encode_10
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/aaa_lib_cfg/cd_encode_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/aaa_lib_cfg/cd_encode_22
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/cdp_cfg/cd_encode_10
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/cdp_cfg/cd_encode_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/cdp_cfg/cd_encode_22
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/cdp_cfg/cd_encode_24
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_10
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_21
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_30
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_31
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_32
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_33
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_34
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_35
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_40
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_41
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_52
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_53
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_54
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_55
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_56
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_57
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_58
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_59
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/codec/cisco_ios_xr/clns_isis_cfg/cd_encode_60
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xe/native/interface_30
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xr/ifmgr_cfg/nc_create_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xr/infra_infra_clock_linux_cfg/nc_create_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xr/policy_repository_cfg/nc_create_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xr/shellutil_filesystem_oper/nc_read_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/crud/cisco_ios_xr/shellutil_oper/nc_read_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/executor/cisco_ios_xr/cfgmgr_rollback_act/nc_execute_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/executor/cisco_ios_xr/ping_act/nc_execute_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/executor/cisco_ios_xr/snmp_test_trap_act/nc_execute_200
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/executor/cisco_ios_xr/syslog_act/nc_execute_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/netconf/cisco_ios_xr/infra_infra_locale_cfg/nc_edit_20
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/netconf/cisco_ios_xr/infra_infra_locale_cfg/nc_edit_22
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/netconf/cisco_ios_xr/infra_infra_locale_cfg/nc_edit_24
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/netconf/cisco_ios_xr/infra_infra_locale_cfg/nc_edit_26
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
samples/netconf/cisco_ios_xr/infra_infra_locale_cfg/nc_edit_28
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
* ------------------------------------------------------------------ * YANG Development Kit * Copyright 2017 Cisco Systems.
ydk
Package ydk provides support for usage of Go API including path, providers, services, and types.
Package ydk provides support for usage of Go API including path, providers, services, and types.
ydk/services
Package services implements support for Go services.
Package services implements support for Go services.
ydk/types/datastore
Package datastore provides support for the DataStore type.
Package datastore provides support for the DataStore type.
ydk/types/encoding_format
Package encodingformat provides support for the EncodingFormat type.
Package encodingformat provides support for the EncodingFormat type.
ydk/types/protocol
Package protocol provides support for the Protocol type.
Package protocol provides support for the Protocol type.
ydk/types/yfilter
Package yfilter can be used to include the various operations supported in the Netconf protocol’s edit-config RPC in your YDK app.
Package yfilter can be used to include the various operations supported in the Netconf protocol’s edit-config RPC in your YDK app.
ydk/types/ylist
Package types provides built-in types specified in YANG RFC 6020 and types used in YDK Go APIs.
Package types provides built-in types specified in YANG RFC 6020 and types used in YDK Go APIs.
ydk/types/ytype
Package ytype provides support for YANG builtin types.
Package ytype provides support for YANG builtin types.
gnmi
ydk/path
Package providers implements support for Go service providers.
Package providers implements support for Go service providers.
ydk/providers
Package providers implements support for Go service providers.
Package providers implements support for Go service providers.
ydk/services
Package services implements support for Go services.
Package services implements support for Go services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL