Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (55 sloc) 1.44 KB
gRPC Client
package main
import (
xr ""
func timeTrack(start time.Time) {
elapsed := time.Since(start)
log.Printf("This process took %s\n", elapsed)
func main() {
// To time this process
defer timeTrack(time.Now())
// YANG path arguments; defaults to "yangpaths.json"
ypath := flag.String("ypath", "../input/yangpaths.json", "YANG path arguments")
// Determine the ID for the transaction.
r := rand.New(rand.NewSource(time.Now().UnixNano()))
id := r.Int63n(10000)
output := "Empty"
// Manually specify target parameters.
router, err := xr.BuildRouter(
if err != nil {
log.Fatalf("target parameters are incorrect: %s", err)
// Setup a connection to the target.
conn, ctx, err := xr.Connect(*router)
if err != nil {
log.Fatalf("could not setup a client connection to %s, %v", router.Host, err)
defer conn.Close()
// Get config for the YANG paths specified on 'js'
js, err := ioutil.ReadFile(*ypath)
if err != nil {
log.Fatalf("could not read file: %v: %v\n", *ypath, err)
output, err = xr.GetConfig(ctx, conn, string(js), id)
if err != nil {
log.Fatalf("could not get the config from %s, %v", router.Host, err)
fmt.Printf("\nconfig from %s\n %s\n", router.Host, output)
You can’t perform that action at this time.