Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/evpn: add no_core_isolation argument #650

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/issue-644.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- markdownlint-disable-file MD013 MD041 -->
FEATURES:

ENHANCEMENTS:

* **resource/junos_evpn**: add `no_core_isolation` argument (Fix [#644](https://github.com/jeremmfr/terraform-provider-junos/issues/644))

BUG FIXES:
3 changes: 3 additions & 0 deletions docs/resources/evpn.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ The following arguments are supported:
Time window for detection of duplicate MACs (5..600 seconds).
- **multicast_mode** (Optional, String)
Multicast mode for EVPN.
- **no_core_isolation** (Optional, Boolean)
Disable EVPN Core isolation.
`routing_instance` need to be `default`.
- **switch_or_ri_options** (Optional, Block, Forces new resource)
Declare `switch-options` or `routing-instance` configuration.
Need to be set if `routing_instance` = `default` or `routing_instance_evpn` = true.
Expand Down
24 changes: 24 additions & 0 deletions internal/providerfwk/resource_evpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ func (rsc *evpn) Schema(
stringvalidator.OneOf("ingress-replication"),
},
},
"no_core_isolation": schema.BoolAttribute{
Optional: true,
Description: "Disable EVPN Core isolation.",
Validators: []validator.Bool{
tfvalidator.BoolTrue(),
},
},
"routing_instance_evpn": schema.BoolAttribute{
Optional: true,
Description: "Configure routing instance is an evpn instance-type.",
Expand Down Expand Up @@ -257,6 +264,7 @@ type evpnData struct {
Encapsulation types.String `tfsdk:"encapsulation"`
DefaultGateway types.String `tfsdk:"default_gateway"`
MulticastMode types.String `tfsdk:"multicast_mode"`
NoCoreIsolation types.Bool `tfsdk:"no_core_isolation"`
RoutingInstanceEvpn types.Bool `tfsdk:"routing_instance_evpn"`
DuplicateMacDetection *evpnBlockDuplicateMACDetection `tfsdk:"duplicate_mac_detection"`
SwitchOrRIOptions *evpnBlockSwitchOrRIOptions `tfsdk:"switch_or_ri_options"`
Expand All @@ -268,6 +276,7 @@ type evpnConfig struct {
Encapsulation types.String `tfsdk:"encapsulation"`
DefaultGateway types.String `tfsdk:"default_gateway"`
MulticastMode types.String `tfsdk:"multicast_mode"`
NoCoreIsolation types.Bool `tfsdk:"no_core_isolation"`
RoutingInstanceEvpn types.Bool `tfsdk:"routing_instance_evpn"`
DuplicateMacDetection *evpnBlockDuplicateMACDetection `tfsdk:"duplicate_mac_detection"`
SwitchOrRIOptions *evpnBlockSwitchOrRIOptionsConfig `tfsdk:"switch_or_ri_options"`
Expand Down Expand Up @@ -336,6 +345,15 @@ func (rsc *evpn) ValidateConfig(
)
}
}
if !config.RoutingInstance.IsNull() && !config.RoutingInstance.IsUnknown() &&
config.RoutingInstance.ValueString() != junos.DefaultW &&
!config.NoCoreIsolation.IsNull() && !config.NoCoreIsolation.IsUnknown() {
resp.Diagnostics.AddAttributeError(
path.Root("no_core_isolation"),
tfdiag.ConflictConfigErrSummary,
fmt.Sprintf("no_core_isolation cannot be configured when routing_instance != %q", junos.DefaultW),
)
}
if config.DuplicateMacDetection != nil {
if config.DuplicateMacDetection.isEmpty() {
resp.Diagnostics.AddAttributeError(
Expand Down Expand Up @@ -637,6 +655,9 @@ func (rscData *evpnData) set(
if v := rscData.MulticastMode.ValueString(); v != "" {
configSet = append(configSet, setPrefix+"multicast-mode "+v)
}
if rscData.NoCoreIsolation.ValueBool() {
configSet = append(configSet, setPrefix+"no-core-isolation")
}
if rscData.SwitchOrRIOptions != nil {
configSet = append(configSet,
setSwitchRIPrefix+"route-distinguisher "+rscData.SwitchOrRIOptions.RouteDistinguisher.ValueString())
Expand Down Expand Up @@ -722,6 +743,8 @@ func (rscData *evpnData) read(
rscData.Encapsulation = types.StringValue(itemTrim)
case balt.CutPrefixInString(&itemTrim, "multicast-mode "):
rscData.MulticastMode = types.StringValue(itemTrim)
case itemTrim == "no-core-isolation":
rscData.NoCoreIsolation = types.BoolValue(true)
}
}
}
Expand Down Expand Up @@ -790,6 +813,7 @@ func (rscData *evpnData) delOpts(
delPrefix + "duplicate-mac-detection",
delPrefix + "encapsulation",
delPrefix + "multicast-mode",
delPrefix + "no-core-isolation",
}

if rscData.RoutingInstanceEvpn.ValueBool() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ resource "junos_evpn" "testacc_evpn_default" {
depends_on = [
junos_switch_options.testacc_evpn,
]
encapsulation = "vxlan"
encapsulation = "vxlan"
no_core_isolation = true
switch_or_ri_options {
route_distinguisher = "20:1"
vrf_target = "target:20:2"
Expand Down
Loading