Skip to content
Snippets Groups Projects
Commit f1cacec0 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Forked arista gnmi to avoid their glog fork

parent 7cb0548c
No related branches found
No related tags found
4 merge requests!90Develop,!88Use SPF Viper for configuration,!85Draft: Resolve "Overhaul Architecture",!53V.0.1.0 Codename Threadbare
Pipeline #57225 passed with warnings
package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"context"
"fmt"
......@@ -24,7 +25,13 @@ func main() {
log.Fatal(err)
}
ctx := context.WithValue(context.Background(), "config", device.Config)
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)
g := nucleus.Gnmi{}
resp, err := g.Capabilities(ctx)
......
goarista @ 4e6fdcf7
Subproject commit 4e6fdcf7f22110ef30e57869c1f0ddac8713b54f
......@@ -2,24 +2,31 @@ module code.fbi.h-da.de/cocsn/gosdn
go 1.14
replace github.com/aristanetworks/goarista/netns => /Users/mk/go/src/github.com/aristanetworks/goarista/netns
require (
code.fbi.h-da.de/cocsn/swagger/apis v0.0.0-20200924152423-61030cab7b88
code.fbi.h-da.de/cocsn/yang-modules/generated/tapi v0.0.0-20201116134549-765aa1790752
github.com/BurntSushi/toml v0.3.1
github.com/aristanetworks/fsnotify v1.4.2
github.com/aristanetworks/goarista v0.0.0-20201120222254-94a892eb0c6a
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591
github.com/go-openapi/runtime v0.19.22
github.com/go-openapi/strfmt v0.19.5
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.2
github.com/neo4j/neo4j-go-driver v1.8.3
github.com/onsi/ginkgo v1.13.0 // indirect
github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802
github.com/openconfig/reference v0.0.0-20190727015836-8dfd928c9696
github.com/openconfig/ygot v0.8.7
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743
github.com/sirupsen/logrus v1.4.2
github.com/tidwall/gjson v1.6.3
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7
google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.25.0
)
This diff is collapsed.
......@@ -26,8 +26,8 @@ type Core struct {
IsRunning chan bool
}
//Init does start-up housekeeping like reading controller config files
func (c *Core) Init(socket, configFileController, configFileClient string, IsRunningChannel chan bool) {
//Initialize does start-up housekeeping like reading controller config files
func (c *Core) Initialize(socket, configFileController, configFileClient string, IsRunningChannel chan bool) {
if err := c.readControllerConfig(configFileController); err != nil {
log.Fatal(err)
}
......
package nucleus
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"context"
"github.com/aristanetworks/goarista/gnmi"
"github.com/google/uuid"
"github.com/openconfig/gnmi/proto/gnmi_ext"
......@@ -21,11 +21,7 @@ func (g *Gnmi) GetConfig() interface{} {
// Capabilities calls GNMI capabilities
func (g *Gnmi) Capabilities(ctx context.Context) (interface{}, error) {
cfg := &gnmi.Config{}
cfg.Addr = ctx.Value("config").(DeviceConfig).Address
cfg.Username = ctx.Value("config").(DeviceConfig).Username
cfg.Password = ctx.Value("config").(DeviceConfig).Password
client, err := gnmi.Dial(cfg)
client, err := gnmi.Dial(ctx.Value("config").(*gnmi.Config))
if err != nil {
return nil, err
}
......@@ -37,18 +33,18 @@ func (g *Gnmi) Capabilities(ctx context.Context) (interface{}, error) {
}
// Get calls GNMI get
func (g *Gnmi) Get(ctx context.Context, cfg *gnmi.Config, paths [][]string, origin string) (interface{}, error) {
func (g *Gnmi) Get(ctx context.Context, paths [][]string, origin string) (interface{}, error) {
req, err := gnmi.NewGetRequest(paths, origin)
if err != nil {
return nil, err
}
return GetWithRequest(ctx, cfg, req)
return GetWithRequest(ctx, req)
}
// GetWithRequest takes a fully formed GetRequest, performs the Get,
// and displays any response.
func GetWithRequest(ctx context.Context, cfg *gnmi.Config, req *gpb.GetRequest) (interface{}, error) {
client, err := gnmi.Dial(cfg)
func GetWithRequest(ctx context.Context, req *gpb.GetRequest) (interface{}, error) {
client, err := gnmi.Dial(ctx.Value("config").(*gnmi.Config))
if err != nil {
return nil, err
}
......@@ -60,9 +56,9 @@ func GetWithRequest(ctx context.Context, cfg *gnmi.Config, req *gpb.GetRequest)
}
// Set calls GNMI set
func (g *Gnmi) Set(ctx context.Context, cfg *gnmi.Config, setOps []*gnmi.Operation,
func (g *Gnmi) Set(ctx context.Context, setOps []*gnmi.Operation,
exts ...*gnmi_ext.Extension) error {
client, err := gnmi.Dial(cfg)
client, err := gnmi.Dial(ctx.Value("config").(*gnmi.Config))
if err != nil {
return err
}
......@@ -70,9 +66,9 @@ func (g *Gnmi) Set(ctx context.Context, cfg *gnmi.Config, setOps []*gnmi.Operati
}
// Subscribe calls GNMI subscribe
func (g *Gnmi) Subscribe(ctx context.Context, cfg *gnmi.Config, subscribeOptions *gnmi.SubscribeOptions,
func (g *Gnmi) Subscribe(ctx context.Context, subscribeOptions *gnmi.SubscribeOptions,
respChan chan<- *gpb.SubscribeResponse) error {
client, err := gnmi.Dial(cfg)
client, err := gnmi.Dial(ctx.Value("config").(*gnmi.Config))
if err != nil {
return err
}
......
......@@ -11,11 +11,11 @@ func StartAndRun(socket, filename string, IsRunningChannel chan bool) {
log.Info("This is the network superintendent...")
log.Info("Starting my ducks")
// Init the Core
// Initialize the Core
core := Core{
database: database.Database{},
}
core.Init(socket, filename, "", IsRunningChannel)
core.Initialize(socket, filename, "", IsRunningChannel)
// Start the GRCP CLI
go getCLIGoing(&core)
go core.Shutdown()
......
......@@ -3,8 +3,7 @@ package ciena
import (
"bytes"
"code.fbi.h-da.de/cocsn/gosdn/database"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces"
t "code.fbi.h-da.de/cocsn/gosdn/nucleus/transport"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
apiclient "code.fbi.h-da.de/cocsn/swagger/apis/mcp/client"
"code.fbi.h-da.de/cocsn/yang-modules/generated/tapi"
"crypto/tls"
......@@ -59,7 +58,7 @@ func NewMCPClient(endpoint, username, password string, database *database.Databa
client := apiclient.New(transport, strfmt.Default)
buffer := new(bytes.Buffer)
transport.Consumers[runtime.JSONMime] = t.YANGConsumer{Data: buffer}
transport.Consumers[runtime.JSONMime] = nucleus.YANGConsumer{Data: buffer}
return &Mcp{
transport: transport,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment