cfgplugins

package
v0.0.0-...-4c88b7d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cfgplugins is a collection of OpenConfig configuration libraries.

Each plugin function has parameters for a gnmi Batch, values to use in the configuration and an ondatra.DUTDevice. Each function returns OpenConfig values.

The configuration function will modify the batch which is passed in by reference. The caller may pass nil as the configuration values to use in which case the function will provide a set of default values. The ondatra.DUTDevice is used to determine any configuration deviations which may be necessary.

The caller may choose to use the returned OC value to customize the values set by this function or for use in a non-batch use case.

Index

Constants

View Source
const (
	// RPLPermitAll policy
	RPLPermitAll = "PERMIT-ALL"

	// DutAS dut AS
	DutAS = uint32(65501)
	// AteAS1 for ATE port1
	AteAS1 = uint32(65511)
	// AteAS2 for ATE port2
	AteAS2 = uint32(65512)
	// AteAS3 for ATE port3
	AteAS3 = uint32(65513)
	// AteAS4 for ATE port4
	AteAS4 = uint32(65514)

	// BGPPeerGroup1 for ATE port1
	BGPPeerGroup1 = "BGP-PEER-GROUP1"
	// BGPPeerGroup2 for ATE port2
	BGPPeerGroup2 = "BGP-PEER-GROUP2"
	// BGPPeerGroup3 for ATE port3
	BGPPeerGroup3 = "BGP-PEER-GROUP3"
	// BGPPeerGroup4 for ATE port4
	BGPPeerGroup4 = "BGP-PEER-GROUP4"

	// PTBGP is shorthand for the long oc protocol type constant
	PTBGP = oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP
)

Variables

This section is empty.

Functions

func BGPClearConfig

func BGPClearConfig(t *testing.T, dut *ondatra.DUTDevice)

BGPClearConfig removes all BGP configuration from the DUT.

func BuildBGPOCConfig

func BuildBGPOCConfig(t *testing.T, dut *ondatra.DUTDevice, routerID string, afiTypes []oc.E_BgpTypes_AFI_SAFI_TYPE, neighborConfig []*NeighborConfig) *oc.NetworkInstance_Protocol_Bgp

BuildBGPOCConfig builds the BGP OC config applying global, neighbors and peer-group config

func ConfigETHChannel

func ConfigETHChannel(t *testing.T, dut *ondatra.DUTDevice, interfaceName, transceiverName string, otnIndex, ethIndex uint32)

ConfigETHChannel configures the ETH channel.

func ConfigOTNChannel

func ConfigOTNChannel(t *testing.T, dut *ondatra.DUTDevice, och string, otnIndex, ethIndex uint32)

ConfigOTNChannel configures the OTN channel.

func ConfigOpticalChannel

func ConfigOpticalChannel(t *testing.T, dut *ondatra.DUTDevice, och string, frequency uint64, targetOpticalPower float64, operationalMode uint16)

ConfigOpticalChannel configures the optical channel.

func DeviationCiscoRoutingPolicyBGPActionSetCommunity

func DeviationCiscoRoutingPolicyBGPActionSetCommunity(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, community string)

DeviationCiscoRoutingPolicyBGPActionSetCommunity is used as an alternative to /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/set-community This deviation implements CLI to perform the equivalent function.

func DeviationCiscoRoutingPolicyBGPActionSetMed

func DeviationCiscoRoutingPolicyBGPActionSetMed(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, prefixSetName string, setMed int, origin string)

DeviationCiscoRoutingPolicyBGPActionSetCommunity is used as an alternative to /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/config/set-med. This deviation implements CLI to perform the equivalent function.

func DeviationCiscoTableConnectionsStatictoBGPMetricPropagation

func DeviationCiscoTableConnectionsStatictoBGPMetricPropagation(t *testing.T, dut *ondatra.DUTDevice, isV4 bool, metric int, routePolicyName string)

DeviationCiscoTableConnectionsStatictoBGPMetricPropagation is used as an alternative to /network-instances/network-instance/table-connections/table-connection/config/disable-metric-propagation. In OC this path is set to 'false' by default, therefore enabling table-connections to propagate metrics from one protocol to another. This deviation implements CLI to perform the equivalent function.

func InterfaceConfig

func InterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port)

InterfaceConfig configures the interface with the given port.

func NewSFlowCollector

func NewSFlowCollector(t *testing.T, batch *gnmi.SetBatch, newcfg *oc.Sampling_Sflow_Collector, d *ondatra.DUTDevice, ni, intfName string, srcAddrV4 string, srcAddrV6 string, ip string) []*oc.Sampling_Sflow_Collector

NewSFlowCollector creates a collector to be appended to SFlowConfig. If sfc is nil, default values are provided.

func NewSFlowGlobalCfg

