karimra / gnoic

gnoic is a gNOI client command line interface
https://gnoic.kmrd.dev
Apache License 2.0
24 stars 6 forks source link

gNOIc go lib example #105

Open asafsonnv opened 9 months ago

asafsonnv commented 9 months ago

Hi:)

Thanks for this great tool. I'm trying to import and use gnoic go lib and I'm facing some issues.

do you have a basic example of use?

I tried this very basic flow and it failed:

cfg := config.TargetConfig{Address: "localhost:9339", Password: &pass, Username: &user, TLSCert: &tlscert, TLSKey: &tlskey}
target := gnoicapi.NewTargetFromConfig(&cfg)
    gnoicapp.New().OsVerify(ctx, target)

I get this error:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x2c0 pc=0x8b3e2b]

goroutine 1 [running]: google.golang.org/grpc.(ClientConn).Invoke(0x0, {0xb0e6f8, 0xc0001c7b90}, {0xa452fb, 0x12}, {0x9c0b80, 0xc0001c7da0}, {0x9f2b80, 0xc0000d8dc0}, {0x0, ...}) /golib/pkg/mod/google.golang.org/grpc@v1.57.0/call.go:30 +0x8b github.com/openconfig/gnoi/os.(oSClient).Verify(0xc0001e5e18, {0xb0e6f8, 0xc0001c7b90}, 0xc0001c3200?, {0x0, 0x0, 0x0}) /golib/pkg/mod/github.com/openconfig/gnoi@v0.1.0/os/os_grpc.pb.go:173 +0xce github.com/karimra/gnoic/app.(*App).OsVerify(0xb0e6c0?, {0xb0e6f8, 0xc0001c7b90}, 0xe73540?) /golib/pkg/mod/github.com/karimra/gnoic@v0.0.19/app/osVerify.go:108 +0x65 main.main() /tests/verify/main.go:26 +0x225 exit status 2

Thanks in Advance, Asaf.

karimra commented 9 months ago

Hi,

You need to call target.CreateGrpcClient() on that created target so that it connects, it's not done automatically. Check the commands Run function under ./app