Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
19 files
+ 12550
103
Compare changes
  • Side-by-side
  • Inline
Files
19
+ 20
27
@@ -3,57 +3,50 @@ package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
schema "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"context"
"github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus"
)
/*
Simple gnmi request program. Use with cauton and leaf paths only.
Bootstrapping of pnd, device and transport simplified not idiomatic
*/
func main() {
log.SetLevel(log.DebugLevel)
sbi := &nucleus.AristaOC{}
transport := &nucleus.Gnmi{SetNode: sbi.SetNode()}
device := nucleus.Device{
Device: &schema.Device{},
SBI: sbi,
device := &nucleus.Device{
SBI: sbi,
Config: nucleus.DeviceConfig{
Uuid: uuid.New(),
Address: "[fdfd::ce05]:6030",
Username: "admin",
Password: "arista",
Uuid: uuid.New(),
},
Transport: transport,
}
pnd := nucleus.NewPND("openconfig", sbi)
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
transport := &nucleus.Gnmi{SetNode: sbi.SetNode()}
cfg := &gnmi.Config{
Addr: device.Config.Address,
Password: device.Config.Password,
Username: device.Config.Username,
Addr: "localhost:9339",
Username: "admin",
Password: "arista",
Encoding: gpb.Encoding_PROTO,
}
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
transport.SetConfig(cfg)
device.Transport = transport
paths := util.NewPaths()
paths.ParseSchema(sbi.Schema(), "device")
p := paths.StringBuilder()
p := []string{"/interfaces/interface[name=en0]/state/name"}
errors := 0
for _,path := range p {
req, err := gnmi.NewGetRequest(gnmi.SplitPaths([]string{path}), "")
resp, err := nucleus.GetWithRequest(ctx, req)
for _, path := range p {
err := pnd.RequestAll(path)
if err != nil {
log.Debug(err)
errors++
break
}
if err := device.Add(resp); err != nil {
log.Debug(err)
errors++
}
}
percentage := float64(errors) / float64(len(p)) * 100.0
Loading