Skip to content
Snippets Groups Projects

Northbound Interface

Merged Ghost User requested to merge grpc-nbi into develop
29 files
+ 343
312
Compare changes
  • Side-by-side
  • Inline
Files
29
+ 0
40
package cli
import (
"context"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
gpb "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus"
)
// Get sends a gNMI Get request to the specified target and prints the response to stdout
func Get(a, u, p string, args ...string) (*gpb.GetResponse, error) {
sbi := &nucleus.OpenConfig{}
opts := &nucleus.GnmiTransportOptions{
Config: gnmi.Config{
Addr: a,
Username: u,
Password: p,
Encoding: gpb.Encoding_JSON_IETF,
},
SetNode: sbi.SetNode(),
}
t, err := nucleus.NewGnmiTransport(opts)
if err != nil {
return nil, err
}
resp, err := t.Get(context.Background(), args...)
if err != nil {
return nil, err
}
log.Debug(resp)
r, ok := resp.(*gpb.GetResponse)
if !ok {
return nil, &errors.ErrInvalidTypeAssertion{}
}
return r, nil
}
Loading