Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
7 files
+ 195
56
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 26
13
@@ -3,25 +3,27 @@ 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/yang-models/generated/openconfig"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
schema "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"context"
"fmt"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.DebugLevel)
sbi := &nucleus.OpenConfig{}
sbi := &nucleus.AristaOC{}
transport := &nucleus.Gnmi{SetNode: sbi.SetNode()}
device := nucleus.Device{
Uuid: uuid.New(),
Device: &openconfig.Device{},
Device: &schema.Device{},
SBI: sbi,
Config: nucleus.DeviceConfig{
Address: "[fdfd::ce05]:6030",
Username: "admin",
Password: "arista",
},
Transport: transport,
}
pnd := nucleus.NewPND("openconfig", "test description", sbi)
if err := pnd.AddDevice(device); err != nil {
@@ -36,14 +38,25 @@ func main() {
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
paths := []string{"/interfaces/interface[name=*]/name"}
req, err := gnmi.NewGetRequest(gnmi.SplitPaths(paths), "")
resp, err := nucleus.GetWithRequest(ctx, req)
if err != nil {
log.Fatal(err)
}
if err := device.Add(resp); err != nil {
panic(err)
paths := util.NewPaths()
paths.ParseSchema(sbi.Schema(), "device")
p := paths.StringBuilder()
errors := 0
for _, path := range p {
req, err := gnmi.NewGetRequest(gnmi.SplitPaths([]string{path}), "")
resp, err := nucleus.GetWithRequest(ctx, req)
if err != nil {
log.Debug(err)
errors++
break
}
if err := device.Add(resp); err != nil {
log.Debug(err)
errors++
}
}
fmt.Println(device.Config)
percentage := float64(errors) / float64(len(p)) * 100.0
log.Debugf("%v errors", errors)
log.Debugf("%v percent failed", percentage)
}
Loading