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

Use ygot.PathToString to create key for the pathAndValues map

parent d1ca2583
No related branches found
No related tags found
No related merge requests found
Pipeline #164274 passed
......@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strconv"
"strings"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/event"
......@@ -15,6 +14,7 @@ import (
"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
"github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ygot/ygot"
log "github.com/sirupsen/logrus"
)
......@@ -184,15 +184,22 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib
pathsAndValues := make(map[string]string, len(resp.Update.Update))
for _, update := range resp.Update.Update {
pathString := ""
//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 + "/"
pathString, err := ygot.PathToString(update.Path)
if err != nil {
log.Errorf("Error trying to create a string from path: %v", err)
}
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()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment