ypgnmi-app Usage

The following sections describe the steps to run and test ypgnmi-app application.

Running Ypgnmi-app

Run the server with the setting --with-gnmi=true flag as follows:

mydir> netconfd-pro --log-level=debug4 --with-gnmi=true

Start the ypgnmi-app application. Note that you have to provide your certificates to start the application:

mydir> ypgnmi-app -cert ~/certs/server.crt -ca ~/certs/ca.crt -key ~/certs/server.key -log-level=debug

Note

Use -fileloc-fhs flag if you started the netconfd-pro server in privileged mode

After this step, the gNMI server starts to listen for any gNMI client requests and will process the requests to the netconfd-pro server and will transfer all the replies back.

Running gNMI Client Applications

The gRPC Network Management/Operations Interface Tools (gNXI Tools) provides basic applications to connect to the server and can be used to test the system. Install the gNXI Tools using the 'go get' and 'go install' tools.

mydir> go get github.com/google/gnxi/gnmi_get
mydir> go install github.com/google/gnxi/gnmi_get
mydir> go get github.com/google/gnxi/gnmi_capabilities
mydir> go install github.com/google/gnxi/gnmi_capabilities
mydir> go get github.com/google/gnxi/gnmi_set
mydir> go install github.com/google/gnxi/gnmi_set

Running CAPABILITY Request

The gNMI CAPABILITY request allows you to query a gNMI-enabled device for its capabilities. Capabilities can include information about the device like the gNMI version it supports, the data models it uses, and additional vendor-specific information.

Pre-requisites

Make sure you have a running ypgnmi-app and netconfd-pro to interact with. gNMI client software installed on your machine (you can use open-source clients like (gnmi_capabilities) or develop your client).

Procedure

  • Connected ypgnmi-app to the netconfd-pro server

  • Run the Capability Request: Use the gNMI client's capability command to request capabilities from the server.

mydir> gnmi_capabilities \
  --target_addr 127.0.0.1:10161  \
  --target_name restconf \
  --ca ~/certs/ca.crt \
  --key ~/certs/client.key \
  --cert ~/certs/client.crt

Alternatively, if you're using a custom client, make sure to invoke the Capability method provided by the gNMI gRPC service.

Sample Output

The gNMI server will respond with a list of its capabilities. This could include information such as supported data models, gNMI versions, and any additional vendor-specific capabilities.

Here is a simplified example of what the output might look like:

gNMI version: 0.7.0
supported models:
- name: openconfig-interfaces
   version: "1.0.0"
- name: openconfig-system
   version: "1.0.0"

Troubleshooting

  • Connection Errors: If you can't establish a connection, double-check your server address and port. Also, ensure that the server is running and accessible from your client machine.

  • Unsupported Capabilities: If the server does not list a capability you expected, it's possible that the particular version of the gNMI server you're interacting with does not support that capability.

Further Reading

For more details about gNMI and the Capability request, you can consult the (official gNMI specification).

Running GET Request

The gNMI GET request allows you to query the state information from a gNMI-enabled device. You can use this request to fetch data, whether it's operational data, configuration data, or any other data that the device exposes through gNMI.

Pre-requisites

Make sure you have a running ypgnmi-app and netconfd-pro to interact with. gNMI client software installed on your machine. You can use open-source clients like (gnmi_get), or you might have your custom client.

Procedure

  • Connected ypgnmi-app to the netconfd-pro server

  • Run the Get Request: Use the gNMI client's get command to request capabilities from the server.

mydir> gnmi_get \
  --target_addr 127.0.0.1:10161 \
  --target_name restconf \
  --ca ~/certs/ca.crt \
  --key ~/certs/client.key \
  --cert ~/certs/client.crt \
  --xpath "/uint16.1"

If you're using a custom client, you will need to call the Get RPC method of the gNMI service.

XPath parameter values are just sample paths of the nodes. Use real paths that represent real nodes in YANG modules that are loaded into the netconfd-pro server.

Set the '--xpath' parameter to a real node to retrieve.

Sample Output

After you issue the GET request, the server will respond with the data associated with the path you queried. This can include configuration values, operational statistics, or other data depending on what you requested.

Here's a simplified example output:

== GetResponse:
notification: <
   timestamp: 1697157269962932559
   update: <
      path: <
         elem: <
            name: "uint16.1"
         >
      >
      val: <
         json_ietf_val: "42"
      >
   >
>

Troubleshooting

  • Path Errors: If you get an error regarding the path, double-check your syntax. Make sure the path you specified is correct and supported by the server.

  • Data Unavailable: If the server responds that the data is unavailable, it's possible that the path you're querying does not exist or is not supported.

