Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
1 file
+ 27
5
Compare changes
  • Side-by-side
  • Inline
+ 97
0
package nucleus
import (
"code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
log "github.com/golang/glog"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/ytypes"
)
// SouthboundInterface provides an
// interface for SBI implementations
type SouthboundInterface interface {
// deprecated
SbiIdentifier() string
// SetNode injects SBI specific model
// representation to the transport.
// Needed for type assertion.
SetNode() func(schema *yang.Entry, root interface{}, path *gpb.Path, val interface{}, opts ...ytypes.SetNodeOpt) error
Schema() *ytypes.Schema
}
type Tapi struct {
}
// OpenConfig is the implementation of an OpenConfig SBI.
// The struct holds the YANG schema and a function that
// returns an SBI specific SetNode function.
type OpenConfig struct {
// deprecated
transport Transport
schema *ytypes.Schema
}
// SbiIdentifier returns the string representation of
// the SBI
// deprecated
func (oc *OpenConfig) SbiIdentifier() string {
return "openconfig"
}
func (oc *OpenConfig) Schema() *ytypes.Schema {
schema, err := openconfig.Schema()
if err != nil {
log.Fatal(err)
}
return schema
}
// 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 {
if err := ytypes.SetNode(schema, root.(*openconfig.Device), path, val, opts...); err != nil {
return err
}
return nil
}
}
// deprecated
// Use for prototyping only.
// Use OpenConfig instead
type AristaOC struct {
// deprecated
transport Transport
schema *ytypes.Schema
}
func (oc *AristaOC) SbiIdentifier() string {
return "arista"
}
func (oc *AristaOC) Schema() *ytypes.Schema {
schema, err := arista.Schema()
if err != nil {
log.Fatal(err)
}
return schema
}
// SetNode injects AristaOC specific model
// representation to the transport.
// Needed for type assertion.
func (oc *AristaOC) 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 {
if err := ytypes.SetNode(schema, root.(*arista.Device), path, val, opts...); err != nil {
return err
}
return nil
}
}
Loading