cfgplugins

package
v0.0.0-...-b343c7a Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

README

cfgplugins package

Goal

The contributing guide specifies that cfgplugins should be used for DUT configuration generation.

The goal of the featureprofiles cfgplugins is to provide a library of functions that generate reusable configuration snippets. These in turn are used to compose configurations used in featureprofiles tests.

Implementing cfgplugins

The cfgplugins structure should align with the /feature folder, which in turn is roughly aligned with the OpenConfig data model tree. Top level feature folders should have a cfgplugins file using the same name.

Each function in cfgplugins should define a struct to hold the required attributes, which is then passed to the configuration generation function. The configuration parameters should be defined in a struct and passed by reference. (See example)

The code in the cfgplugin function should construct and return an ondatra gnmi.BatchReplace object. (See example)

Test code (_test.go files) should call as many cfgplugins as needed to compose the desired configuration. After assembling the configuration needed for a particular test or subtest, the test should call batch.Set() to replace the portion of the configuration on the DUT described by in the batch object. (See example.

The idea behind placing the .Set call in the test code is this is modifying the DUT and is what is being tested. In other words, we are not testing the configuration generation helper, but rather we are testing if the DUT will accept the configuration.

Function parameters

All exported/public functions from a cfgplugin should have a parameter signature like: (t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg MyConfigToUpdateStruct)

The purpose of the *gnmi.SetBatch is so the caller can pass in a Batch object containing their configuration and the plugin can add to it. This allows the caller to call many cfgplugins to accumulate configuration and then .Set that configuration all at once (or whenever the caller would like to Set the config to satisfy their workflow).

An example function and struct should look like:

// StaticARPConfig holds all per-port static ARP entries.
type StaticARPConfig struct {
 Entries []StaticARPEntry
}

// StaticARPWithMagicUniversalIP configures static ARP and static routes per-port.
func StaticARPWithMagicUniversalIP(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg StaticARPConfig) *gnmi.SetBatch {
   // implementaton goes here
}

An example usage of the cfgplugin might look like:

  b := &gnmi.SetBatch{}
  cfg := cfgplugins.SecondaryIPConfig{
   Entries: []cfgplugins.SecondaryIPEntry{
    {PortName: "port2", PortAttr: dutPort2IP, DumIP: otgPort2IP.IPv4, MagicMAC: magicMac},
    {PortName: "port3", PortAttr: dutPort3IP, DumIP: otgPort3IP.IPv4, MagicMAC: magicMac},
    {PortName: "port4", PortAttr: dutPort4IP, DumIP: otgPort4IP.IPv4, MagicMAC: magicMac},
   },
  }

  cfgplugins.StaticARPWithSecondaryIP(t, dut, b, cfg)
  b.Set(t, dut)

Deviations and cfgplugins

Deviations affecting configuration generation SHOULD be placed into the relevant cfgplugins functions. This way the deviation is used consistently across all tests, is easier to discover and maintain compared to the deviations being implemented in individual tests.

For example, the sflow plugin includes a minimum sampling rate. But a deviation exists for some platforms which do not support the required rate. The logic to implement the deviation is included in the sflow cfgplugin.

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.

Package cfgplugins provides configuration plugins for network protocols, including IS-IS related configuration helpers.

Package cfgplugins is a collection of OpenConfig configuration libraries for system and network instance.

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 (
	IPFragmentFirst   = oc.Transport_BuiltinDetail_TCP_INITIAL
	IPFragmentLater   = oc.Transport_BuiltinDetail_FRAGMENT
	ICMPv4ProtocolNum = 1
	ICMPv6ProtocolNum = 58
	TCPProtocolNum    = 6
	UDPProtocolNum    = 17
	DefaultEntryID    = 990
)
View Source
const (
	// RPLPermitAll policy
	RPLPermitAll = "PERMIT-ALL"
	// ALLOW policy
	ALLOW = "ALLOW"

	// 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
)
View Source
const (
	IPv4 = "IPv4"
	IPv6 = "IPv6"
)

Consts

Variables

View Source
var (

	// PolicyForwardingConfigv4Arista configuration for policy-forwarding for ipv4.
	PolicyForwardingConfigv4Arista = `` /* 499-byte string literal not displayed */

	// PolicyForwardingConfigv6Arista configuration for policy-forwarding for ipv6.
	PolicyForwardingConfigv6Arista = `` /* 585-byte string literal not displayed */

	// PolicyForwardingConfigDualStackArista configuration for policy-forwarding for the dualstack.
	PolicyForwardingConfigDualStackArista = `` /* 1045-byte string literal not displayed */

	// PolicyForwardingConfigMulticloudAristav4 configuration for policy-forwarding for multicloud ipv4.
	PolicyForwardingConfigMulticloudAristav4 = `` /* 535-byte string literal not displayed */

)

Functions

func AddInterfaceMTUOps

func AddInterfaceMTUOps(b *gnmi.SetBatch, dut *ondatra.DUTDevice, intfName string, mtu uint16, isDelete bool)

AddInterfaceMTUOps adds gNMI operations for interface MTU to the batch.

func AddPortToAggregate

func AddPortToAggregate(t *testing.T, dut *ondatra.DUTDevice, aggID string, dutAggPorts []*ondatra.Port, b *gnmi.SetBatch, op *ondatra.Port)

AddPortToAggregate adds an Ondatra port as a member to the aggregate interface.

func AddSubInterface

func AddSubInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatch, i *oc.Interface, s *DUTSubInterfaceData)

AddSubInterface adds a subinterface to an interface.

func AppendBGPNeighbor

AppendBGPNeighbor configures BGP peer-groups and neighbors into a batch.

func ApplyEthernetConfig

func ApplyEthernetConfig(t *testing.T, i *oc.Interface, p *ondatra.Port, d *ondatra.DUTDevice)

ApplyEthernetConfig configures Ethernet-specific settings like port speed and duplex.

func ApplyPolicyToInterfaceOC

func ApplyPolicyToInterfaceOC(t *testing.T, pf *oc.NetworkInstance_PolicyForwarding, interfaceID string, appliedPolicyName string)

ApplyPolicyToInterfaceOC configures the policy-forwarding interfaces section to apply the specified policy to the given interface ID.

func ApplyQosPolicyOnInterface

func ApplyQosPolicyOnInterface(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, params *SchedulerParams)

ApplyQosPolicyOnInterface applies a QoS policy on the specified interface. The configuration is applied using either CLI or OC based on the QosSchedulerIngressPolicer deviation.

func ApplyVrfSelectionPolicyToInterfaceOC

func ApplyVrfSelectionPolicyToInterfaceOC(t *testing.T, pf *oc.NetworkInstance_PolicyForwarding, interfaceID string, appliedPolicyName string)

func AssignETHIndexes

func AssignETHIndexes(t *testing.T, dut *ondatra.DUTDevice) map[string]uint32

AssignETHIndexes assigns the ETH indexes for the given ports.

func AssignInterfaceToNetworkInstance

func AssignInterfaceToNetworkInstance(t testing.TB, batch *gnmi.SetBatch, d *ondatra.DUTDevice, i string, nip *NetworkInstanceParams, si uint32)

AssignInterfaceToNetworkInstance attaches an interface to a network instance using batch update. This is required for vendors that do not support subinterfaces and only support interface to network instance assignment.

func AssignOTNIndexes

func AssignOTNIndexes(t *testing.T, dut *ondatra.DUTDevice) map[string]uint32

AssignOTNIndexes assigns the OTN indexes for the given ports.

func AssignToNetworkInstance

func AssignToNetworkInstance(t testing.TB, d *ondatra.DUTDevice, i string, ni string, si uint32)

AssignToNetworkInstance attaches a subinterface to a network instance. TODO: To migrate to AssignInterfaceToNetworkInstance() which uses gnmi.BatchReplace

func BGPClearConfig

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

BGPClearConfig removes all BGP configuration from the DUT.

func BgpISISRedistribution

func BgpISISRedistribution(t *testing.T, dut *ondatra.DUTDevice, afisafi string, b *gnmi.SetBatch, importPolicy string) *oc.Root

BgpISISRedistribution configures the BGP to ISIS redistribution for a given AFI/SAFI.

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, opts ...OpticalChannelOpt)

ConfigOpticalChannel configures the optical channel.

func ConfigureACL

func ConfigureACL(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, params AclParams)

func ConfigureBGPNeighbor

func ConfigureBGPNeighbor(t *testing.T, dut *ondatra.DUTDevice, ni *oc.NetworkInstance, routerID, peerAddress string, routerAS, peerAS uint32, ipType string, sendReceivePaths bool)

ConfigureBGPNeighbor configures a BGP neighbor.

func ConfigureBMP

func ConfigureBMP(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, cfgParams BMPConfigParams)

ConfigureBMP applies BMP station configuration on DUT.

func ConfigureBMPAccessList

func ConfigureBMPAccessList(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, cfgParams BMPConfigParams)

ConfigureBMPAccessList applies access-list to permit BMP port if blocked by default rules.

func ConfigureCommonBGPPolicies

func ConfigureCommonBGPPolicies(t *testing.T, dut *ondatra.DUTDevice) *oc.RoutingPolicy

ConfigureCommonBGPPolicies applies a standard set of BGP route policies and defined sets to the provided oc.RoutingPolicy object.

func ConfigureDUTBGP

func ConfigureDUTBGP(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, cfg BGPConfig) *oc.NetworkInstance_Protocol

ConfigureDUTBGP configures BGP on the DUT using OpenConfig.

func ConfigureDUTBGPMaxSegmentSize

func ConfigureDUTBGPMaxSegmentSize(t *testing.T, dut *ondatra.DUTDevice, intfName string, mtu uint16, nbrList []string, mss uint16)

ConfigureDUTBGPMaxSegmentSize configures the DUT interface MTU and BGP neighbor TCP MSS. intfName is the name of the interface to configure MTU on.

func ConfigureDutWithGueDecap

func ConfigureDutWithGueDecap(t *testing.T, dut *ondatra.DUTDevice, guePort int, ipType, tunIP, decapInt, policyName string, policyId int)

ConfigureDutWithGueDecap configures the DUT to decapsulate GUE (Generic UDP Encapsulation) traffic. It supports both native CLI configuration (for vendors like Arista) and OpenConfig (GNMI) configuration.

func ConfigureEBgpPeersScale

func ConfigureEBgpPeersScale(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice, top gosnappi.Config,
	cfg []*EBgpConfigScale,
) (gosnappi.Config, *oc.NetworkInstance_Protocol)

ConfigureEBgpPeersScale configures EBGP peers between DUT and ATE ports.

func ConfigureGNPSI

func ConfigureGNPSI(t *testing.T, dut *ondatra.DUTDevice, params *GNPSIParams)

func ConfigureGlobal

func ConfigureGlobal(bgp *oc.NetworkInstance_Protocol_Bgp, dut *ondatra.DUTDevice, opts ...GlobalOption)

ConfigureGlobal applies a series of GlobalOptions to the BGP global configuration.

func ConfigureLoadbalance

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

ConfigureLoadbalance configures baseline DUT settings across all platforms.

func ConfigureNDPRulesFromCLI

func ConfigureNDPRulesFromCLI(t *testing.T, dut *ondatra.DUTDevice, params AclParams)

func ConfigureNetworkInstance

func ConfigureNetworkInstance(t *testing.T, dut *ondatra.DUTDevice, netInstName string, isDefault bool) *oc.NetworkInstance

ConfigureNetworkInstance configures a new network instance on the DUT not using batch update TODO: To migrate to AssignInterfaceToNetworkInstance() which uses gnmi.BatchReplace

func ConfigurePeer

func ConfigurePeer(peer *oc.NetworkInstance_Protocol_Bgp_Neighbor, dut *ondatra.DUTDevice, opts ...PeerOption)

ConfigurePeer applies a series of PeerOptions to a BGP Peer.

func ConfigurePeerGroup

func ConfigurePeerGroup(pg *oc.NetworkInstance_Protocol_Bgp_PeerGroup, dut *ondatra.DUTDevice, opts ...PeerGroupOption)

ConfigurePeerGroup applies a series of PeerGroupOptions to a BGP Peer Group.

func ConfigureQoSDSCPRemarkFix

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

ConfigureQoSDSCPRemarkFix adds configuration that may be needed to rewrite DSCP packet fields. It is intended to be called only if DSCP remarking is used. It must be called after NewQoSClassifierConfiguration and SetInputClassifier

func ConfigureQosClassifierDscpRemark

func ConfigureQosClassifierDscpRemark(t *testing.T, dut *ondatra.DUTDevice, qos *oc.Qos, classifierName string, interfaceName string, ipv4DscpValues []uint8, ipv6DscpValues []uint8)

ConfigureQosClassifierDscpRemark configures the QoS classifier DSCP remark through OC or CLI based on the deviation.

func ConfigureSubinterfaceIPs

func ConfigureSubinterfaceIPs(s *oc.Interface_Subinterface, dut *ondatra.DUTDevice, ipv4Addr string, ipv4Prefix uint8, ipv6Addr string, ipv6Prefix uint8)

ConfigureSubinterfaceIPs configures IPv4 and IPv6 addresses for a subinterface.

func ConfigureTrafficPolicyACL

func ConfigureTrafficPolicyACL(t *testing.T, dut *ondatra.DUTDevice, params ACLTrafficPolicyParams)

ConfigureTrafficPolicyACL configures acl related configs

func ConfigureURPFonDutInt

func ConfigureURPFonDutInt(t *testing.T, dut *ondatra.DUTDevice, cfg URPFConfigParams)

ConfigureURPFonDutInt configures URPF on the interface.

func ConfigureVLAN

func ConfigureVLAN(s *oc.Interface_Subinterface, dut *ondatra.DUTDevice, vlanID uint16)

ConfigureVLAN configures VLAN settings for a subinterface.

func ConfigureVlan

func ConfigureVlan(t *testing.T, dut *ondatra.DUTDevice, cfg VlanParams)

ConfigureVlan configures the Vlan and remove the spanning-tree with ID.

func ConfigureVrfSelectionPolicy

func ConfigureVrfSelectionPolicy(t *testing.T, dut *ondatra.DUTDevice, pf *oc.NetworkInstance_PolicyForwarding, policyName string, vrfRules []VrfRule)

func CreateBGPNeighbors

func CreateBGPNeighbors(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg BGPNeighborsConfig) error

CreateBGPNeighbors creates BGP neighbors for the given router ID, peer group names, and neighbors. The global AS and router ID are set to the AS and router ID of the first neighbor, assuming that all neighbors provided have the same local AS and the same peer AS. The sb is updated with the BGP neighbors configuration.

func CreateGNMIServer

func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams)

CreateGNMIServer creates a gNMI server on the DUT on a given network-instance.

func CreateQueues

func CreateQueues(t *testing.T, dut *ondatra.DUTDevice, qos *oc.Qos, queues []string)

CreateQueues configures the given queues within the provided oc.Qos object. It handles setting the queue name and optionally the QueueId based on deviations.

func CreateVRFs

func CreateVRFs(t *testing.T, dut *ondatra.DUTDevice, vrfBatch *gnmi.SetBatch, cfg VRFConfig) []string

CreateVRFs creates multiple VRFs on the DUT in a single GNMI SetBatch. Returns a slice of all created VRF names (including the default NI).

func DecapGroupConfigGre

func DecapGroupConfigGre(t *testing.T, dut *ondatra.DUTDevice, pf *oc.NetworkInstance_PolicyForwarding, ocPFParams OcPolicyForwardingParams)

DecapGroupConfigGre configures the interface decap-group.

func DecapGroupConfigGue

func DecapGroupConfigGue(t *testing.T, dut *ondatra.DUTDevice, pf *oc.NetworkInstance_PolicyForwarding, ocPFParams OcPolicyForwardingParams)

DecapGroupConfigGue configures the interface decap-group for GUE.

func DecapPolicyRulesandActionsGre

func DecapPolicyRulesandActionsGre(t *testing.T, pf *oc.NetworkInstance_PolicyForwarding, params OcPolicyForwardingParams)

DecapPolicyRulesandActionsGre configures the "decap MPLS in GRE" policy and related MPLS global and static LSP settings.

func DecapPolicyRulesandActionsGue

func DecapPolicyRulesandActionsGue(t *testing.T, pf *oc.NetworkInstance_PolicyForwarding, params OcPolicyForwardingParams)

DecapPolicyRulesandActionsGue configures the "decap MPLS in GUE" policy and related MPLS global and static LSP settings.

func DeleteACL

func DeleteACL(t *testing.T, batch *gnmi.SetBatch, params AclParams)

func DeleteAggregate

func DeleteAggregate(t *testing.T, dut *ondatra.DUTDevice, aggID string, dutAggPorts []*ondatra.Port)

DeleteAggregate deletes the aggregate interface.

func DeleteDUTBGPMaxSegmentSize

func DeleteDUTBGPMaxSegmentSize(t *testing.T, dut *ondatra.DUTDevice, intfName string, mtu uint16, nbrList []string, mss uint16)

DeleteDUTBGPMaxSegmentSize removes the DUT interface MTU and BGP neighbor TCP MSS configurations. intfName is the name of the interface to remove MTU config from.

func DeviationAristaBGPNeighborMaxPrefixes

func DeviationAristaBGPNeighborMaxPrefixes(t *testing.T, dut *ondatra.DUTDevice, neighborIP string, maxPrefixes uint32)

DeviationAristaBGPNeighborMaxPrefixes updates the max-prefixes of a specific BGP neighbor. This is an Arista specific augmented model which sets the following path: /network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/prefix-limit/config/max-prefixes Set max-prefixes to 0 will mean no limit will be set. Tracking the removal of this deviation in b/438620249

func DeviationAristaRoutingPolicyBGPAsPathSetUnsupported

func DeviationAristaRoutingPolicyBGPAsPathSetUnsupported(t *testing.T, dut *ondatra.DUTDevice, aclName string, routeMap string, asPathRegex string)

DeviationAristaRoutingPolicyBGPAsPathSetUnsupported is used for DUTs that don't support filtering by AS-Set (in tests such as RT-1.64) This deviation implements CLI to perform the same function

func DeviationBgpRibStreamingConfigRequired

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

DeviationBgpRibStreamingConfigRequired updates required config for BGP RIB streaming

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)

DeviationCiscoRoutingPolicyBGPActionSetMed 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 DeviationCiscoRoutingPolicyBGPToISIS

func DeviationCiscoRoutingPolicyBGPToISIS(t *testing.T, dut *ondatra.DUTDevice, asn uint32, bgpInstance string, policyName string, community string, tagSet int)

DeviationCiscoRoutingPolicyBGPToISIS is used as an alternative for DUTs that don't support direct redistribution from BGP to ISIS using community match as condition. 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 DeviationJuniperRoutingPolicyBGPActionSetCommunity

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

DeviationJuniperRoutingPolicyBGPActionSetCommunity 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 EnableACLCountersFromCLI

func EnableACLCountersFromCLI(t *testing.T, dut *ondatra.DUTDevice, params AclParams)

func EnableDefaultNetworkInstanceBgp

func EnableDefaultNetworkInstanceBgp(t *testing.T, dut *ondatra.DUTDevice, dutAS uint32)

func EnableInterfaceAndSubinterfaces

func EnableInterfaceAndSubinterfaces(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatch, portAttribs attrs.Attributes)

EnableInterfaceAndSubinterfaces enables the parent interface and v4 and v6 subinterfaces.

func EnsureRoutedSubinterface0

func EnsureRoutedSubinterface0(i *oc.Interface, d *ondatra.DUTDevice, ipv4Addr string, ipv6Addr string, ipv4Prefix uint8, ipv6Prefix uint8)

EnsureRoutedSubinterface0 creates and enables IPv4/IPv6 on subinterface 0 if required by deviations.

func FindLineCardParent

func FindLineCardParent(t *testing.T, dut *ondatra.DUTDevice, startComponentName string) string

FindLineCardParent traverses up the component hierarchy starting from the given component name to find the nearest ancestor component of type LINECARD. It returns the name of the LINECARD component if found, or an error otherwise.

func GenerateDynamicRouteWithISIS

func GenerateDynamicRouteWithISIS(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch)

GenerateDynamicRouteWithISIS configures the DUT to generate dynamic routes using ISIS as the trigger protocol.

func GetPolicyCLICounters

func GetPolicyCLICounters(t *testing.T, dut *ondatra.DUTDevice, policyName string) string

func IncrementIP

func IncrementIP(ipStr string, num int) (string, string)

IncrementIP increments an IPv4 or IPv6 address by a specified number of addresses.

func InterfaceConfig

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

InterfaceConfig configures the interface with the given port.

func InterfaceGetOpMode

func InterfaceGetOpMode() uint16

InterfaceGetOpMode returns the opmode value after the Initialize function has been called

func InterfaceInitialize

func InterfaceInitialize(t *testing.T, dut *ondatra.DUTDevice, initialOperationalMode uint16) uint16

InterfaceInitialize assigns OpMode with value received through operationalMode flag.

func InterfacePolicyForwardingApply

func InterfacePolicyForwardingApply(t *testing.T, dut *ondatra.DUTDevice, params OcPolicyForwardingParams)

InterfacePolicyForwardingApply configure to apply policy forwarding.

func InterfacePolicyForwardingConfig

func InterfacePolicyForwardingConfig(t *testing.T, dut *ondatra.DUTDevice, a *attrs.Attributes, aggID string, pf *oc.NetworkInstance_PolicyForwarding, params OcPolicyForwardingParams)

InterfacePolicyForwardingConfig configures the interface policy-forwarding config.

func InterfaceQosClassificationConfig

func InterfaceQosClassificationConfig(t *testing.T, dut *ondatra.DUTDevice, a *attrs.Attributes, aggID string)

InterfaceQosClassificationConfig configures the interface qos classification.

func InterfacelocalProxyConfig

func InterfacelocalProxyConfig(t *testing.T, dut *ondatra.DUTDevice, a *attrs.Attributes, aggID string)

InterfacelocalProxyConfig configures the interface local-proxy-arp.

func IsIPv4InterfaceARPresolved

func IsIPv4InterfaceARPresolved(t *testing.T, ate *ondatra.ATEDevice, cfg AddressFamilyParams) error

IsIPv4InterfaceARPresolved validates that the IPv4 interface is resolved based on the interface configured.

func IsIPv6InterfaceARPresolved

func IsIPv6InterfaceARPresolved(t *testing.T, ate *ondatra.ATEDevice, cfg AddressFamilyParams) error

IsIPv6InterfaceARPresolved validates that the IPv6 interface is resolved based on the interface configured.

func LabelRangeConfig

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

LabelRangeConfig configures the interface label range.

func LabelRangeOCConfig

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

LabelRangeOCConfig configures MPLS label ranges on the DUT using OpenConfig.

func MPLSStaticLSP

func MPLSStaticLSP(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, nextHopIP string, intfName string, protocolType string)

MPLSStaticLSP configures static MPLS label binding using OC on device.

func MPLSStaticLSPByPass

func MPLSStaticLSPByPass(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, nextHopIP string, protocolType string, byPass bool)

func MPLSStaticLSPConfig

func MPLSStaticLSPConfig(t *testing.T, dut *ondatra.DUTDevice, ni *oc.NetworkInstance, ocPFParams OcPolicyForwardingParams)

MPLSStaticLSPConfig configures the interface mpls static lsp. TODO: Need to refactor this function by adding one more parameter ocMPLSStaticLSPParams

func MplsConfig

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

MplsConfig configures the interface mpls.

func NewAggregateInterface

func NewAggregateInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatch, l *DUTAggData) *oc.Interface

NewAggregateInterface creates the below configuration for the aggregate interface: 1. Create a new aggregate interface 2. LACP configuration 3. Adds member Ports configuration to an aggregate interface 4. Subinterface configuration including thier IP address and VLAN ID Note that you will still need to push the batch config to the DUT in your code.

func NewConfigureGRETunnel

func NewConfigureGRETunnel(t *testing.T, dut *ondatra.DUTDevice, decapIp string, decapGrpName string)

Configure GRE decapsulated. Adding deviation when device doesn't support OC

func NewDUTHardwareInit

func NewDUTHardwareInit(t *testing.T, dut *ondatra.DUTDevice, feature FeatureType) string

func NewISIS

func NewISIS(t *testing.T, dut *ondatra.DUTDevice, ISISData *ISISGlobalParams, b *gnmi.SetBatch) *oc.Root

NewISIS configures the DUT with ISIS protocol.

func NewISISBasic

func NewISISBasic(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, cfg ISISConfigBasic) *oc.NetworkInstance_Protocol

NewISISBasic configures ISIS on the DUT using OpenConfig. It enables ISIS globally, sets AFs, and applies interface-level config.

func NewInterfaceConfigAll

func NewInterfaceConfigAll(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, params *ConfigParameters)

NewInterfaceConfigAll configures all the ports.

func NewMPLSSRBasic

func NewMPLSSRBasic(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, cfg MPLSSRConfigBasic)

NewMPLSSRBasic configures MPLS on the DUT using OpenConfig.

func NewNetworkInstance

func NewNetworkInstance(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams)

ConfigureCustomNetworkInstance configures a default or non-default network instance name and type.

func NewOneRateTwoColorScheduler

func NewOneRateTwoColorScheduler(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, params *SchedulerParams)

NewOneRateTwoColorScheduler is the top-level API used by callers to configure an ORTC scheduler.

func NewPolicyForwardingEncapGre

func NewPolicyForwardingEncapGre(t *testing.T, dut *ondatra.DUTDevice, pf *oc.NetworkInstance_PolicyForwarding, policyName string, interfaceName string, targetName string, rules []PolicyForwardingRule)

func NewPolicyForwardingGueEncap

func NewPolicyForwardingGueEncap(t *testing.T, dut *ondatra.DUTDevice, params GueEncapPolicyParams)

NewPolicyForwardingGueEncap configure policy forwarding for GUE encapsulation.

func NewPolicyForwardingMatchAndSetTTL

func NewPolicyForwardingMatchAndSetTTL(t *testing.T, dut *ondatra.DUTDevice, pf *oc.NetworkInstance_PolicyForwarding, params OcPolicyForwardingParams)

NewPolicyForwardingMatchAndSetTTL configures a policy-forwarding rule that matches packets based on IP TTL and rewrites the TTL before redirecting traffic to a specified next-hop group.

func NewPolicyForwardingVRFSelection

func NewPolicyForwardingVRFSelection(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg PolicyForwardingConfigName) *gnmi.SetBatch

NewPolicyForwardingVRFSelection configures Policy-Based Routing for VRF selection.

func NewQoSClassifierConfiguration

func NewQoSClassifierConfiguration(t *testing.T, dut *ondatra.DUTDevice, q *oc.Qos, classifiers []QosClassifier) *oc.Qos

NewQoSClassifierConfiguration creates a QoS classifier configuration.

func NewQoSForwardingGroup

func NewQoSForwardingGroup(t *testing.T, dut *ondatra.DUTDevice, q *oc.Qos, forwardingGroups []ForwardingGroup)

NewQoSForwardingGroup creates a QoS forwarding group configuration.

func NewQoSQueue

func NewQoSQueue(t *testing.T, dut *ondatra.DUTDevice, q *oc.Qos)

NewQoSQueue creates a QoS queue configuration.

func NewQoSSchedulerInterface

func NewQoSSchedulerInterface(t *testing.T, dut *ondatra.DUTDevice, q *oc.Qos, schedulerIntfs []QoSSchedulerInterface, schedulerPort string) *oc.Qos

NewQoSSchedulerInterface creates a QoS scheduler interface configuration.

func NewQoSSchedulerPolicy

func NewQoSSchedulerPolicy(t *testing.T, dut *ondatra.DUTDevice, q *oc.Qos, policies []SchedulerPolicy) *oc.Qos

NewQoSSchedulerPolicy creates a QoS scheduler policy configuration.

func NewQosInitialize

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

NewQosInitialize initializes the QoS on the DUT. This is a temporary solution to initialize the QoS on the DUT. This will be removed once the QoS initialization is supported in the Ondatra.

func NewSFlowCollector

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, p *SFlowGlobalParams) *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 NewStaticMplsLspPopLabel

func NewStaticMplsLspPopLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, intfName string, nextHopIP string, protocolType string)

NewStaticMplsLspPopLabel configures static MPLS label binding (LBL1) using CLI with deviation, if OC is unsupported on the device.

func NewStaticMplsLspPushLabel

func NewStaticMplsLspPushLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, intfName string, nextHopIP string, destIP string, mplsPushLabel uint32, lspNextHopIndex uint32, protocolType string)

NewStaticMplsLspPushLabel configures a static MPLS LSP.

func NewStaticMplsLspSwapLabel

func NewStaticMplsLspSwapLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, nextHopIP string, mplsSwapLabelTo uint32, lspNextHopIndex uint32)

NewStaticMplsLspSwapLabel configures a static MPLS LSP and swaps label.

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 NewStaticVRFRoute

NewStaticVRFRoute configures a static route inside a given VRF on the DUT.

func NewSubInterfaces

func NewSubInterfaces(t *testing.T, dut *ondatra.DUTDevice, dutPorts []Attributes)

NewSubInterfaces creates the below configuration for the subinterfaces:

func NewTwoRateThreeColorScheduler

func NewTwoRateThreeColorScheduler(t *testing.T, dut *ondatra.DUTDevice, batch *gnmi.SetBatch, params *SchedulerParams)

NewTwoRateThreeColorScheduler configures a two-rate three-color policer/scheduler on the DUT. It uses either OC or CLI based on the QosTwoRateThreeColorPolicerOCUnsupported deviation.

func NextHopGroupConfig

func NextHopGroupConfig(t *testing.T, dut *ondatra.DUTDevice, traffictype string, ni *oc.NetworkInstance, params StaticNextHopGroupParams)

NextHopGroupConfig configures the interface next-hop-group config.

func NextHopGroupConfigForIpOverUdp

func NextHopGroupConfigForIpOverUdp(t *testing.T, dut *ondatra.DUTDevice, params NexthopGroupUDPParams)

NextHopGroupConfigForIpOverUdp configures the interface next-hop-group config for ip over udp.

func NextHopGroupConfigForMulticloud

func NextHopGroupConfigForMulticloud(t *testing.T, dut *ondatra.DUTDevice, traffictype string, ni *oc.NetworkInstance, params StaticNextHopGroupParams)

NextHopGroupConfigForMulticloud configures the interface next-hop-group config for multicloud.

func PolicyForwardingConfig

func PolicyForwardingConfig(t *testing.T, dut *ondatra.DUTDevice, traffictype string, pf *oc.NetworkInstance_PolicyForwarding, params OcPolicyForwardingParams)

PolicyForwardingConfig configures the interface policy-forwarding config.

func PolicyForwardingGreDecapsulation

func PolicyForwardingGreDecapsulation(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, decapIP string, policyName string, portName string, decapGrpName string)

Configure GRE decapsulated. Adding deviation when device doesn't support OC

func PushDUTHardwareInitConfig

func PushDUTHardwareInitConfig(t *testing.T, dut *ondatra.DUTDevice, hardwareInitConf string)

func PushPolicyForwardingConfig

func PushPolicyForwardingConfig(t *testing.T, dut *ondatra.DUTDevice, ni *oc.NetworkInstance)

PushPolicyForwardingConfig pushes the complete Policy Forwarding config.

func QosClassificationConfig

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

QosClassificationConfig configures the interface qos classification.

func QosClassificationOCConfig

func QosClassificationOCConfig(t *testing.T)

QosClassificationOCConfig builds an OpenConfig QoS classification configuration.

func RemoveStaticMplsLspPopLabel

func RemoveStaticMplsLspPopLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, intfName string, nextHopIP string, protocolType string)

RemoveStaticMplsLspPopLabel removes static MPLS POP label binding using CLI with deviation, if OC is unsupported on the device.

func RemoveStaticMplsLspPushLabel

func RemoveStaticMplsLspPushLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, intfName string)

RemoveStaticMplsLspPushLabel removes a static MPLS LSP.

func RemoveStaticMplsLspSwapLabel

func RemoveStaticMplsLspSwapLabel(t *testing.T, dut *ondatra.DUTDevice, lspName string, incomingLabel uint32, nextHopIP string, mplsSwapLabelTo uint32)

RemoveStaticMplsLspSwapLabel removes a static MPLS LSP and swaps label.

func RoutingPolicyBGPAdvertiseAggregate

func RoutingPolicyBGPAdvertiseAggregate(t *testing.T, dut *ondatra.DUTDevice, triggerPfxName string, triggerPfx string, genPfxName string, genPfx string, bgpAS uint, localAggregateName string)

func RulesAndActions

RulesAndActions defines forwarding policies, their rules, and associated next-hop groups within the provided policy-forwarding container, based on canonical OpenConfig modeling.

func SetupAggregateAtomically

func SetupAggregateAtomically(t *testing.T, dut *ondatra.DUTDevice, aggID string, dutAggPorts []*ondatra.Port)

SetupAggregateAtomically sets up the aggregate interface atomically.

func SetupPolicyForwardingInfraOC

func SetupPolicyForwardingInfraOC(networkInstanceName string) (*oc.Root, *oc.NetworkInstance, *oc.NetworkInstance_PolicyForwarding)

SetupPolicyForwardingInfraOC creates a new OpenConfig root object, the specified network instance, and the policy-forwarding container within it. It returns the root, the network instance, and the policy-forwarding container.

func SetupStaticAggregateAtomically

func SetupStaticAggregateAtomically(t *testing.T, dut *ondatra.DUTDevice, aggrBatch *gnmi.SetBatch, cfg StaticAggregateConfig) *oc.Interface

SetupStaticAggregateAtomically sets up the static aggregate interface atomically.

func StaticARPWithMagicUniversalIP

func StaticARPWithMagicUniversalIP(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg StaticARPConfig) *gnmi.SetBatch

StaticARPWithMagicUniversalIP configures static ARP and static routes per-port.

func StaticARPWithSecondaryIP

func StaticARPWithSecondaryIP(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg SecondaryIPConfig) *gnmi.SetBatch

StaticARPWithSecondaryIP configures secondary IPs and static ARP for gRIBI compatibility

func StaticRouteNextNetworkInstance

func StaticRouteNextNetworkInstance(t *testing.T, dut *ondatra.DUTDevice, cfg *StaticRouteCfg)

StaticRouteNextNetworkInstance configures a static route with a next network instance (cross-VRF routing).

func ToggleInterface

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

ToggleInterface toggles the interface.

func ToggleInterfaceState

func ToggleInterfaceState(t *testing.T, dut *ondatra.DUTDevice, p *ondatra.Port, params *ConfigParameters)

ToggleInterfaceState toggles the interface with operational mode.

func UpdateNetworkInstanceOnDut

func UpdateNetworkInstanceOnDut(t *testing.T, dut *ondatra.DUTDevice, netInstName string, netInst *oc.NetworkInstance)

UpdateNetworkInstanceOnDut updates the network instance on the DUT. Not using batch update

func ValidateInterfaceConfig

func ValidateInterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port, targetOutputPowerdBm float64, targetFrequencyMHz uint64, targetOutputPowerTolerancedBm float64, targetFrequencyToleranceMHz float64)

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, duration ...time.Duration)

VerifyDUTBGPEstablished verifies on DUT BGP peer establishment

func VerifyDUTVrfBGPState

func VerifyDUTVrfBGPState(t *testing.T, dut *ondatra.DUTDevice, cfg VrfBGPState)

VerifyDUTVrfBGPState verify BGP neighbor status with configured DUT VRF configuration.

func VerifyOTGBGPEstablished

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

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.

func VerifyRoutes

func VerifyRoutes(t *testing.T, dut *ondatra.DUTDevice, routesToAdvertise map[string]RouteInfo)

VerifyRoutes checks if advertised routes are installed in DUT AFT.

Types

type ACLTrafficPolicyParams

type ACLTrafficPolicyParams struct {
	PolicyName   string
	ProtocolType string
	SrcPrefix    []string
	DstPrefix    []string
	SrcPort      string
	DstPort      string
	IntfName     string
	Direction    string
	Action       string
}

ACLTrafficPolicyParams holds parameters for configuring ACL forwarding configs.

type AclParams

type AclParams struct {
	Name          string
	DefaultPermit bool
	ACLType       oc.E_Acl_ACL_TYPE
	Intf          string
	Ingress       bool
	Terms         []AclTerm
	Update        bool
}

type AclTerm

type AclTerm struct {
	SeqID             uint32
	Description       string
	Permit            bool
	IPSrc             string
	IPDst             string
	L4SrcPort         uint32
	L4SrcPortRange    string
	L4DstPort         uint32
	L4DstPortRange    string
	ICMPCode          int64
	ICMPType          int64
	IPInitialFragment bool
	Protocol          uint8
	Log               bool
}

type AddressFamilyParams

type AddressFamilyParams struct {
	InterfaceNames []string
}

AddressFamilyParams defines parameters for IPv4/v6 interfaces.

type Attributes

type Attributes struct {
	*attrs.Attributes
	NumSubIntf       uint32
	Index            uint8
	AteISISSysID     string
	V4Route          func(vlan int) string
	V4ISISRouteCount uint32
	V6Route          func(vlan int) string
	V6ISISRouteCount uint32
	Ip4              func(vlan int) (string, string)
	Ip6              func(vlan int) (string, string)
	Gateway          func(vlan int) (string, string)
	Gateway6         func(vlan int) (string, string)
	Ip4Loopback      func(vlan int) (string, string)
	Ip6Loopback      func(vlan int) (string, string)
	LagMAC           string
	EthMAC           string
	Port1MAC         string
	Pg4              string
	Pg6              string
}

