개발 Dev/NETCONF, YANG

[NETCONF/YANG] # 00. How to install Sysrepo, Netopeer2 for developing YANG and NETCONF

BoBooBoo 2021. 6. 10. 20:00
반응형

* This article was written on June 8, 2021.


1. Environment

OS, Opensource for YANG and NETCONF


2. Install the necessary tools, libraries, ...

Install packages required for developement or have dependencies with Sysrepo and Netopeer.

sudo apt autoclean 
sudo apt update --fix-missing && sudo apt upgrade -y
sudo apt install -y gcc g++ make cmake git clang vim \
                    libpcre2-dev doxygen graphviz cmocka-doc \ 
                    libcmocka-dev bison flex pkg-config devscripts \
                    rpm debhelper valgrind expect shunit2

 

Build Requirement

  • C compiler
  • cmake >= 2.8.12
  • libpcre2 >= 10.21 (including devel package)
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
...

$ cmake --version
cmake version 3.10.2

$ pcre2-config --version
10.31

 

[optional] Install package for development on vscode for c++, yang and netconf

# ifconfig ...
sudo apt install -y net-tools

# boost library for c++
sudo apt install -y libboost-dev libboost-doc libboost-tools-dev

# for remote ssh connection
sudo apt install -y openssh-server openssh-client 
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# for visual studio code YANG extension
sudo apt install -y openjdk-8-jdk

3. Compile and Build the opensource for YANG and NETCONF

Because of library dependencies, you neet to build the source code in the following order.

(1) libyang (https://github.com/CESNET/libyang)
(2) sysrepo (https://github.com/sysrepo/sysrepo)
(3) libnetconf2 (https://github.com/CESNET/libnetconf2)
(4) netopeer2 (https://github.com/CESNET/netopeer2)

 

3.1 set the workspace

All source codes are installed in ~/workspace

cd ~
mkdir workspace && cd workspace

 

3.2 [optional] Install Uncrusfy

# ~/workspace
git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify; mkdir build && cd build

# ~/workspace/uncrustify/build
cmake .. && make && sudo make install

Check if uncrustify was installed properly.

$ uncrustify -v
Uncrustify_d-0.73.0-26-d00895aa

 

3.3 Install Libyang

cd ~/workspace

# ~/workspace
git clone https://github.com/CESNET/libyang.git
cd libyang; mkdir build && cd build

# ~/workspace/libyang/build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make && sudo make install

 

3.4 Install Sysrepo

libyang must be installed first.

cd ~/workspace

# ~/workspace
git clone https://github.com/CESNET/libyang.git
cd sysrepo; mkdir build && cd build

# ~/workspace/sysrepo/build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make && sudo make install

Check if sysrepo was installed properly.

$ sysrepoctl --version
sysrepoctl - sysrepo YANG schema manipulation tool, compiled with libsysrepo v2.0.1 (SO v6.0.1)

 

3.5 Install Libnetconf2

To install Libnetconf2, you need version 0.7.1 or higher of LIBSSH and openssl

 

openssl

# Install libssl (for openssl)
sudo apt install -y libssl-dev libssl-doc

 

libssh (>= 0.7.1)

# install zlib1g-dev
sudo apt install -y zlib1g-dev

cd ~/workspace

# ~/workspace
git clone http://git.libssh.org/projects/libssh.git
cd libssh; mkdir build; cd build

# ~/workspace/libssh/build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make; sudo make install

 

libnetconf2

cd ~/workspace

# ~/workspace
git clone https://github.com/CESNET/libnetconf2.git
cd libnetconf2; mkdir build; cd build

# ~/workspace/libnetconf2/build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make; sudo make install

 

3.6 Install Netopeer2

cd ~/workspace

# ~/workspace
git clone https://github.com/CESNET/netopeer2.git
cd netopeer2; mkdir build; cd build

# ~/workspace/netopeer2/build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make; sudo make install

Check if Netopeer2 was installed properly.
You can Use the command netopeer2-server -h and netopeer2-cli.

$ netopeer2-server -h
Usage: netopeer2-server [-dhV] [-p path] [-U (path)] [-m mode] [-u uid] [-g gid] [-t timeout] [-v level] [-c category]
 -d         debug mode (do not daemonize and print verbose messages to stderr instead of syslog)
 -h         display help
 -V         show program version
 -p path    path to pidfile (default path is "/var/run/netopeer2-server.pid")
 -U[path]   listen on a local UNIX socket (default path is "/var/run/netopeer2-server.sock")
 -m mode    set mode for the listening UNIX socket
 -u uid     set UID/user for the listening UNIX socket
 -g gid     set GID/group for the listening UNIX socket
 -t timeout timeout in seconds of all sysrepo functions (applying edit-config, reading data, ...),
            if 0 (default), the default sysrepo timeouts are used
 -v level   verbose output level:
                0 - errors
                1 - errors and warnings
                2 - errors, warnings, and verbose messages
 -c category[,category]*
            verbose debug level, print only these debug message categories
            categories: DICT, YANG, YIN, XPATH, DIFF, MSG, LN2DBG, SSH, SYSREPO

$ netopeer2-cli 
get_netconf_dir: Configuration directory "/home/u18-sysrepo2/.netopeer2-cli" did not exist, created.
load_config: No saved history.
load_config: No saved configuration.
> help
Available commands:
  auth            Manage SSH authentication options
  knownhosts      Manage the user knownhosts file
  cert            Manage trusted or your own certificates
  crl             Manage Certificate Revocation List directory
  outputformat    Set the output format of all the data
  searchpath      Set the search path for models
  verb            Change verbosity
  version         Print Netopeer2 CLI version
...
...

THE END.

반응형