diff --git a/cmd/gnmi-telemetry/telemetry.go b/cmd/gnmi-telemetry/telemetry.go index b89717f91a560005430781338d57c886826172e2..98650bd09d0fda8e12855b17387e2c346f392e43 100644 --- a/cmd/gnmi-telemetry/telemetry.go +++ b/cmd/gnmi-telemetry/telemetry.go @@ -17,33 +17,32 @@ import ( func main() { log.SetLevel(log.DebugLevel) sbi := &nucleus.AristaOC{} - transport := &nucleus.Gnmi{ - SetNode: sbi.SetNode(), - RespChan: make(chan *gpb.SubscribeResponse), - } + device := nucleus.Device{ GoStruct: sbi.Schema().Root, SBI: sbi, Config: nucleus.DeviceConfig{ - Uuid: uuid.New(), - Address: "localhost:9339", - Username: "admin", - Password: "arista", + Uuid: uuid.New(), }, - Transport: transport, } pnd := nucleus.NewPND("openconfig", "a simple openconfig PND", sbi) if err := pnd.AddDevice(&device); err != nil { log.Fatal(err) } + transport := &nucleus.Gnmi{ + SetNode: sbi.SetNode(), + RespChan: make(chan *gpb.SubscribeResponse), + } cfg := &gnmi.Config{ - Addr: device.Config.Address, - Password: device.Config.Password, - Username: device.Config.Username, + Addr: "portainer.danet.fbi.h-da.de:6030", + Username: "admin", + Password: "arista", + Encoding: gpb.Encoding_JSON_IETF, } - ctx := gnmi.NewContext(context.Background(), cfg) - ctx = context.WithValue(ctx, "config", cfg) + transport.SetConfig(cfg) + + device.Transport = transport paths := []string{"/interfaces/interface/name"} @@ -61,7 +60,7 @@ func main() { } done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGILL, syscall.SIGTERM) - ctx = context.WithValue(ctx, "opts", opts) + ctx := context.WithValue(context.Background(), "opts", opts) go func() { if err := transport.Subscribe(ctx); err != nil { log.Fatal(err)