From 9185dae68c7d166857f89440fdb8d57d220dbd3d Mon Sep 17 00:00:00 2001 From: Manuel Kieweg <manuel.kieweg@h-da.de> Date: Mon, 21 Jun 2021 16:58:33 +0100 Subject: [PATCH] change southbound interface --- interfaces/southbound/sbi.go | 1 + nucleus/gnmi_transport.go | 6 +++--- nucleus/southbound.go | 12 ++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/interfaces/southbound/sbi.go b/interfaces/southbound/sbi.go index 0d4cdb56f..11fdb71b1 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 77f078aa6..fc77bb875 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 dc074235f..49e1ea8ec 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 { -- GitLab