func NewSFlowGlobalCfg(t *testing.T, batch *gnmi.SetBatch, newcfg *oc.Sampling_Sflow, d *ondatra.DUTDevice, ni, intfName string, srcAddrV4 string, srcAddrV6 string, ip string) *oc.Sampling_Sflow

NewSFlowGlobalCfg takes optional input of sflow global and sfcollector and returns OC configuration including any deviations for the device. If sfglobal is nil, default values are provided. The SFlow configuration is returned to give the caller an option to override default values.

func NewStaticRouteCfg

func NewStaticRouteCfg(batch *gnmi.SetBatch, cfg *StaticRouteCfg, d *ondatra.DUTDevice) (*oc.NetworkInstance_Protocol_Static, error)

NewStaticRouteCfg provides OC configuration for a static route for a specific NetworkInstance, Prefix and NextHops.

Configuration deviations are applied based on the ondatra device passed in.

func ToggleInterface

func ToggleInterface(t *testing.T, dut *ondatra.DUTDevice, intf string, isEnabled bool)

ToggleInterface toggles the interface.

func ValidateInterfaceConfig

func ValidateInterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port)

ValidateInterfaceConfig validates the output power and frequency for the given port.

func VerifyBGPCapabilities

func VerifyBGPCapabilities(t *testing.T, dut *ondatra.DUTDevice, nbrs []*BgpNeighbor)

VerifyBGPCapabilities function is used to Verify BGP capabilities like route refresh as32 and mpbgp.

func VerifyDUTBGPEstablished

func VerifyDUTBGPEstablished(t *testing.T, dut *ondatra.DUTDevice)

VerifyDUTBGPEstablished verifies on DUT BGP peer establishment

func VerifyOTGBGPEstablished

func VerifyOTGBGPEstablished(t *testing.T, ate *ondatra.ATEDevice)

VerifyOTGBGPEstablished verifies on OTG BGP peer establishment

func VerifyPortsUp

func VerifyPortsUp(t *testing.T, dev *ondatra.Device)

VerifyPortsUp asserts that each port on the device is operating.

Types

type BGPSession

type BGPSession struct {
	DUT             *ondatra.DUTDevice
	ATE             *ondatra.ATEDevice
	OndatraDUTPorts []*ondatra.Port
	OndatraATEPorts []*ondatra.Port
	ATEIntfs        []gosnappi.Device

	DUTConf *oc.Root
	ATETop  gosnappi.Config

	DUTPorts []*attrs.Attributes
	ATEPorts []*attrs.Attributes
	// contains filtered or unexported fields
}

BGPSession is a convenience wrapper around the dut, ate, ports, and topology we're using.

func NewBGPSession

func NewBGPSession(t *testing.T, pc PortCount, ni *string) *BGPSession

NewBGPSession creates a new BGPSession using the default global config, and configures the interfaces on the dut and the ate based in given topology port count. Only supports 2 and 4 port DUT-ATE topology

func (*BGPSession) PushAndStart

func (bs *BGPSession) PushAndStart(t testing.TB) error

PushAndStart calls PushDUT and PushAndStartATE to send config to both devices

func (*BGPSession) PushAndStartATE

func (bs *BGPSession) PushAndStartATE(t testing.TB)

PushAndStartATE pushes the ATETop to the ATE and starts protocols on it.

func (*BGPSession) PushDUT

func (bs *BGPSession) PushDUT(t testing.TB) error

PushDUT replaces DUT config with s.dutConf. Only interfaces and the ISIS protocol are written

func (*BGPSession) WithEBGP

func (bs *BGPSession) WithEBGP(t *testing.T, afiTypes []oc.E_BgpTypes_AFI_SAFI_TYPE, bgpPorts []string, isSamePG, isSameAS bool) *BGPSession

WithEBGP adds eBGP specific config

type BgpNeighbor

type BgpNeighbor struct {
	LocalAS    uint32
	PeerAS     uint32
	Neighborip string
	IsV4       bool
	PeerGrp    string
}

BgpNeighbor holds BGP Peer information.

type NeighborConfig

type NeighborConfig struct {
	Name         string
	IPv4Neighbor string
	IPv6Neighbor string
	PeerGroup    string
	AS           uint32
}

NeighborConfig to hold neighbor specific config

type PortCount

type PortCount int

PortCount of topology

var (

	// PortCount2 use this for topology of 2 ports
	PortCount2 PortCount = 2
	// PortCount4 use this for topology of 4 ports
	PortCount4 PortCount = 4
)

type StaticRouteCfg

type StaticRouteCfg struct {
	NetworkInstance string
	Prefix          string
	NextHops        map[string]oc.NetworkInstance_Protocol_Static_NextHop_NextHop_Union
}

StaticRouteCfg defines commonly used attributes for setting a static route

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL