From af732489eb5b894de87270386c43cf62e94eda1c Mon Sep 17 00:00:00 2001 From: "S.H." <sebastian.heiss94@proton.me> Date: Fri, 14 Mar 2025 11:58:22 +0100 Subject: [PATCH] Change makefile to rename image to gnmi-target-local, add many debug print statements --- Makefile | 2 +- examples/example01/handlers/interfaces/interfacesHandler.go | 4 +++- internal/gnmiserver/server.go | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 976de05..405ecdd 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ generate-yang-models: install-tools go generate container: build - docker buildx build --rm -t gnmi-target --load -f ./examples/example01/target.Dockerfile . + docker buildx build --rm -t gnmi-target-local --load -f ./examples/example01/target.Dockerfile . container-debug: docker buildx build --rm -t gnmi-target-debug --load -f .examples/example01/Dockerfile.debug . diff --git a/examples/example01/handlers/interfaces/interfacesHandler.go b/examples/example01/handlers/interfaces/interfacesHandler.go index cb77aa2..6d2d4f3 100644 --- a/examples/example01/handlers/interfaces/interfacesHandler.go +++ b/examples/example01/handlers/interfaces/interfacesHandler.go @@ -59,6 +59,7 @@ func (yh *InterfacesHandler) Init(config *handler.Config, publishToSubsFunc func case update := <-interfaceChannel: //lock access for model diff, err := yh.updateOrCreateInterface(update) + fmt.Println("PublishToSubs with this diff:", diff) if err != nil { log.Errorf("Error within interface subscription goroutine; %v", err) // TODO: check again @@ -70,12 +71,12 @@ func (yh *InterfacesHandler) Init(config *handler.Config, publishToSubsFunc func } } }() - return nil } func (yh *InterfacesHandler) Update(c ygot.ValidatedGoStruct, updates []*gnmi.Update) error { fmt.Println("Update request received for ", yh.GetName()) + fmt.Println("To be updated:", updates) config, ok := c.(*gnmitargetygot.Gnmitarget) if !ok { return fmt.Errorf("failed type assertion for config %T", (*gnmitargetygot.Gnmitarget)(nil)) @@ -149,6 +150,7 @@ func (yh *InterfacesHandler) Update(c ygot.ValidatedGoStruct, updates []*gnmi.Up } func (yh *InterfacesHandler) updateOrCreateInterface(localInterface *additions.Interface) ([]*gnmi.Notification, error) { + fmt.Println("UpdateOrCreateInterface on interface", localInterface) yh.Config.Lock() defer yh.Config.Unlock() diff --git a/internal/gnmiserver/server.go b/internal/gnmiserver/server.go index 1ad9553..8c3df6b 100644 --- a/internal/gnmiserver/server.go +++ b/internal/gnmiserver/server.go @@ -144,6 +144,8 @@ func (s *Server) callback(newConfig ygot.ValidatedGoStruct, existingConf ygot.Va // TODO: This will be moved. func (s *Server) PublishNotificationsToSubscribers(notifications []*gnmi.Notification) error { + fmt.Println("In PublishNotificationsToSubscribers()") + fmt.Println("Notifications:", notifications) for _, specificDiff := range notifications { // First for gnmi Updates updates := specificDiff.GetUpdate() -- GitLab