Skip to content
Snippets Groups Projects
Commit e06f342e authored by Malte Bauch's avatar Malte Bauch
Browse files

Use ygot.PathToString to create key for the pathAndValues map

parent 5011a5ff
No related branches found
No related tags found
1 merge request!576Resolve "The key for more complex paths in the map containing information of update events should be improved"
This commit is part of merge request !576. Comments created here will be created in the context of that merge request.
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"strconv" "strconv"
"strings"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs" "code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/event" "code.fbi.h-da.de/danet/gosdn/controller/event"
...@@ -15,6 +14,7 @@ import ( ...@@ -15,6 +14,7 @@ import (
"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi" "code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
"github.com/google/uuid" "github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi" gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ygot/ygot"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
...@@ -184,15 +184,22 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib ...@@ -184,15 +184,22 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib
pathsAndValues := make(map[string]string, len(resp.Update.Update)) pathsAndValues := make(map[string]string, len(resp.Update.Update))
for _, update := range resp.Update.Update { for _, update := range resp.Update.Update {
pathString := "" //pathString := ""
// go through elem to build full path pathString, err := ygot.PathToString(update.Path)
for _, elem := range update.Path.Elem { if err != nil {
// remove unwanted parts of path string example: "name:\"system\"" -> "system" log.Errorf("Error trying to create a string from path: %v", err)
filteredElem := elem.String()[strings.Index(elem.String(), ":\"")+2 : len(elem.String())-1]
pathString += filteredElem + "/"
} }
log.Info("Generated path string, used as key in pathAndValues map: ", pathString)
//// go through elem to build full path
//for _, elem := range update.Path.Elem {
// // remove unwanted parts of path string example: "name:\"system\"" -> "system"
// filteredElem := elem.String()[strings.Index(elem.String(), ":\"")+2 : len(elem.String())-1]
// pathString += filteredElem + "/"
//}
pathsAndValues[pathString] = update.Val.GetStringVal() pathsAndValues[pathString] = update.Val.GetStringVal()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment