Skip to content
Snippets Groups Projects

Process response overhaul

Merged Ghost User requested to merge process-response-overhaul into develop
1 file
+ 2
52
Compare changes
  • Side-by-side
  • Inline
+ 2
52
@@ -18,13 +18,9 @@ package gnmi
import (
"errors"
"fmt"
"net"
"reflect"
"sort"
oc "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
log "github.com/sirupsen/logrus"
"github.com/openconfig/goyang/pkg/yang"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes"
@@ -68,16 +64,8 @@ func (m *Model) NewConfigStruct(jsonConfig []byte) (ygot.ValidatedGoStruct, erro
if !ok {
return nil, errors.New("root node is not a ygot.ValidatedGoStruct")
}
ifaces, err := getInterfaces()
if err != nil {
return nil, err
}
device, ok := rootStruct.(*oc.Device)
if !ok {
return nil, errors.New("root node is not a oc.Device")
}
device.Interfaces = ifaces
return device, nil
return rootStruct, nil
}
// SupportedModels returns a list of supported models.
@@ -89,41 +77,3 @@ func (m *Model) SupportedModels() []string {
sort.Strings(mDesc)
return mDesc
}
func getInterfaces() (*oc.OpenconfigInterfaces_Interfaces, error) {
ifaces, err := net.Interfaces()
if err != nil {
log.Fatal()
}
interfaces := &oc.OpenconfigInterfaces_Interfaces{
Interface: make(map[string]*oc.OpenconfigInterfaces_Interfaces_Interface),
}
for _, tInterface := range ifaces {
var mtu *uint16
var name *string
var index *uint32
rmtu := uint16(tInterface.MTU)
rname := tInterface.Name
rindex := uint32(tInterface.Index)
mtu = &rmtu
name = &rname
index = &rindex
iface, err := interfaces.NewInterface(tInterface.Name)
if err != nil {
return nil, err
}
iface.State = &oc.OpenconfigInterfaces_Interfaces_Interface_State{
Ifindex: &rindex,
Mtu: &rmtu,
Name: &rname,
}
iface.State.Name = name
iface.State.Mtu = mtu
iface.State.Ifindex = index
}
return interfaces, nil
}
Loading