-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
* intial code * defined deviations * updated deviation usage * taken care of comments, also changed static route replace to update to preserve base routes * added default bgp instance name in metadata file * Update internal/cfgplugins/bgp_policy.go function description change Co-authored-by: Darren Loher <[email protected]> * Update internal/cfgplugins/bgp_policy.go function description change 2 Co-authored-by: Darren Loher <[email protected]> * added bug info to the deviations --------- Co-authored-by: Darren Loher <[email protected]> Co-authored-by: Ram <[email protected]>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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 cfgplugins | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/openconfig/featureprofiles/internal/helpers" | ||
"github.com/openconfig/ondatra" | ||
) | ||
|
||
// DeviationCiscoRoutingPolicyBGPActionSetCommunity is used as an alternative to | ||
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
Check failure on line 25 in internal/cfgplugins/bgp_policy.go GitHub Actions / Static Analysis
|
||
// /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/config/set-med. | ||
// This deviation implements CLI to perform the equivalent function. | ||
func DeviationCiscoRoutingPolicyBGPActionSetMed(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, prefixSetName string, setMed int, origin string) { | ||
//route-policy route-policy-v4 | ||
// #statement-name statement-v4 | ||
// if destination in prefix-set-v4 then | ||
// set med 104 | ||
// set origin igp | ||
// endif | ||
// end-policy | ||
cliConfig := fmt.Sprintf("route-policy %s\n #statement-name %v\n if destination in %v then\n", policyName, statement, prefixSetName) | ||
|
||
if setMed != 0 { | ||
cliConfig += fmt.Sprintf(" set med %d\n", setMed) | ||
} | ||
if origin != "" { | ||
cliConfig += fmt.Sprintf(" set origin %v\n", origin) | ||
} | ||
cliConfig += " done\n endif\nend-policy\n" | ||
helpers.GnmiCLIConfig(t, dut, cliConfig) | ||
} | ||
|
||
// 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 DeviationCiscoRoutingPolicyBGPActionSetCommunity(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, community string) { | ||
// route-policy route-policy-v4 | ||
// #statement-name statement-v4 | ||
// set community community-set-v4 | ||
// done | ||
// end-policy | ||
cliConfig := fmt.Sprintf("route-policy %s\n #statement-name %v\n", policyName, statement) | ||
if community != "" { | ||
cliConfig += fmt.Sprintf(" set community %v\n", community) | ||
} | ||
cliConfig += " done\nend-policy\n" | ||
helpers.GnmiCLIConfig(t, dut, cliConfig) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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 cfgplugins | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/openconfig/featureprofiles/internal/helpers" | ||
"github.com/openconfig/ondatra" | ||
) | ||
|
||
// 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 DeviationCiscoTableConnectionsStatictoBGPMetricPropagation(t *testing.T, dut *ondatra.DUTDevice, isV4 bool, metric int, routePolicyName string) { | ||
// router bgp 64512 | ||
// | ||
// address-family ipv4 unicast | ||
// redistribute static metric 104 | ||
// ! | ||
// address-family ipv6 unicast | ||
// redistribute static metric 106 | ||
var aftype string | ||
if isV4 { | ||
aftype = "ipv4" | ||
} else { | ||
aftype = "ipv6" | ||
} | ||
cliConfig := fmt.Sprintf("router bgp 64512\n address-family %v unicast\n redistribute static metric %d\n !\n!\n", aftype, metric) | ||
if routePolicyName != "" { | ||
cliConfig = fmt.Sprintf("router bgp 64512\n address-family %v unicast\n redistribute static metric %d route-policy %s\n !\n!\n", aftype, metric, routePolicyName) | ||
} | ||
helpers.GnmiCLIConfig(t, dut, cliConfig) | ||
} |