Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
schema "code.fbi.h-da.de/cocsn/yang-models/generated/arista"
"context"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
func main() {
sbi := &nucleus.AristaOC{}
transport := &nucleus.Gnmi{SetNode: sbi.SetNode()}
Config: nucleus.DeviceConfig{
Uuid: uuid.New(),
Address: "localhost:9339",
}
pnd := nucleus.NewPND("openconfig", sbi)
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
cfg := &gnmi.Config{
Addr: device.Config.Address,
Password: device.Config.Password,
Username: device.Config.Username,
}
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
p := []string{"/interfaces/interface[name=en0]/state/name"}
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++
}
log.Debugf("%v errors", errors)
log.Debugf("%v percent failed", percentage)