Skip to content

Commit

Permalink
gnsi binding (openconfig#1879)
Browse files Browse the repository at this point in the history
* gnsi binding

* move to ondatra v0.2.1

* address review commenst

* static check issue
  • Loading branch information
mojiiba authored Jul 20, 2023
1 parent 24cf75f commit f4d2164
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 4 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ require (
github.com/open-traffic-generator/snappi/gosnappi v0.11.15
github.com/openconfig/gnmi v0.9.1
github.com/openconfig/gnoi v0.1.0
github.com/openconfig/gnsi v1.2.1
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b
github.com/openconfig/goyang v1.4.0
github.com/openconfig/gribi v1.0.0
github.com/openconfig/gribigo v0.0.0-20230207233343-ef59db57c4fc
github.com/openconfig/kne v0.1.13
github.com/openconfig/ondatra v0.2.0
github.com/openconfig/ondatra v0.2.1
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07
github.com/openconfig/ygnmi v0.8.1
github.com/openconfig/ygot v0.29.0
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ github.com/openconfig/gnmi v0.9.1 h1:hVOdLTaRjdy68oCGJbkf2vrmnUoQ5xbINqBOAMix4xM
github.com/openconfig/gnmi v0.9.1/go.mod h1:Y9os75GmSkhHw2wX8sMsxfI7qRGAEcDh8NTa5a8vj6E=
github.com/openconfig/gnoi v0.1.0 h1:7Odq6UyieHuXW3PYfDBj/dUWgFrL9KVMm0iooQoFLdw=
github.com/openconfig/gnoi v0.1.0/go.mod h1:ZMRwQ7maVNSOjie3Jn67fW5WY7UDrFSiYSlV/GxthQs=
github.com/openconfig/gnsi v1.2.1 h1:JIC6+uVg39jLx3K39g/n6+J7b+c8FKU8TgwFAxmON+A=
github.com/openconfig/gnsi v1.2.1/go.mod h1:QikTHkm468uc2rq/kVhETfyZ6FPeM+zitubrHBbB0HE=
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b h1:NSYuxdlOWLldNpid1dThR6Dci96juXioUguMho6aliI=
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b/go.mod h1:uhC/ybmPapgeyAL2b9ZrUQ+DZE+DB+J+/7377PX+lek=
github.com/openconfig/goyang v0.0.0-20200115183954-d0a48929f0ea/go.mod h1:dhXaV0JgHJzdrHi2l+w0fZrwArtXL7jEFoiqLEdmkvU=
Expand All @@ -911,16 +913,22 @@ github.com/openconfig/kne v0.1.13 h1:CXcy95vrUDAA7nTPGekwJXunlt2kBwM/oMQUlbDzmFM
github.com/openconfig/kne v0.1.13/go.mod h1:L3y17JPcmU06vcTFRssYynUdKS7HfcGJUJNVvwkl5S8=
github.com/openconfig/lemming/operator v0.2.0 h1:dovZnR6lQkOHXcODli1NDOr/GVYrBY05KS5X11jxVbw=
github.com/openconfig/lemming/operator v0.2.0/go.mod h1:LKgEXSR5VK2CAeh2uKijKAXFj42uQuwakrCHVPF0iII=
github.com/openconfig/ondatra v0.2.0 h1:kaYEnVOZgIyEIL6FWQwBv8i/tvp78ptrCUfMP+trLYU=
github.com/openconfig/ondatra v0.2.0/go.mod h1:prhnBnjQC64W5wFbjNqSEomoUb6eWjJiTlAPHhZt2yE=
github.com/openconfig/ondatra v0.1.22 h1:MR8l6tm1IGRTyuko8HG58fx1Ja+fK7TmU+1QdlpkCTM=
github.com/openconfig/ondatra v0.1.22/go.mod h1:9Iprn9ZM9zLBojh6Ngfinl/Abt1JijnJB16MoPu2da0=
github.com/openconfig/ondatra v0.2.1 h1:AbN9OvZ4B0aCFlm3TQxyaygpFCBHO/yUDR94VNZ+oBQ=
github.com/openconfig/ondatra v0.2.1/go.mod h1:kr3B2EiJaA/mArj6VmprDqpe4KR705v9nrf9PYxyHZE=
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07 h1:X631iD/B0ximGFb5P9LY5wHju4SiedxUhc5UZEo7VSw=
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07/go.mod h1:bmpU0kIsCiXuncozViVuQx1HqolC3C94H7lD9KKmoTo=
github.com/openconfig/ygnmi v0.7.10 h1:3nrGANDrXiCc3Z3AakQbbdntx74XF65BZGc1dlvrT/Y=
github.com/openconfig/ygnmi v0.7.10/go.mod h1:cMCgt7ptmWjxpCKcDX4QQZ0WMJcs88J0ZwPqqu1Y7NQ=
github.com/openconfig/ygnmi v0.8.1 h1:wdjrn1wBBBTCSQGO94ht0CY2zyJdoOe4G6rmjsMdPdc=
github.com/openconfig/ygnmi v0.8.1/go.mod h1:AGp9/4AnD9E/mocBis1W+eXAEIlJiBhm1DShOU14Jlg=
github.com/openconfig/ygot v0.6.0/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQSmIhqwAs=
github.com/openconfig/ygot v0.10.4/go.mod h1:oCQNdXnv7dWc8scTDgoFkauv1wwplJn5HspHcjlxSAQ=
github.com/openconfig/ygot v0.13.2/go.mod h1:kJN0yCXIH07dOXvNBEFm3XxXdnDD5NI6K99tnD5x49c=
github.com/openconfig/ygot v0.25.6/go.mod h1:+IVqHe5iTfGcDRi3szuq1Mgvy5q3S4x8DG69K5kw62o=
github.com/openconfig/ygot v0.28.3 h1:r1GSxzamx+HaO0/MdMTmSlOtX7us6arG+fDMWvRVGI0=
github.com/openconfig/ygot v0.28.3/go.mod h1:MB1WlgmH/547+unI5oVy7dQ46Tx+pCA05bJB2Gr9iXY=
github.com/openconfig/ygot v0.29.0 h1:mY/8blz05LZiKQM3baOR1BMQ4NiwvCc8KBIA1Oa+Bj8=
github.com/openconfig/ygot v0.29.0/go.mod h1:i0wozoTfFxK7SuMBHhAigyl6+e2BTCb1QYsFW9NLmjQ=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
2 changes: 1 addition & 1 deletion internal/deviations/byexceptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Deviations in this file are to be added by exception only. These deviations can be set via
// Package Deviations in this file are to be added by exception only. These deviations can be set via
// metadata.textproto or as a test flag, if a flag value is set, that will take precedence.
package deviations

Expand Down
12 changes: 12 additions & 0 deletions topologies/binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ func (d *staticDUT) DialGNOI(ctx context.Context, opts ...grpc.DialOption) (bind
return gnoiConn{conn: conn}, nil
}

func (d *staticDUT) DialGNSI(ctx context.Context, opts ...grpc.DialOption) (binding.GNSIClients, error) {
dialer, err := d.r.gnsi(d.Name())
if err != nil {
return nil, err
}
conn, err := dialer.dialGRPC(ctx, opts...)
if err != nil {
return nil, err
}
return gnsiConn{conn: conn}, nil
}

func (d *staticDUT) DialGRIBI(ctx context.Context, opts ...grpc.DialOption) (grpb.GRIBIClient, error) {
dialer, err := d.r.gribi(d.Name())
if err != nil {
Expand Down
50 changes: 50 additions & 0 deletions topologies/binding/gnsi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package binding

import (
"github.com/openconfig/ondatra/binding"
"google.golang.org/grpc"

accpb "github.com/openconfig/gnsi/accounting"
authzpb "github.com/openconfig/gnsi/authz"
certzpb "github.com/openconfig/gnsi/certz"
credpb "github.com/openconfig/gnsi/credentialz"
pathzpb "github.com/openconfig/gnsi/pathz"
)

// gnsiConn implements the stub builder needed by the Ondatra
// binding.Binding interface.
type gnsiConn struct {
*binding.AbstractGNSIClients
conn *grpc.ClientConn
}

func (g gnsiConn) Authz() authzpb.AuthzClient { return authzpb.NewAuthzClient(g.conn) }
func (g gnsiConn) Pathz() pathzpb.PathzClient {
return pathzpb.NewPathzClient(g.conn)
}
func (g gnsiConn) Certz() certzpb.CertzClient { return certzpb.NewCertzClient(g.conn) }
func (g gnsiConn) Credentialz() credpb.CredentialzClient {
return credpb.NewCredentialzClient(g.conn)
}
func (g gnsiConn) AccountingPull() accpb.AccountingPullClient {
return accpb.NewAccountingPullClient(g.conn)
}
func (g gnsiConn) AccountingPush() accpb.AccountingPushClient {
return accpb.NewAccountingPushClient(g.conn)
}

var _ = binding.GNSIClients(gnsiConn{})

0 comments on commit f4d2164

Please sign in to comment.