Further Reading

For more details about gNMI and the Capability request, you can consult the (official gNMI specification).

Running SET Request

The gNMI SET request is used to modify the configuration or state of a gNMI-enabled network device. With a SET request, you can update, replace, or delete specific data elements on the device.

Pre-requisites

Make sure you have a running ypgnmi-app and netconfd-pro to interact with. gNMI client software installed on your machine. You can use open-source clients like (gnmi_set), or you might have your custom client.

Procedure

  • Connected ypgnmi-app to the netconfd-pro server

  • Run the Set Request: Use the gNMI client's set command to request capabilities from the server.

mydir> gnmi_set \
  --target_addr localhost:10161 \
  --target_name restconf \
  --ca ~/certs/ca.crt \
  --key ~/certs/client.key \
  --cert ~/certs/client.crt \
  --delete /system/openflow/agent/config/max-backoff \
  --delete /system/openflow/agent/config/max-backoff2 \
  --replace /system/clock:@/mydir/clock-config.json \
  --update /system/clock/config/timezone-name:@/mydir/clock-config2.json

XPath parameter values are just sample paths of the nodes. Use your real paths that represent your real nodes in YANG modules that you loaded into the netconfd-pro server. Set the --delete, --update, --replace parameter paths with real nodes that you want to edit.

The clock-config.json input file to replace container “clock” might look as follows.

{
  "clock": {
    "timezone-name": "Europe/Stockholm"
  }
}

The clock-config2.json input file to update a lead “timezone-name” might look as follows:

{
    "timezone-name": "ETZ"
}

In addition, you may use the following gNMI client for sending SET requests.

Refer to OpenConfig gNMI for more details.

To run gNMI requests using the following client, for example, SET and Subscribe request:

mydir> gnmi_cli \
  --address localhost:10161 \
  --server_name restconf \
  --ca_crt ~/certs/ca.crt \
  --client_crt ~/certs/client.crt \
  --client_key ~/certs/client.key \
  --set --delete="/person"

In a custom client, you'd make a call to the Set RPC method provided by the gNMI service.

Sample Output

After running the SET request, you should get a response from the server indicating whether the operation was successful.

Here's a simplified example output:

response: <
   path: <
      elem: < name: "interfaces" >
      elem: <name: "interface" key: <key: "name" value: "eth0" > >
      elem: <name: "config" >
      elem: <name: "enabled" > >
   op: UPDATE
>

Troubleshooting

  • Path Errors: Double-check your path and syntax if you get a path-related error.

  • Operation Failure: If the SET operation fails, the error message should give you clues about what went wrong. This could be due to permission issues, unsupported data paths, or incorrect values.

Further Reading

For an in-depth look at the SET request in gNMI, check out the (official gNMI specification).

Running SUBSCRIBE Request

The gNMI SUBSCRIBE request is a powerful feature that allows you to subscribe to changes or updates on a network device. The SUBSCRIBE request can work in three different modes: ONCE, STREAM, and POLL.

Pre-requisites

Make sure you have a running ypgnmi-app and netconfd-pro to interact with. gNMI client software on your machine, which could be an open-source option like (gnmi-cli), (gnmi_subscribe), or a custom client that you've developed.

Procedure

  • Connected ypgnmi-app to the netconfd-pro server

  • Initiate the SUBSCRIBE Request: You'll need to specify the data path you're interested in the subscription mode (ONCE, STREAM, or POLL).

ONCE Subscription Mode

A subscription operating in the ONCE mode acts as a single request/response channel. The target creates the relevant update messages, transmits them, and subsequently closes the RPC.

To create a one-off subscription, a client sends a SubscribeRequest message to the target. The subscribe field within this message specifies a SubscriptionList with the mode field set to ONCE.

mydir> gnmi_cli \
  --address localhost:10161 \
  --server_name restconf \
  --ca_crt ~/certs/ca.crt \
  --client_crt ~/certs/client.crt \
  --client_key ~/certs/client.key \
  --query_type once \
  --query "/uint32.1"

mydir> gnmi_subscribe -xpath "/uint32.1" \
  -target_addr localhost:10161 \
  -target_name restconf \
  -ca ~/certs/ca.crt \
  -key ~/certs/client.key \
  -cert ~/certs/client.crt \
  -once

If you're using a custom client, you'll need to use the Subscribe RPC method provided by the gNMI service.

Sample Output

In an ONCE subscription mode, you should get updates based on poll requests. Here's an example of what output might look like for an ONCE mode subscription:

update: <
   timestamp: 1696531421174724264
   update: <
      path: <
         elem: <
         name: "uint32.1"
         >
      >
      val: <
         json_ietf_val: "8"
      >
   >
>

Troubleshooting

  • Subscription Errors: If you encounter an error while setting up the subscription, double-check your syntax, the data path, and the subscription mode.

  • No Data: If you don't receive any data, make sure the path you've subscribed to has data and that you have the necessary permissions to access it.

Further Reading

To delve deeper into the details and capabilities of the SUBSCRIBE request, refer to the (official gNMI specification).

POLL Subscription Mode

Polling subscriptions are used for on-demand retrieval of data items via long-lived RPCs. A poll subscription relates to a certain set of subscribed paths and is initiated by sending a SubscribeRequest message with encapsulated SubscriptionList.

Subscription messages contained within the SubscriptionList indicate the set of paths that are of interest to the polling client.

To retrieve data from the target, a client sends a SubscribeRequest message to the target, containing a poll field, specified to be an empty Poll message. On reception of such a message, the target MUST generate updates for all the corresponding paths within the SubscriptionList

mydir> gnmi_cli \
  --address localhost:10161 \
  --server_name restconf \
  --ca_crt ~/certs/ca.crt \
  --client_crt ~/certs/client.crt \
  --client_key ~/certs/client.key \
  --query_type polling \
  --polling_interval 5s \
  --query "/uint32.1"

mydir> gnmi_subscribe -xpath "/uint32.1" \
  -target_addr localhost:10161 \
  -target_name restconf \
  -ca ~/certs/ca.crt \
  -key ~/certs/client.key \
  -cert ~/certs/client.crt \
  -poll

Sample Output

In a POLL subscription mode, you should get updates based on poll requests. Here's an example of what output might look like for a POLL mode subscription:

==>
update: <
   timestamp: 1696531726554114879
   update: <
      path: <
         elem: <
         name: "uint32.1"
         >
      >
      val: <
         json_ietf_val: "8"
      >
   >
>

I1005 11:48:54.054178 1032368 gnmi_subscribe.go:215] SyncResponse received
I1005 11:48:54.054186 1032368 gnmi_subscribe.go:149] Press enter to poll

==>
update: <
   timestamp: 1696531734057750162
   update: <
      path: <
         elem: <
         name: "uint32.1"
         >
      >
      val: <
         json_ietf_val: "8"
      >
   >
>

I1005 11:51:26.979750 1032368 gnmi_subscribe.go:215] SyncResponse received
I1005 11:51:26.979760 1032368 gnmi_subscribe.go:149] Press enter to poll
...

Troubleshooting

  • Subscription Errors: If you encounter an error while setting up the subscription, double-check your syntax, the data path, and the subscription mode.

  • No Data: If you don't receive any data, make sure the path you've subscribed to has data and that you have the necessary permissions to access it.

Further Reading

To delve deeper into the details and capabilities of the SUBSCRIBE request, refer to the (official gNMI specification).

STREAM Subscription Mode

Stream subscriptions are long-lived subscriptions that continue to transmit updates relating to the set of paths that are covered within the subscription indefinitely.

Each entry within the Subscription message is specified with one of the following modes:

  • Sampled (SAMPLE) - a subscription that is defined to be sampled MUST be specified along with a sample_interval encoded as an unsigned 64-bit integer representing nanoseconds between samples. The default minimum Sample Interval is 5 sec.

    • Optionally, the suppress_redundant field of the Subscription message may be set for a sampled subscription.

    • A heartbeat_interval MAY be specified to modify the behavior of suppress_redundant in a sampled subscription.

  • On Change (ON_CHANGE) - when a subscription is defined to be "on change", data updates are only sent when the value of the data item changes. A heartbeat interval MAY be specified along with an "on change" subscription.

  • Target Defined (TARGET_DEFINED) - when a client creates a subscription specifying the target-defined mode, the target MUST determine the best type of subscription to be created on a per-leaf basis.

Sampled STREAM Subscription

A Sampled STREAM subscription is created by sending a SubscribeRequest message with the subscribe field containing a SubscriptionList message with the type specified as STREAM. Here is an example of a Sampled STREAM Subscription with 10 seconds Sample Interval configurations:

mydir> gnmi_subscribe -xpath "/uint16.1" \
  -target_addr localhost:10161 \
  -target_name restconf \
  -ca ~/certs/ca.crt \
  -key ~/certs/client.key \
  -cert ~/certs/client.crt \
  -sample_interval 10000000000

Sample Output

In a Sampled STREAM subscription mode, you should get updates based on Sample Interval. Here's an example of what output might look like for a Sampled STREAM subscription:

