Skip to content
Snippets Groups Projects

Resolve "A SetRequest to change a specific path of an OND only works for paths with string values"

Compare and
4 files
+ 86
29
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -148,7 +148,7 @@ func fillOndBySpecificPath(pnd networkdomain.NetworkDomain, did string, path str
return nil, status.Errorf(codes.Aborted, "%v", err)
}
gnmiPath, err := ygot.StringToPath(path, ygot.StructuredPath)
gnmiPath, err := ygot.StringToStructuredPath(path)
if err != nil {
log.Error(err)
return nil, status.Errorf(codes.Aborted, "%v", err)
@@ -163,31 +163,9 @@ func fillOndBySpecificPath(pnd networkdomain.NetworkDomain, did string, path str
// we should be fine to access nodes[0] here, since ytypes.GetNode() throws
// an error if there are no matches for the path.
nodeEntry := nodes[0].Schema
node := nodes[0].Data
var dev []*gnmi.Notification
if nodeEntry.IsDir() {
validatedNode, ok := nodes[0].Data.(ygot.ValidatedGoStruct)
if !ok {
return nil, status.Errorf(codes.Aborted, "%v", errors.ErrInvalidTypeAssertion{
Value: node,
Type: (ygot.ValidatedGoStruct)(nil),
})
}
cfg := ygot.GNMINotificationsConfig{}
dev, err = ygot.TogNMINotifications(validatedNode, time.Now().UnixNano(), cfg)
if err != nil {
log.Error(err)
return nil, status.Errorf(codes.Aborted, "%v", err)
}
} else if nodeEntry.IsLeaf() {
dev, err = genGnmiNotificationForLeaf(gnmiPath, node)
if err != nil {
log.Error(err)
return nil, status.Errorf(codes.Aborted, "%v", err)
}
}
dev, err := genGnmiNotification(gnmiPath, node)
sbi := spb.SouthboundInterface{}
if d.SBI() != nil {
@@ -205,8 +183,8 @@ func fillOndBySpecificPath(pnd networkdomain.NetworkDomain, did string, path str
return ond, nil
}
func genGnmiNotificationForLeaf(path *gnmi.Path, val any) ([]*gnmi.Notification, error) {
typedVal, err := ygot.EncodeTypedValue(val, gnmi.Encoding_PROTO)
func genGnmiNotification(path *gnmi.Path, val any) ([]*gnmi.Notification, error) {
typedVal, err := ygot.EncodeTypedValue(val, gnmi.Encoding_JSON_IETF)
if err != nil {
return nil, err
}
Loading