Skip to content
Snippets Groups Projects
Commit b05a327d authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Fixed telemetry.go

parent 5e187d37
No related branches found
No related tags found
3 merge requests!97Resolve "PND handling via CLI and database",!91"Overhaul Architecture",!90Develop
Pipeline #63885 passed with warnings
...@@ -17,33 +17,32 @@ import ( ...@@ -17,33 +17,32 @@ import (
func main() { func main() {
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
sbi := &nucleus.AristaOC{} sbi := &nucleus.AristaOC{}
transport := &nucleus.Gnmi{
SetNode: sbi.SetNode(),
RespChan: make(chan *gpb.SubscribeResponse),
}
device := nucleus.Device{ device := nucleus.Device{
GoStruct: sbi.Schema().Root, GoStruct: sbi.Schema().Root,
SBI: sbi, SBI: sbi,
Config: nucleus.DeviceConfig{ Config: nucleus.DeviceConfig{
Uuid: uuid.New(), Uuid: uuid.New(),
Address: "localhost:9339",
Username: "admin",
Password: "arista",
}, },
Transport: transport,
} }
pnd := nucleus.NewPND("openconfig", "a simple openconfig PND", sbi) pnd := nucleus.NewPND("openconfig", "a simple openconfig PND", sbi)
if err := pnd.AddDevice(&device); err != nil { if err := pnd.AddDevice(&device); err != nil {
log.Fatal(err) log.Fatal(err)
} }
transport := &nucleus.Gnmi{
SetNode: sbi.SetNode(),
RespChan: make(chan *gpb.SubscribeResponse),
}
cfg := &gnmi.Config{ cfg := &gnmi.Config{
Addr: device.Config.Address, Addr: "portainer.danet.fbi.h-da.de:6030",
Password: device.Config.Password, Username: "admin",
Username: device.Config.Username, Password: "arista",
Encoding: gpb.Encoding_JSON_IETF,
} }
ctx := gnmi.NewContext(context.Background(), cfg) transport.SetConfig(cfg)
ctx = context.WithValue(ctx, "config", cfg)
device.Transport = transport
paths := []string{"/interfaces/interface/name"} paths := []string{"/interfaces/interface/name"}
...@@ -61,7 +60,7 @@ func main() { ...@@ -61,7 +60,7 @@ func main() {
} }
done := make(chan os.Signal, 1) done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGILL, syscall.SIGTERM) signal.Notify(done, syscall.SIGILL, syscall.SIGTERM)
ctx = context.WithValue(ctx, "opts", opts) ctx := context.WithValue(context.Background(), "opts", opts)
go func() { go func() {
if err := transport.Subscribe(ctx); err != nil { if err := transport.Subscribe(ctx); err != nil {
log.Fatal(err) log.Fatal(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment