Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
2 files
+ 90
4
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 74
0
package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
schema "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"context"
"fmt"
"github.com/google/uuid"
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{}
transport := &nucleus.Gnmi{
SetNode: sbi.SetNode(),
RespChan: make(chan *gpb.SubscribeResponse),
}
device := nucleus.Device{
Device: &schema.Device{},
SBI: sbi,
Config: nucleus.DeviceConfig{
Uuid: uuid.New(),
Address: "[fdfd::ce05]:6030",
Username: "admin",
Password: "arista",
},
Transport: transport,
}
pnd := nucleus.NewPND("openconfig", sbi)
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
cfg := &gnmi.Config{
Addr: device.Config.Address,
Password: device.Config.Password,
Username: device.Config.Username,
}
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
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: device.Config.Address,
}
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGILL, syscall.SIGTERM)
ctx = context.WithValue(ctx, "opts", opts)
go func() {
if err := transport.Subscribe(ctx); err != nil {
log.Fatal(err)
}
}()
fmt.Println("awaiting signal")
<-done
fmt.Println("exiting")
}
\ No newline at end of file
Loading