What is gNMI? Why use it over eAPI? (Streaming Telemetry, Declarative Configuration, Protobuf/gRPC, schema-driven). gNMI RPC types: Capabilities, Get, Set, Subscribe.
Enabling gNMI on cEOS: Review the startup-config change required.
gnmi-lab.clab.yaml
name: gnmi-lab
topology:
nodes:
ceos1:
kind: arista_ceos
image: ceos:4.34.0F
ceos2:
kind: arista_ceos
image: ceos:4.34.0F
links:
- endpoints: ["ceos1:eth1", "ceos2:eth1"]// gnmi_connect.go
package main
import (
"context"
"fmt"
"os"
"github.com/openconfig/gnmic/pkg/api"
)
const (
targetAddress = "172.20.20.2:6030" // Replace with your cEOS container IP and gNMI port
username = "admin"
password = "admin"
)
func main() {
target, err := api.NewTarget(
api.Address(targetAddress),
api.Username(username),
api.Password(password),
api.SkipVerify(false),
api.Insecure(true),
)
if err != nil {
fmt.Println(err, "failed to create gnmi client")
os.Exit(1)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// create a gNMI client
err = target.CreateGNMIClient(ctx)
if err != nil {
fmt.Println(err, "failed to create gnmi client")
os.Exit(1)
}
defer target.Close()
// send the created gNMI GetRequest to the created target
capResp, err := target.Capabilities(ctx)
if err != nil {
fmt.Println(err, "failed to execute get request")
os.Exit(1)
}
fmt.Println("gNMI Capabilities:")
fmt.Printf(" Supported Models: %+v\n", capResp.GetSupportedModels())
fmt.Printf(" Supported Versions: %+v\n", capResp.GetGNMIVersion())
fmt.Printf(" Supported Encodings: %+v\n", capResp.GetSupportedEncodings())
}- Deploy the
gnmi-lab.clab.yaml. - Find the IP address of
clab-automation-lab-ceos1. - Update
gnmi_connect.gowith the correct IP and run the program. Verify that it connects and prints capabilities.