Attributes is a type for the attributes of a port.

type BGPConfig

type BGPConfig struct {
	// DutAS is the AS number of the DUT.
	DutAS uint32
	// ECMPMaxPath is the maximum number of paths to advertise per prefix for both iBGP and eBGP.
	ECMPMaxPath uint32
	// RouterID is the router ID of the DUT. (Usually the IPv4 address.)
	RouterID string
	//Maximum Routes
	EnableMaxRoutes bool
	//Peer Groups
	PeerGroups []string
}

BGPConfig holds all parameters needed to configure BGP on the DUT.

type BGPNeighborConfig

type BGPNeighborConfig struct {
	AteAS            uint32
	PortName         string
	NeighborIPv4     string
	NeighborIPv6     string
	IsLag            bool
	MultiPathEnabled bool
	PolicyName       *string
}

BGPNeighborConfig holds params for creating BGP neighbors + peer groups.

type BGPNeighborsConfig

type BGPNeighborsConfig struct {
	// Router ID of the BGP neighbors.
	RouterID string
	// Name of the peer group for IPv4 neighbors.
	PeerGrpNameV4 string
	// Name of the peer group for IPv6 neighbors.
	PeerGrpNameV6 string
	// List of BGP neighbors to be configured.
	Nbrs []*BgpNeighbor
}

BGPNeighborsConfig contains the configuration for configuring multiple BGP neighbors.

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 BMPConfigParams

type BMPConfigParams struct {
	DutAS        uint32
	BGPObj       *oc.NetworkInstance_Protocol_Bgp
	Source       string
	LocalAddr    string
	StationAddr  string
	StationPort  uint16
	StatsTimeOut uint16
	PrePolicy    bool
	PostPolicy   bool
}

BMPConfigParams holds the parameters to bgp BMP collector

type BgpNeighbor

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

BgpNeighbor holds BGP Peer information.

type BgpNeighborScale

type BgpNeighborScale struct {
	As         uint32
	Neighborip string
	IsV4       bool
	Pg         string
}

BgpNeighborScale holds parameters for configuring BGP neighbors in a scale test.

func BuildIPv4v6NbrScale

func BuildIPv4v6NbrScale(t *testing.T, cfg *EBgpConfigScale) []*BgpNeighborScale

BuildIPv4v6NbrScale generates a list of BgpNeighborScale configurations for IPv4 and IPv6 peers.

type ConfigParameters

type ConfigParameters struct {
	Enabled             bool
	Frequency           uint64
	TargetOpticalPower  float64
	OperationalMode     uint16
	PortSpeed           oc.E_IfEthernet_ETHERNET_SPEED
	FormFactor          oc.E_TransportTypes_TRANSCEIVER_FORM_FACTOR_TYPE
	NumPhysicalChannels uint8
	RateClass           oc.E_TransportTypes_TRIBUTARY_RATE_CLASS_TYPE
	TribProtocol        oc.E_TransportTypes_TRIBUTARY_PROTOCOL_TYPE
	Allocation          float64
	HWPortNames         map[string]string
	TransceiverNames    map[string]string
	TempSensorNames     map[string]string
	OpticalChannelNames map[string]string
	OTNIndexes          map[string]uint32
	ETHIndexes          map[string]uint32
}

ConfigParameters contains the configuration parameters for the ports.

type DUTAggData

type DUTAggData struct {
	attrs.Attributes
	SubInterfaces   []*DUTSubInterfaceData
	OndatraPortsIdx []int
	OndatraPorts    []*ondatra.Port
	LagName         string
	LacpParams      *LACPParams
	AggType         oc.E_IfAggregate_AggregationType
}

DUTAggData is the data structure for a LAG in the DUT.

func (*DUTAggData) PopulateOndatraPorts

func (d *DUTAggData) PopulateOndatraPorts(t *testing.T, dut *ondatra.DUTDevice)

PopulateOndatraPorts populates the OndatraPorts field of the DutLagData from the OndatraPortsIdx field.

type DUTSubInterfaceData

type DUTSubInterfaceData struct {
	VlanID        int
	IPv4Address   net.IP
	IPv6Address   net.IP
	IPv4PrefixLen int
	IPv6PrefixLen int
}

DUTSubInterfaceData is the data structure for a subinterface in the DUT.

type DecapMPLSParams

type DecapMPLSParams struct {
	ScaleStaticLSP          bool
	MplsStaticLabels        []int
	MplsStaticLabelsForIPv6 []int
	NextHops                []string
	NextHopsV6              []string
}

type DecapPolicyParams

type DecapPolicyParams struct {
	PolicyID                  string
	RuleSeqID                 uint32
	IPv4DestAddress           string // For the match criteria in the decap rule
	MPLSInterfaceID           string // For MPLS global interface attributes (e.g., "Aggregate4")
	StaticLSPNameIPv4         string
	StaticLSPLabelIPv4        uint32
	StaticLSPNextHopIPv4      string
	StaticLSPNameIPv6         string
	StaticLSPLabelIPv6        uint32
	StaticLSPNextHopIPv6      string
	StaticLSPNameMulticast    string
	StaticLSPLabelMulticast   uint32
	StaticLSPNextHopMulticast string
	DecapMPLSParams           DecapMPLSParams
}

DecapPolicyParams defines parameters for the Decap MPLS in GRE policy and related MPLS configs.

type DynamicStructParams

type DynamicStructParams struct {
	NexthopGrpName string
	NexthopType    string
	TTL            int
	TunnelSrc      string
	TunnelDst      string
	MplsLabel      int
	EntryValue     int
}

type EBgpConfigScale

type EBgpConfigScale struct {
	AteASV4       uint32
	AteASV6       uint32
	AtePortIPV4   string
	AtePortIPV6   string
	PeerV4GrpName string
	PeerV6GrpName string
	NumOfPeers    uint32
	PortName      string
}

EBgpConfigScale holds parameters for configuring eBGP peers in a scale test. Use same value for AteASV4 and AteASV6 to configures ipv4 and ipv6 in the same AS.

type FeatureType

type FeatureType int
const (
	FeatureMplsTracking FeatureType = iota
	FeatureVrfSelectionExtended
	FeaturePolicyForwarding
	FeatureQOSCounters
	FeatureEnableAFTSummaries
	FeatureNGPR
	FeatureTTLPolicyForwarding
	FeatureQOSIn
	FeatureACLCounters
)

type ForwardingGroup

type ForwardingGroup struct {
	Desc        string
	QueueName   string
	TargetGroup string
	Priority    uint8
}

ForwardingGroup is a struct to hold the forwarding group configuration.

type FrequencyList

type FrequencyList []uint64

FrequencyList is a type for a list of frequencies in uint64 format.

func (*FrequencyList) Default

func (f *FrequencyList) Default(t *testing.T, dut *ondatra.DUTDevice) FrequencyList

Default returns the default frequency list.

func (*FrequencyList) Get

func (f *FrequencyList) Get() any

Get returns the list of frequencies.

func (*FrequencyList) Set

func (f *FrequencyList) Set(value string) error

Set sets the list of frequencies from the string representation.

func (*FrequencyList) String

func (f *FrequencyList) String() string

String returns the string representation of the list of frequencies.

type GNPSIParams

type GNPSIParams struct {
	Port       int
	SSLProfile string
}

type GlobalOption

GlobalOption is a function that sets options for BGP Global configuration.

func WithAS

func WithAS(as uint32) GlobalOption

