Documentation
¶
Overview ¶
Package xrgrpc is a gRPC Client library for Cisco IOS XR devices. It exposes different RPC's to manage the device(s). The objective is to have a single interface to retrieve info from the device, apply configs to it, generate telemetry streams and program the RIB/FIB.
The GetConfig service retrieves the configuration from a target device for the YANG paths specified.
output, err = xr.GetConfig(ctx, conn, yang, id) if err != nil { log.Fatalf("Could not get the config from %s, %v", targets.Routers[d].Host, err) }
ShowCmdJSONOutput and ShowCmdTextOutput services return show command outputs JSON encoded or as unstructured text correspondingly.
switch *enc { case "text": output, err = xr.ShowCmdTextOutput(ctx, conn, *cli, id) case "json": output, err = xr.ShowCmdJSONOutput(ctx, conn, *cli, id) default: log.Fatalf("Do NOT recognize encoding: %v\n", *enc) }
Tutorials to setup a testbed have been posted at:
- Programming IOS-XR with gRPC and Go: https://xrdocs.github.io/programmability/tutorials/2017-08-04-programming-ios-xr-with-grpc-and-go/
- Validate the intent of network config changes: https://xrdocs.github.io/programmability/tutorials/2017-08-14-validate-the-intent-of-network-config-changes/
Index ¶
- func ActionJSON(ctx context.Context, conn *grpc.ClientConn, j string, id int64) (string, error)
- func CLIConfig(ctx context.Context, conn *grpc.ClientConn, cli string, id int64) error
- func ClientInit(conn *grpc.ClientConn) error
- func CommitConfig(ctx context.Context, conn *grpc.ClientConn, cm [2]string, id int64) (string, error)
- func CommitReplace(ctx context.Context, conn *grpc.ClientConn, cli, js string, id int64) error
- func Connect(xr CiscoGrpcClient) (*grpc.ClientConn, context.Context, error)
- func ConnectInsecure(xr CiscoGrpcClient) (*grpc.ClientConn, context.Context, error)
- func DecodeJSONConfig(v interface{}, f string) error
- func DeleteConfig(ctx context.Context, conn *grpc.ClientConn, js string, id int64) (int64, error)
- func GetConfig(ctx context.Context, conn *grpc.ClientConn, js string, id int64) (string, error)
- func GetSubscription(ctx context.Context, conn *grpc.ClientConn, p string, id int64, enc int64) (chan []byte, chan error, error)
- func MergeConfig(ctx context.Context, conn *grpc.ClientConn, js string, id int64) (int64, error)
- func ReplaceConfig(ctx context.Context, conn *grpc.ClientConn, js string, id int64) (int64, error)
- func SetRoute(conn *grpc.ClientConn, o int, ad string, d uint32, nh string) error
- func ShowCmdJSONOutput(ctx context.Context, conn *grpc.ClientConn, cli string, id int64) (string, error)
- func ShowCmdTextOutput(ctx context.Context, conn *grpc.ClientConn, cli string, id int64) (string, error)
- func VRFOperation(conn *grpc.ClientConn, o int, d uint32) error
- type CiscoGrpcClient
- type Devices
- type RouterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionJSON ¶ added in v0.3.1
ActionJSON returns the output of an action commands as a JSON structured output.
func ClientInit ¶ added in v0.2.0
func ClientInit(conn *grpc.ClientConn) error
ClientInit takes care of global initialization and setup a notification channel
func CommitConfig ¶
func CommitConfig(ctx context.Context, conn *grpc.ClientConn, cm [2]string, id int64) (string, error)
CommitConfig commits a config. Need to clarify its use-case.
func CommitReplace ¶ added in v0.3.4
CommitReplace issues a cli and JSON config to the target.
func Connect ¶
func Connect(xr CiscoGrpcClient) (*grpc.ClientConn, context.Context, error)
Connect will return a grpc.ClienConn to the target. TLS encryption
func ConnectInsecure ¶ added in v0.3.0
func ConnectInsecure(xr CiscoGrpcClient) (*grpc.ClientConn, context.Context, error)
ConnectInsecure will return a grpc.ClienConn to the target. No TLS encryption
func DecodeJSONConfig ¶
DecodeJSONConfig marshalls the file into the object v.
func DeleteConfig ¶
DeleteConfig removes the config config specified in 'js' on the target device.
func GetSubscription ¶
func GetSubscription(ctx context.Context, conn *grpc.ClientConn, p string, id int64, enc int64) (chan []byte, chan error, error)
GetSubscription follows the Channel Generator Pattern, it returns a []byte channel where the Streaming Telemetry data is sent/received. It also propagates error messages on an error channel.
func MergeConfig ¶
MergeConfig configs the target with YANG/JSON config specified in 'js'.
func ReplaceConfig ¶
ReplaceConfig replaces the config specified in 'js' on the target device.
func SetRoute ¶ added in v0.2.0
SetRoute ...
SL_OBJOP_ADD = 1 // Route add. Fails if the route already exists. SL_OBJOP_UPDATE = 2 // Route update. Creates or updates the route. SL_OBJOP_DELETE = 3 // Route delete. The route path is not necessary to delete the route. SLRoutev6Op(ctx context.Context, in *SLRoutev6Msg, opts ...grpc.CallOption) (*SLRoutev6MsgRsp, error)
func ShowCmdJSONOutput ¶
func ShowCmdJSONOutput(ctx context.Context, conn *grpc.ClientConn, cli string, id int64) (string, error)
ShowCmdJSONOutput returns the output of a CLI show commands as a JSON structured output.
func ShowCmdTextOutput ¶
func ShowCmdTextOutput(ctx context.Context, conn *grpc.ClientConn, cli string, id int64) (string, error)
ShowCmdTextOutput returns the output of a CLI show commands as text.
func VRFOperation ¶ added in v0.2.0
func VRFOperation(conn *grpc.ClientConn, o int, d uint32) error
VRFOperation handles VRF registration operations
SL_REGOP_REGISTER = 0x1 // VRF registration SL_REGOP_UNREGISTER = 0x2 // VRF Un-registeration SL_REGOP_EOF = 0x3 // After Registration, the client is expected to send an EOF
Types ¶
type CiscoGrpcClient ¶
type CiscoGrpcClient struct { User string Password string Host string Cert string Domain string Timeout int }
CiscoGrpcClient identifies the parameters for gRPC session setup.
func BuildRouter ¶
func BuildRouter(opts ...RouterOption) (*CiscoGrpcClient, error)
BuildRouter is a traget constructor with options.
type Devices ¶
type Devices struct {
Routers []CiscoGrpcClient
}
Devices identifies a list of gRPC targets.
type RouterOption ¶
type RouterOption func(r *CiscoGrpcClient) error
RouterOption is a funcion that sets one or more options for a given target.
func WithCert ¶
func WithCert(f string) RouterOption
WithCert specifies the location of the IOS XR certificate file. ios-xr-grpc-python refers to this as Creds.
func WithHost ¶
func WithHost(h string) RouterOption
WithHost sets the IP address and Port of the target.
func WithPassword ¶
func WithPassword(p string) RouterOption
WithPassword sets the password for a target.
func WithTimeout ¶
func WithTimeout(t int) RouterOption
WithTimeout sets the timeout value for the gRPC session.
func WithUsername ¶
func WithUsername(n string) RouterOption
WithUsername sets the username for a target.
Directories
¶
Path | Synopsis |
---|---|
example
|
|
action
command
|
|
configvalidate
command
|
|
configvalidate4
command
|
|
configvalidateoc1
command
|
|
configvalidateoc2
command
|
|
configvalidateoc3
command
|
|
definetarget
command
|
|
definetarget4
command
|
|
deleteconfig
command
|
|
getconfig
command
|
|
mergeconfig
command
|
|
mergetemplate
command
|
|
replaceconfig
command
|
|
setconfig
command
|
|
setconfiglist
command
|
|
setroute
command
|
|
showcmd
command
|
|
telemetry
command
|
|
telemetrygpb
command
|
|
telemetrykv
command
|
|
proto
|
|
ems
Package IOSXRExtensibleManagabilityService is a generated protocol buffer package.
|
Package IOSXRExtensibleManagabilityService is a generated protocol buffer package. |
sla
Package service_layer is a generated protocol buffer package.
|
Package service_layer is a generated protocol buffer package. |
telemetry
Package telemetry is a generated protocol buffer package.
|
Package telemetry is a generated protocol buffer package. |
telemetry/bgp
Package cisco_ios_xr_ipv4_bgp_oper_bgp_instances_instance_instance_active_default_vrf_neighbors_neighbor is a generated protocol buffer package.
|
Package cisco_ios_xr_ipv4_bgp_oper_bgp_instances_instance_instance_active_default_vrf_neighbors_neighbor is a generated protocol buffer package. |
telemetry/bgp4
Package cisco_ios_xr_ipv4_bgp_oper_bgp_instances_instance_instance_active_default_vrf_neighbors_neighbor is a generated protocol buffer package.
|
Package cisco_ios_xr_ipv4_bgp_oper_bgp_instances_instance_instance_active_default_vrf_neighbors_neighbor is a generated protocol buffer package. |
telemetry/lldp
Package cisco_ios_xr_ethernet_lldp_oper_lldp_nodes_node_neighbors_details_detail is a generated protocol buffer package.
|
Package cisco_ios_xr_ethernet_lldp_oper_lldp_nodes_node_neighbors_details_detail is a generated protocol buffer package. |