yangcli-gw Getting Started

Install the Required Software

The 'yangcli-gw' program must be installed. This is available in binary form in the 'yumapro-sdk' package. To build from source code, then the WITH_ZEROMQ=1 make flag or EVERYTHING=1 make flag must be used.

The ZeroMQ development libraries of choice must be installed on your development machine. Refer to the ZeroMQ Getting Started page for details.

The 'yangcli-gw' program requires the libzmq library. The binary package is available on many platforms.

Example: Install libzmq3-dev on Ubuntu:

sudo apt-get install libzmq3-dev

Example: Install zeromq-devel on Fedora:

sudo dnf install zeromq-devel

Install Optional Software

The yangcli-gw-apps/ folder contains the Python3 example programs. These require the pyzmq library.

The binary package is available on many platforms. This can be installed on Ubuntu 22.04 as follows:

sudo apt-get install python3 python3-pip
[sudo] pip3 install pyzmq

Configure yangcli-gw Same As yangcli-pro

The yangcli-gw program uses the yangcli-pro configuration file at this time.

  • Any CLI parameter can be supplied on the command line instead of the configuration file.

  • The default configuration file is /etc/yumapro/yangcli-pro.conf

  • The --no-config parameter can be used on the command line to ignore the default configuration file, even if it is present.

  • The --config parameter can be used from the command line to use a different file specification.

  • All of the yangcli-pro CLI parameters are accepted and almost all parameters are relevant and applied in the program.

  • The --batch-mode parameter is forced to be present so no interactive commands are available in yangcli-gw.

  • There is no automatic Call Home Server configuration so this feature must be configured manually.

  • The yangcli-gw file locations used are relative to the starting directory and $HOME directory for the user starting the program.

  • Script file locations can be specified with the --runpath configuration parameter.

    • The default script file location is $HOME/scripts

  • Data file locations can be specified with the --datapath configuration parameter.

    • The default data file location is $HOME/data

Configure the ZMQAPI Parameters

There are some CLI parameters that are only supported by yangcli-gw, even though they are defined in the yangcli-pro YANG module.

The program can be used with the default values but the following parameters should be explicitly configured in most cases.

Parameter

Default

--zmqapi-gateway-id

gateway1

--zmqapi-responder-endpoint

tcp://127.0.0.1:5555

--zmqapi-publisher-endpoint

tcp://127.0.0.1:5556

Start the yangcli-gw Program

The yangcli-gw program can be run in the foreground or background.

  • It is not an interactive program like yangcli-pro.

  • The Control-C key sequence can be used to exit the program

  • The quit command received from a ZMQAPI client will cause yangcli-gw to quit

Example running with default parameters:

andy@andy-office-pc:~$ yangcli-gw

  yangcli-gw version 23.10T-0 (23.0.0-T)
  libssh2 version 1.10.0

  Copyright (c) 2008-2012, Andy Bierman, All Rights Reserved.
  Copyright (c) 2012-2023, YumaWorks, Inc., All Rights Reserved.

zmqapi: Bind to responder endpoint OK 'tcp://127.0.0.1:5555'
zmqapi: Bind to publisher endpoint OK 'tcp://127.0.0.1:5556'

Run Your Application And Connect to yangcli-gw

Using the example program 'pyclient2.py:

> python3 ./pyclient2.py

Connecting to ZMQAPI server…

Enter yangcli-gw command:

Get the Current Status

Send a 'dot' command to get the current status:

> python3 ./pyclient2.py

Connecting to ZMQAPI server…

Enter yangcli-gw command: .
Send header
ZMQAPI.1 REQ R2 client1 325efa6c-476c-11ee-9cdf-257b3af3daaa
Send command
.
Got 2 REP message parts
Received ZMQAPI header
ZMQAPI.1 REP R0 S0 gateway1 client1 325efa6c-476c-11ee-9cdf-257b3af3daaa
Received SESSION header
{"count":0,"sid":0,"name":"default","server":"","port":0,"user":""}

Enter yangcli-gw command:

Connect to a NETCONF Server

Use the connect command to start a session with a NETCONF server:

Enter yangcli-gw command: connect server=192.168.0.237 user=andy password=mypassword
Send header
ZMQAPI.1 REQ R2 client1 97b1ce3a-4771-11ee-9cdf-257b3af3daaa
Send command
connect server=192.168.0.237 user=andy password=mypassword
Got 4 REP message parts
Received ZMQAPI header
ZMQAPI.1 REP R2 S0 gateway1 client1 97b1ce3a-4771-11ee-9cdf-257b3af3daaa
Received SESSION header
{"count":1,"sid":1,"name":"default","server":"192.168.0.237","port":830,"user":"andy"}
Received response message
ok
Received log message

> connect server=192.168.0.237 user=andy password=mypassword

Send a Command

In this example, the sget command is used to retrieve the '/system' container from yuma-system.yang

Enter yangcli-gw command: sget /system
Send header
ZMQAPI.1 REQ R2 client1 52314a92-4772-11ee-9cdf-257b3af3daaa
Send command
sget /system
Got 4 REP message parts
Received ZMQAPI header
ZMQAPI.1 REP R2 S0 gateway1 client1 52314a92-4772-11ee-9cdf-257b3af3daaa
Received SESSION header
{"count":1,"sid":1,"name":"default","server":"192.168.0.237","port":830,"user":"andy"}
Received response message
{
  "rpc-reply": {
    "data": {
      "system": {
        "sysName":"localhost",
        "sysCurrentDateTime":"2023-08-30T20:18:02Z",
        "sysBootDateTime":"2023-08-30T20:17:15Z",
        "sysLogLevel":"debug4",
        "sysNetconfServerId":"netconfd-pro ocelot-t-andy-ypw-2054-zeromq-2023-08-28.13.18 (23.0.0-T)",
        "sysNetconfStartupSource":"startup",
        "sysNetconfStartupFilespec":"/home/andy/.yumapro/startup-cfg.xml",
        "sysNetconfStartupTxidFilespec":"/home/andy/.yumapro/startup-cfg-txid.txt",
        "sysNetconfServerCLI": {
          "access-control":"off",
          "config":"/home/andy/CONF/plain.conf",
          "log-level":"debug4",
          "no-watcher":[null],
          "with-yuma-system":"true"
        },
        "uname": {
          "sysname":"Linux",
          "release":"5.15.0-82-generic",
          "version":"#91-Ubuntu SMP Mon Aug 14 14:14:14 UTC 2023",
          "machine":"x86_64",
          "nodename":"andy-office-pc.localdomain"
        }
      }
    }
  }
}

Received log message

[email protected]> sget /system

RPC Data Reply 3 for session 3 [default]: