YANG Suite is HTML5-based tooling that is available for working with the YANG-based programmable interfaces on Cisco IOS XE, XR, and Nexus network operating systems. It has plug-ins that allow for interacting with the programmable interfaces and supports downloading YANG files directly from network devices. In this tutorial, we will explore using RESTCONF and gRPC to interact with the APIs in a switch.

What You’ll Learn

What You’ll Need

RESTCONF is a standard protocol using HTTP to access APIs defined in YANG. The YANG Suite application helps visualize this process, but you can interact with the API with something like a Python script as well. There is another tutorial covering using RESTCONF with Python requests.

In this step you will make an API call to get the interface description using RESTCONF and YANG Suite.

  1. Protocol: “RESTCONF”
  2. Select a YANG Set: “c9300-default-yangset”
  3. Select a device: “C9300”
  4. Select YANG modules: “Cisco-IOS-XE-native”
  5. Select depth limit: “2”
  6. Select “Load Module(s)”

  1. Once the tree loads, close the popup that says “Tree generated, please select node(s) to generate API(s)”
  2. Expand the tree by selecting the arrow next to “Cisco-IOS-XE-native”

  1. Search for “interface” in the expanded tree. (note: select CONTROL + F to find “interface” on the page)
  2. Expand “interface” and search for “Loopback" (note: select CONTROL + F to find “Loopback” on the page)

  1. Click the blue “Generate API(s)” button. (note: it may take a few moments to load the APIs)
  2. Close the popup that says “API(s) are generated”

  1. Click the blue “Show API(s)” button
  2. Select the link next to the “GET” operation corresponding to the API call “/data/Cisco-IOS-XE-native:native/interface/Loopback”
  3. Click the “Try it out” button

  1. Click the “Execute” button to send the RESTCONF payload and view the reply, including the Loopback Netmask

gRPC is an open-source RPC framework that is used for streaming telemetry (operational data) from infrastructure devices. Think of a more modern SNMP, but with better APIs and much faster.

In this task you will use YANG Suite to set up a gRPC telemetry subscription. The network device needs some configuration to start streaming the telemetry, and the configuration is provided below.

gRPC subscription

  1. In YANG Suite,
    1. Protocol: “gRPC telemetry”
    2. Listen at IP address: “0.0.0.0”
    3. Listen at port: “58500”
    4. Click the “Start receiver” button

  1. On the switch, configure the subscription by copy/pasting the configs:

    conf t
    telemetry ietf subscription 2011
    encoding encode-kvgpb
    filter xpath /ios:native
    stream yang-push
    update-policy periodic 6000
    receiver-type protocol
    receiver name yangsuite
    
    telemetry receiver protocol yangsuite
    host name yangsuite-telemetry.cisco.com 58500
    protocol grpc-tcp
    

  1. Back in YANG Suite, check the telemetry data that should appear at regular intervals on the “gRPC telemetry” screen
  2. When the telemetry data begins to flow from the C9300 into YANG Suite, several lines of data will be displayed. Included in this is the timestamp, subscription ID, node, path, name, and value fields.

Learn More