Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Configure gNOI Services

Configure the remote network management system as a gRPC client that can execute gNOI operations on network devices.

The gRPC Network Operations Interface (gNOI) uses the gRPC Remote Procedure Call (gRPC) framework to perform operations on a network device. The network management system must have the gRPC stack installed.

OpenConfig defines proto definition files for gNOI services. Proto definition files define the operations (RPCs) and the data structures (messages) for a given service. The definitions are language agnostic. gRPC supports using many different languages to execute service operations. You must compile the proto definition files for your language of choice. You then create applications that use the objects (classes, functions, methods, etc) in the compiled files to connect to the gRPC server on the network device and execute the desired operations.

For information about using gRPC with the different supported languages, consult the gRPC documentation. The following sections provide sample commands for setting up a gRPC client and downloading and compiling the gNOI proto definition files for Python. You must use the commands that are appropriate for your operating system, environment, and gRPC language of choice.

Before you configure the gRPC client, configure the gRPC server as defined in Configure gRPC Services.

Set up the gRPC Client

gNOI uses the gRPC framework to perform operations on a network device. gRPC supports using many different languages. Before you can perform gNOI operations using your language of choice, you must install the gRPC stack on the network management system.

For example, to install the gRPC stack for Python on a network management system running Ubuntu 20.04 LTS (use sudo where appropriate):

  1. Install pip for Python 3.
  2. Install the grpcio package for Python.
  3. Install the grpcio-tools package for Python.

Compile the Proto Definiton Files

gRPC supports using many languages. In order to perform gRPC operations on network devices, you must compile the respective proto definition files for your language of choice. OpenConfig provides the necessary proto definition files in the OpenConfig GitHub repository. You use the protocol buffer compiler (protoc or equivalent application) to compile the .proto files.

For this setup, we execute a script that copies all the desired .proto files into a directory, updates the files to use relative import statements, and then compiles the files.

To download and compile the gNOI proto definition files for Python:

  1. Create the temporary directory for the original source files.
  2. Clone the gNOI GitHub repository to the local device.
  3. Compile the .proto files for your language, which in this example is Python.

    The sample shell script performs the following operations:

    • Creates the src/proto directory.
    • Copies the desired proto files into the new directory.
    • Updates the import statement in each proto file to use a relative path.
    • Compiles each proto file in the specified list for use with Python.

    To compile the files using the script, execute the script from the parent directory that contains the src directory.

    Note:

    The script compiles only the subset of proto files (as defined in gnoiFileList) that have services supported on Junos devices. To compile other services as they become available, you can update the variables to include those services.

  4. Verify that the proto files are compiled by viewing the output files in the target directory.

    The file list should include the compiled files, which for Python have _pb2 and pb2_grpc in the output filenames.

Create gNOI Applications

After you compile the proto definition files, you create applications that use the objects in the compiled files. The applications connect to the gRPC server on the network device and perform the desired operations. This section provides two sample Python modules, which are described in their respective sections.

grpc_channel.py

The grpc_channel.py Python module provides sample functions that create a gRPC channel using the arguments provided for the selected method of authentication, server-only or mutual.

gnoi_connect_cert_auth_mutual.py

The gnoi_connect_cert_auth_mutual.py Python application establishes a gRPC channel with the given gRPC server and executes a simple gNOI System service operation. The user provides the necessary connection and mutual authentication information as input to the application. The application invokes the appropriate function in the grpc_channel.py module to establish the gRPC channel between the client and the server. If the application successfully establishes a gRPC channel, it then executes a simple system service RPC to retrieve the time from the network device.

Execute the Application

After you create applications to perform gNOI service operations, you execute the applications and provide any necessary arguments. The following example uses the scripts provided in the previous section to connect to the gRPC server on the network device and request the time. The gRPC server is configured to require and verify the client's certificate.

  • For mutual authentication, the client provides their own key and X.509 public key certificate in PEM format in addition to the server's IP address, gRPC port, and root CA certificate. The client also provides the credentials for RPC calls: the user_id argument supplies the username, and the application prompts for the user password.