Skip to content
Snippets Groups Projects

Draft: Resolve "Allow vendor specifics in OC"

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