Table of contents
- About gRPCurl
- Install GO on your automation setup
- Install gRPCurl on your automation setup
- Clone the repo on your automation setup
- List from a proto file on your automation setup
- Describe from a proto file on your automation setup
- Server reflection
- List from a gRPC server (CVP)
- Describe from a gRPC server (CVP)
- Get inventory from CVP
gRPCurl is a command-line tool that lets you interact with gRPC servers. It's basically curl for gRPC servers.
You can invoke RPC methods on a gRPC server from the command-line.
You can also inspect gRPC services, either by querying a server that supports server reflection, or by reading proto source files.
So, if the server you interact with does not support reflection, you can use the proto source files that define the service.
gRPCurl source code: https://github.com/fullstorydev/grpcurl
GO is required to install gRPCurl.
Please follow these instructions to install GO on your automation setup
gRPCurl is a command-line tool that lets you interact with gRPC servers. It's basically curl for gRPC servers.
CVP is the gRPC server.
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
ls $GOPATH/pkg/mod/github.com/fullstorydev/
ls $GOPATH/bin/
grpcurl --help
git clone https://github.com/aristanetworks/cloudvision-apis.git $GOPATH/src/github.com/cloudvision-apis
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/inventory.v1/services.gen.proto list
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/tag.v2/services.gen.proto list
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto arista/tag.v2/services.gen.proto list
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/inventory.v1/services.gen.proto list arista.inventory.v1.DeviceService
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/tag.v2/services.gen.proto describe arista.tag.v2.TagAssignmentService
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto arista/tag.v2/services.gen.proto describe arista.tag.v2.TagAssignmentService
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto arista/tag.v2/services.gen.proto describe arista.tag.v2.TagService
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/inventory.v1/services.gen.proto describe arista.inventory.v1.DeviceService.GetAll
grpcurl --plaintext --import-path ${GOPATH}/src/github.com/cloudvision-apis --proto ${GOPATH}/src/github.com/cloudvision-apis/arista/inventory.v1/services.gen.proto describe arista.inventory.v1.DeviceService.GetOne
Server reflection is enabled on CVP so we can use a gRPCurl to inspect the gRPC services from CVP through server reflection (i.e you do not have to use the proto source file to inspect the gRPC services).
Run this command on your automation setup to list all services
grpcurl -H "Authorization: Bearer `cat token.tok`" -insecure 192.168.0.5:443 list
grpcurl -H "Authorization: Bearer `cat token.tok`" -insecure 192.168.0.5:443 list arista.inventory.v1.DeviceService
grpcurl -H "Authorization: Bearer `cat token.tok`" -insecure 192.168.0.5:443 describe arista.inventory.v1.DeviceService
grpcurl -H "Authorization: Bearer `cat token.tok`" -insecure 192.168.0.5:443 describe arista.inventory.v1.DeviceService.GetAll
Run this command on your automation setup
grpcurl -H "Authorization: Bearer `cat token.tok`" -proto arista/inventory.v1/services.gen.proto -format json -format-error --import-path ${GOPATH}/src/github.com/cloudvision-apis/ -insecure 192.168.0.5:443 arista.inventory.v1.DeviceService/GetAll
Run this command on your automation setup
grpcurl -H "Authorization: Bearer `cat token.tok`" -proto arista/inventory.v1/services.gen.proto -format json -format-error --import-path ${GOPATH}/src/github.com/cloudvision-apis/ -insecure -d '{"partialEqFilter": [{"softwareVersion":"4.27.2F","streamingStatus":"STREAMING_STATUS_ACTIVE"}]}' 192.168.0.5:443 arista.inventory.v1.DeviceService/GetAll
Run this command on your automation setup
grpcurl -H "Authorization: Bearer `cat token.tok`" -proto arista/inventory.v1/services.gen.proto -format json -format-error --import-path ${GOPATH}/src/github.com/cloudvision-apis/ -insecure 192.168.0.5:443 arista.inventory.v1.DeviceService/Subscribe
Run this command on your automation setup
grpcurl -H "Authorization: Bearer `cat token.tok`" -proto arista/inventory.v1/services.gen.proto -format json -format-error --import-path ${GOPATH}/src/github.com/cloudvision-apis/ -insecure -d '{"key": {"deviceId": "spine1"}}' 192.168.0.5:443 arista.inventory.v1.DeviceService/GetOne