diff --git a/interfaces/southbound/sbi.go b/interfaces/southbound/sbi.go index 0d4cdb56fd5290a849e33bd107a2ef55e31e3748..11fdb71b1c62877d16e3439ee69c5c4b08c669f3 100644 --- a/interfaces/southbound/sbi.go +++ b/interfaces/southbound/sbi.go @@ -22,4 +22,5 @@ type SouthboundInterface interface { // nolint Schema() *ytypes.Schema ID() uuid.UUID Type() spb.Type + Unmarshal() func([]byte, []string, interface{}, ...ytypes.UnmarshalOpt) error } diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index 77f078aa69c32a501adde00c46d2d1fc3f5a1677..fc77bb8755018e0ff6d1abf1b0547d7b0feb6234 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -68,6 +68,7 @@ func newGnmiTransport(opts *tpb.TransportOption, sbi southbound.SouthboundInterf return &Gnmi{ SetNode: sbi.SetNode(), RespChan: make(chan *gpb.SubscribeResponse), + Unmarshal: sbi.Unmarshal(), Options: opts, client: c, config: gnmiConfig, @@ -231,11 +232,10 @@ func (g *Gnmi) ProcessResponse(resp interface{}, root interface{}, s *ytypes.Sch for _, msg := range rn { for _, update := range msg.Update { path := update.Path - fullPath := path - val, ok := update.Val.Value.(*gpb.TypedValue_JsonIetfVal) + val, ok := update.Val.Value.(*gpb.TypedValue_JsonVal) if ok { opts := []ytypes.UnmarshalOpt{&ytypes.IgnoreExtraFields{}} - return g.Unmarshal(val.JsonIetfVal, pathutils.ToStrings(fullPath), root, opts...) + return g.Unmarshal(val.JsonVal, pathutils.ToStrings(path), root, opts...) } // TODO(mk): Evaluate hardcoded model key schema := models["Device"] diff --git a/nucleus/southbound.go b/nucleus/southbound.go index dc074235f843ec4fe646797713bd338ce9815165..49e1ea8ec864a142c126cfcc9aa9d99e869797c8 100644 --- a/nucleus/southbound.go +++ b/nucleus/southbound.go @@ -58,8 +58,7 @@ func (oc *OpenConfig) Schema() *ytypes.Schema { return schema } -// SetNode injects OpenConfig specific model -// representation to the transport. +// SetNode injects OpenConfig specific model representation to the transport. // Needed for type assertion. func (oc *OpenConfig) SetNode() func(schema *yang.Entry, root interface{}, path *gpb.Path, val interface{}, opts ...ytypes.SetNodeOpt) error { return func(schema *yang.Entry, root interface{}, path *gpb.Path, val interface{}, opts ...ytypes.SetNodeOpt) error { @@ -67,8 +66,7 @@ func (oc *OpenConfig) SetNode() func(schema *yang.Entry, root interface{}, path } } -// Unmarshal injects OpenConfig specific model -// representation to the transport. +// Unmarshal injects OpenConfig specific model representation to the transport. // Needed for type assertion. func (oc *OpenConfig) Unmarshal() func([]byte, []string, interface{}, ...ytypes.UnmarshalOpt) error { return unmarshal @@ -170,6 +168,12 @@ func (csbi *Csbi) SetNode() func(schema *yang.Entry, root interface{}, path *gpb } } +// Unmarshal injects OpenConfig specific model representation to the transport. +// Needed for type assertion. +func (csbi *Csbi) Unmarshal() func([]byte, []string, interface{}, ...ytypes.UnmarshalOpt) error { + return unmarshal +} + // Schema is holding the default OpenConfig schema for minimal compatibility // to gosdn interfaces func (csbi *Csbi) Schema() *ytypes.Schema {