WithAS sets the global Autonomous System number.

func WithExternalRouteDistance

func WithExternalRouteDistance(distance uint8) GlobalOption

WithExternalRouteDistance sets the default external route distance.

func WithGlobalAfiSafiEnabled

func WithGlobalAfiSafiEnabled(afiSafi oc.E_BgpTypes_AFI_SAFI_TYPE, enabled bool) GlobalOption

WithGlobalAfiSafiEnabled enables or disables a global AFI/SAFI.

func WithGlobalEBGPMultipath

func WithGlobalEBGPMultipath(maxPaths uint32) GlobalOption

WithGlobalEBGPMultipath configures global EBGP multipath settings.

func WithGlobalGracefulRestart

func WithGlobalGracefulRestart(enabled bool, restartTime, staleTime uint16) GlobalOption

WithGlobalGracefulRestart configures global BGP Graceful Restart settings.

func WithRouterID

func WithRouterID(id string) GlobalOption

WithRouterID sets the BGP Router ID.

type GueEncapPolicyParams

type GueEncapPolicyParams struct {
	IPFamily         string // IPFamily specifies the IP address family for encapsulation. For example, "V4Udp" for IPv4-over-UDP or "V6Udp" for IPv6-over-UDP.
	PolicyName       string
	NexthopGroupName string
	SrcIntfName      string
	DstAddr          []string
	SrcAddr          []string
	Ttl              uint8
	Rule             uint8
}

GueEncapPolicyParams defines parameters required to configure a GUE (Generic UDP Encapsulation) policy-based forwarding rule on the DUT.

type ISISConfigBasic

type ISISConfigBasic struct {
	InstanceName string
	AreaAddress  string
	SystemID     string
	AggID        string
	Ports        []*ondatra.Port
	LoopbackIntf string
}

ISISConfigBasic holds all parameters needed for configuring ISIS on the DUT.

type ISISGlobalParams

type ISISGlobalParams struct {
	DUTArea             string
	DUTSysID            string
	NetworkInstanceName string
	ISISInterfaceNames  []string
	NetworkInstanceType *oc.E_NetworkInstanceTypes_NETWORK_INSTANCE_TYPE
}

ISISGlobalParams is the data structure for the DUT data.

type LACPParams

type LACPParams struct {
	Activity *oc.E_Lacp_LacpActivityType
	Period   *oc.E_Lacp_LacpPeriodType
}

LACPParams is the data structure for the LACP parameters used in the DUTLagData.

type MPLSSRConfigBasic

type MPLSSRConfigBasic struct {
	InstanceName   string
	SrgbName       string
	SrgbStartLabel uint32
	SrgbEndLabel   uint32
	SrgbID         string
}

MPLSSRConfigBasic holds all parameters needed to configure MPLS and SR on the DUT.

type NeighborConfig

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

NeighborConfig to hold neighbor specific config

type NetworkInstanceParams

type NetworkInstanceParams struct {
	Name    string
	Default bool
}

type NexthopGroupUDPParams

type NexthopGroupUDPParams struct {
	IPFamily           string // IPFamily specifies the IP address family for encapsulation. For example, "V4Udp" for IPv4-over-UDP or "V6Udp" for IPv6-over-UDP.
	NexthopGrpName     string
	DstIp              []string
	SrcIp              string
	DstUdpPort         uint16
	SrcUdpPort         uint16
	TTL                uint8
	DSCP               uint8
	NetworkInstanceObj *oc.NetworkInstance
}

NexthopGroupUDPParams defines the parameters used to create or configure a Next Hop Group that performs UDP encapsulation for traffic forwarding.

type OcPolicyForwardingParams

type OcPolicyForwardingParams struct {
	NetworkInstanceName string
	InterfaceID         string
	AppliedPolicyName   string

	// Policy Rule specific params
	InnerDstIPv6       string
	InnerDstIPv4       string
	CloudV4NHG         string
	CloudV6NHG         string
	DecapPolicy        DecapPolicyParams
	GUEPort            uint32
	IPType             string
	DecapProtocol      string
	Dynamic            bool
	TunnelIP           string
	InterfaceName      string              // InterfaceName specifies the DUT interface where the policy will be applied.
	PolicyName         string              // PolicyName refers to the traffic policy that is bound to the given interface in CLI-based configuration.
	NetworkInstanceObj *oc.NetworkInstance // NetworkInstanceObj represents the OpenConfig network instance (default/non-default VRF).
	HasMPLS            bool                // HasMPLS indicates whether the policy forwarding configuration involves an MPLS overlay.
	MatchTTL           int
	ActionSetTTL       int
	ActionNHGName      string
	RemovePolicy       bool
}

OcPolicyForwardingParams holds parameters for generating the OC Policy Forwarding config.

type OperationalModeList

type OperationalModeList []uint16

OperationalModeList is a type for a list of operational modes in uint16 format.

func (*OperationalModeList) Default

Default returns the default operational mode list.

func (*OperationalModeList) Get

func (om *OperationalModeList) Get() any

Get returns the list of operational modes.

func (*OperationalModeList) Set

func (om *OperationalModeList) Set(value string) error

Set sets the list of operational modes from the string representation.

func (*OperationalModeList) String

func (om *OperationalModeList) String() string

String returns the string representation of the list of operational modes.

type OpticalChannelOpt

type OpticalChannelOpt func(*oc.Component_OpticalChannel)

OpticalChannelOpt is an option for ConfigOpticalChannel.

func WithLinePort

func WithLinePort(dut *ondatra.DUTDevice, och string) OpticalChannelOpt

WithLinePort sets the line-port for the optical channel if supported by the DUT.

type PbrRule

type PbrRule struct {
	Sequence  uint32
	EtherType oc.NetworkInstance_PolicyForwarding_Policy_Rule_L2_Ethertype_Union
	EncapVrf  string
}

PbrRule defines a policy-based routing rule configuration

type PeerGroupOption

PeerGroupOption is a function that sets options for BGP Peer Group configuration.

func ApplyPGRoutingPolicy

func ApplyPGRoutingPolicy(importPolicy, exportPolicy string, addDeleteLinkBW bool) PeerGroupOption

ApplyPGRoutingPolicy applies routing policies to the peer group.

func WithPGAfiSafiEnabled

func WithPGAfiSafiEnabled(afiSafi oc.E_BgpTypes_AFI_SAFI_TYPE, enabled bool, configureGR bool) PeerGroupOption

WithPGAfiSafiEnabled enables or disables an AFI/SAFI for the peer group.

func WithPGDescription

func WithPGDescription(desc string) PeerGroupOption

WithPGDescription sets the description for the peer group.

func WithPGGracefulRestart

func WithPGGracefulRestart(enabled bool) PeerGroupOption

WithPGGracefulRestart configures Graceful Restart for the peer group.

func WithPGMultipath

func WithPGMultipath(pgName string, enableMultipath bool) PeerGroupOption

WithPGMultipath configures multipath settings for the peer group.

func WithPGSendCommunity

func WithPGSendCommunity(communities []oc.E_Bgp_CommunityType) PeerGroupOption

WithPGSendCommunity sets the community types to send.

func WithPGTimers

func WithPGTimers(holdTime, keepalive, minAdvInterval uint16) PeerGroupOption

WithPGTimers configures BGP timers for the peer group.

func WithPGTransport

func WithPGTransport(transportAddress string) PeerGroupOption

WithPGTransport sets the transport address for the peer group.

func WithPeerAS

func WithPeerAS(as uint32) PeerGroupOption

WithPeerAS sets the Peer Autonomous System number for the group.

type PeerOption

PeerOption is a function that sets options for BGP Peer configuration.

func ApplyPeerPerAfiSafiRoutingPolicy

func ApplyPeerPerAfiSafiRoutingPolicy(isV4 bool, importPolicy, exportPolicy string, addDeleteLinkBW bool) PeerOption

ApplyPeerPerAfiSafiRoutingPolicy applies routing policies to the peer per AFI/SAFI.

func WithPeerAfiSafiEnabled

func WithPeerAfiSafiEnabled(isV4 bool, importPolicy, exportPolicy string, addDeleteLinkBW bool) PeerOption

WithPeerAfiSafiEnabled enables or disables an AFI/SAFI for the peer group.

func WithPeerGroup

func WithPeerGroup(pgName string, as uint32, importPolicy, exportPolicy string, addDeleteLinkBW bool) PeerOption

WithPeerGroup sets the Peer Group for the neighbor.

type PolicyForwardingConfigName

type PolicyForwardingConfigName struct {
	Name string // Policy name (e.g., "VRF-SELECT-POLICY")
}

PolicyForwardingConfigName defines the configuration parameters for PBR VRF selection.

type PolicyForwardingRule

type PolicyForwardingRule struct {
	Id                 uint32
	Name               string
	IpType             string
	SourceAddress      string
	DestinationAddress string
	TTL                []uint8
	Dscp               uint8
	Action             *oc.NetworkInstance_PolicyForwarding_Policy_Rule_Action
}

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 QoSSchedulerInterface

type QoSSchedulerInterface struct {
	Desc      string
	QueueName string
	Scheduler string
}

QoSSchedulerInterface is a struct to hold the QoS scheduler interface configuration.

type QosClassifier

type QosClassifier struct {
	Desc        string
	Name        string
	ClassType   oc.E_Qos_Classifier_Type
	TermID      string
	TargetGroup string
	DscpSet     []uint8
	RemarkDscp  uint8
}

QosClassifier is a struct to hold the QoS classifier configuration parameters.

type RouteInfo

type RouteInfo struct {
	VRF         string
	IPType      string
	DefaultName string
}

type SFlowCollectorParams

type SFlowCollectorParams struct {
	Ni        string
	IntfName  string
	SrcAddrV4 string
	SrcAddrV6 string
	IP        string
}

SFlowCollectorParams defines parameters for the SFlow collector configuration.

type SFlowGlobalParams

type SFlowGlobalParams struct {
	Ni              string
	IntfName        string
	SrcAddrV4       string
	SrcAddrV6       string
	IP              string
	MinSamplingRate uint32
}

SFlowGlobalParams defines parameters for the SFlow global configuration.

type SchedulerParams

type SchedulerParams struct {
	SchedulerName  string
	PolicerName    string
	InterfaceName  string
	ClassName      string
	CirValue       uint64
	PirValue       uint64
	BurstSize      uint32
	SequenceNumber uint32
	QueueID        uint32
	QueueName      string
}

SchedulerParams is a struct to hold parameters for configuring a QoS scheduler.

type SchedulerPolicy

type SchedulerPolicy struct {
	Desc        string
	Sequence    uint32
	SetPriority bool
	Priority    oc.E_Scheduler_Priority
	InputID     string
	InputType   oc.E_Input_InputType
	SetWeight   bool
	QueueName   string
	TargetGroup string
}

SchedulerPolicy is a struct to hold the scheduler policy configuration.

type SecondaryIPConfig

type SecondaryIPConfig struct {
	Entries []SecondaryIPEntry
}

SecondaryIPConfig holds all per-port secondary IP configurations.

type SecondaryIPEntry

type SecondaryIPEntry struct {
	PortName      string           // DUT port name (e.g., "port2")
	PortDummyAttr attrs.Attributes //  DUT dummy IP attributes
	DummyIP       string           // OTG Dummy IPv4 address (e.g., "192.0.2.10")
	MagicMAC      string           // MAC to use for static ARP (e.g., "00:1A:2B:3C:4D:FF")

}

SecondaryIPEntry defines per-port dummy IP + ARP mapping for secondary IP config.

type StaticARPConfig

type StaticARPConfig struct {
	Entries []StaticARPEntry
}

StaticARPConfig holds all per-port static ARP entries.

type StaticARPEntry

type StaticARPEntry struct {
	PortName string // DUT port name (e.g., "port2")
	MagicIP  string // Per-port IP (e.g., "192.0.2.1")
	MagicMAC string // Per-port MAC (e.g., "00:1A:2B:3C:4D:5E")
}

StaticARPEntry defines per-port static ARP mapping.

type StaticAggregateConfig

type StaticAggregateConfig struct {
	AggID    string
	DutLag   attrs.Attributes
	AggPorts []*ondatra.Port
}

StaticAggregateConfig defines the parameters for configuring a static LAG.

type StaticNextHopGroupParams

type StaticNextHopGroupParams struct {

	// For the "MPLS_in_GRE_Encap" Next-Hop Group definition from JSON's "static" block
	StaticNHGName string
	NHIPAddr1     string
	NHIPAddr2     string
	// OuterIpv4Src*Def / OuterIpv4DstDef are used only when DynamicVal == false.
	// When DynamicVal == true, tunnel src/dst must be provided per-entry via DynamicStructParams and these fields are ignored.
	OuterIpv4DstDef  string
	OuterIpv4Src1Def string
	OuterIpv4Src2Def string
	OuterDscpDef     uint8
	OuterTTLDef      uint8
	DynamicValues    []DynamicStructParams
	DynamicVal       bool
}

StaticNextHopGroupParams holds parameters for generating the OC Static Next Hop Group config.

type StaticRouteCfg

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

StaticRouteCfg defines commonly used attributes for setting a static route

type StaticVRFRouteCfg

type StaticVRFRouteCfg struct {
	NetworkInstance string
	Prefix          string
	NextHopGroup    string
	ProtocolStr     string
}

StaticVRFRouteCfg represents a static route configuration within a specific network instance (VRF). It defines the destination prefix, associated next-hop group, and the protocol string used for identification.

type TargetOpticalPowerList

type TargetOpticalPowerList []float64

TargetOpticalPowerList is a type for a list of target optical powers in float64 format.

func (*TargetOpticalPowerList) Default

Default returns the default target optical power list.

func (*TargetOpticalPowerList) Get

func (top *TargetOpticalPowerList) Get() any

Get returns the list of target optical powers.

func (*TargetOpticalPowerList) Set

func (top *TargetOpticalPowerList) Set(value string) error

Set sets the list of target optical powers from the string representation.

func (*TargetOpticalPowerList) String

func (top *TargetOpticalPowerList) String() string

String returns the string representation of the list of target optical powers.

type URPFConfigParams

type URPFConfigParams struct {
	InterfaceName string
	IPv4Obj       *oc.Interface_Subinterface_Ipv4
	IPv6Obj       *oc.Interface_Subinterface_Ipv6
}

URPFConfigParams holds all parameters required to configure Unicast Reverse Path Forwarding (uRPF) on a DUT interface. It includes the interface name and its IPv4/IPv6 subinterface objects.

type VRFConfig

type VRFConfig struct {
	VRFCount int
}

VRFConfig holds input parameters for creating VRFs in a batched way.

type VlanParams

type VlanParams struct {
	VlanID uint16
}

VlanParams defines the parameters for configuring a VLAN.

type VrfBGPState

type VrfBGPState struct {
	NetworkInstanceName string
	NeighborIPs         []string
}

VrfBGPState holds the parameters to verify BGP neighbors state.

type VrfRule

type VrfRule struct {
	Index        uint32
	IpType       string
	SourcePrefix string
	PrefixLength uint8
	NetInstName  string
}

Vrf struct

Jump to

Keyboard shortcuts

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