==>
update: <
   timestamp: 1697152098950903329
   update: <
      path: <
         elem: <
            name: "uint16.1"
         >
      >
      val: <
         json_ietf_val: "42"
      >
   >
>

I1012 16:08:18.951239   36913 gnmi_subscribe.go:215] SyncResponse received
==>
update: <
timestamp: 1697152108963226989
   update: <
      path: <
         elem: <
            name: "uint16.1"
         >
      >
      val: <
         json_ietf_val: "42"
      >
   >
>

I1012 16:08:28.963452   36913 gnmi_subscribe.go:215] SyncResponse received
...

Optionally, the suppress_redundant field of the Subscription message may be set for a sampled subscription. In the case that it is set to true, the server will not generate a telemetry update message unless the value of the path being reported has changed since the last update was generated.

mydir> gnmi_subscribe -xpath "/uint16.1" \
  -target_addr localhost:10161 \
  -target_name restconf \
  -ca ~/certs/ca.crt \
  -key ~/certs/client.key \
  -cert ~/certs/client.crt \
  -sample_interval 10000000000
  -suppress_redundant

Note

By default, the server will not enforce Suppression. In addition, if the suppress_redundant filed is used and the heartbeat_interval is not set, then the heartbeat_interval will be set automatically to the default value of 30 seconds.

Troubleshooting

  • Subscription Errors: If you encounter an error while setting up the subscription, double-check your syntax, the data path, and the subscription mode. If one or more subscribed paths is syntactically incorrect UNIMPLEMENTED error will be reported.

  • No Data: Subscribed paths are syntactically correct but one or more paths neither exist (yet) nor have a YANG default value in use. Nothing is sent for non-existent paths (yet), RPC is not closed.

Further Reading

To delve deeper into the details and capabilities of the SUBSCRIBE request, refer to the (official gNMI specification).

On Change STREAM Subscription

The gNMI SUBSCRIBE request with "On-Change" STREAM mode allows you to establish a long-lived streaming connection between the client and the server. Unlike the traditional STREAM mode where updates are sent periodically, the "On-Change" mode sends updates only when the subscribed data changes.

To retrieve data from the target, a client sends a SubscribeRequest message to the target with the STREAM mode set to "On-Change".

In the following example, the client subscribes to an "On-Change" STREAM with a heartbeat_interval interval set to 100 seconds:

mydir> gnmi_subscribe -xpath "/uint16.1" \
  -target_addr localhost:10161 \
  -target_name restconf \
  -ca ~/certs/ca.crt \
  -key ~/certs/client.key \
  -cert ~/certs/client.crt \
  -stream_on_change \
  -heartbeat_interval 100000000000

Sample Output

The server sends updates to the client only when there are changes to the subscribed data paths. This is in contrast to the "Sampled" STREAM mode, where updates are sent at regular intervals regardless of whether the data has changed.

When you subscribe with "On-Change", the server will not send any data initially unless the value at the subscribed path changes. Once a change occurs, you'll get an update.

Here's a sample output you might see:

==>
update: <
   timestamp: 1697500643566301311
   update: <
      path: <
         elem: <
            name: "uint16.1"
         >
      >
      val: <
         json_ietf_val: "13"
      >
   >
>

I1016 16:57:23.566638  247304 gnmi_subscribe.go:215] SyncResponse received
I1016 16:57:28.573071  247304 gnmi_subscribe.go:215] SyncResponse received
==>
update: <
   timestamp: 1697500703638696004
   update: <
      path: <
         elem: <
            name: "uint16.1"
         >
      >
      val: <
         json_ietf_val: "8"
      >
   >
>

Optionally, a heartbeat_interval may be specified along with an "on change" subscription - in this case, the value of the data item(s) will be re-sent once per heartbeat interval regardless of whether the value has changed or not.

Troubleshooting

  • Subscription Errors: If you encounter an error while setting up the subscription, double-check your syntax, the data path, and the subscription mode. If one or more subscribed paths is syntactically incorrect UNIMPLEMENTED error will be reported.

  • No Data: Subscribed paths are syntactically correct but one or more paths neither exist (yet) nor have a YANG default value in use. Nothing is sent for non-existent paths (yet), RPC is not closed.

Further Reading

To delve deeper into the details and capabilities of the SUBSCRIBE request, refer to the (official gNMI specification).

Closing ypgnmi-app

The ypgnmi-app can be shut down by typing Ctrl-C in the window that started the application.

If the netconfd-pro server is not running when ypgnmi-app is started the application will terminate with an error message stating that the netconfd-pro server is not running.

If the netconfd-pro server is shut down then ypgnmi-app will also shutdown.