-
Manuel Kieweg authored
Revert "Merge branch 'develop' into '74-follow-up-from-draft-resolve-pnd-handling-via-cli-and-database'" This reverts commit 7d6f3967
Manuel Kieweg authoredRevert "Merge branch 'develop' into '74-follow-up-from-draft-resolve-pnd-handling-via-cli-and-database'" This reverts commit 7d6f3967
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
telemetry.go 1.58 KiB
package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"context"
"fmt"
gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
log.SetLevel(log.DebugLevel)
sbi := &nucleus.AristaOC{}
device, err := nucleus.NewDevice("gnmi", sbi,
&nucleus.GnmiTransportOptions{
Addr: "portainer.danet.fbi.h-da.de:6030",
Username: "admin",
Password: "arista",
SetNode: sbi.SetNode(),
RespChan: make(chan *gpb.SubscribeResponse),
Encoding: gpb.Encoding_JSON_IETF,
})
if err != nil {
log.Debug(err)
}
pnd, err := nucleus.NewPND("openconfig", "a simple openconfig PND", sbi)
if err != nil {
log.Fatal(err)
}
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
paths := []string{"/interfaces/interface/name"}
opts := &gnmi.SubscribeOptions{
UpdatesOnly: false,
Prefix: "",
Mode: "stream",
StreamMode: "sample",
SampleInterval: uint64(10 * time.Second.Nanoseconds()),
SuppressRedundant: false,
HeartbeatInterval: uint64(time.Second.Nanoseconds()),
Paths: gnmi.SplitPaths(paths),
Origin: "",
Target: "portainer.danet.fbi.h-da.de:6030",
}
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGILL, syscall.SIGTERM)
ctx := context.WithValue(context.Background(), "opts", opts)
go func() {
if err := device.Transport.Subscribe(ctx); err != nil {
log.Fatal(err)
}
}()
fmt.Println("awaiting signal")
<-done
fmt.Println("exiting")
}