Skip to content
Snippets Groups Projects
Commit 9185dae6 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

change southbound interface

parent 71fe6871
No related branches found
No related tags found
1 merge request!173Process response overhaul
This commit is part of merge request !173. Comments created here will be created in the context of that merge request.
......@@ -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
}
......@@ -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"]
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment