diff --git a/CHANGELOG.md b/CHANGELOG.md index 93f0ffe9e..f0ad041c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id` - Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478) - Add `sdwan_policy_group` resource and data source +- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source ## 0.6.2 diff --git a/docs/data-sources/cisco_system_feature_template.md b/docs/data-sources/cisco_system_feature_template.md index 08698d9c6..dbecd5b6e 100644 --- a/docs/data-sources/cisco_system_feature_template.md +++ b/docs/data-sources/cisco_system_feature_template.md @@ -45,6 +45,7 @@ data "sdwan_cisco_system_feature_template" "example" { - `device_groups_variable` (String) Variable name - `device_types` (Set of String) List of supported device types - `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric +- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing - `geo_fencing` (Boolean) Enable Geo fencing - `geo_fencing_range` (Number) Set the device’s geo fencing range - `geo_fencing_range_variable` (String) Variable name diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 2b2998254..3aed93508 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -1,12 +1,12 @@ ---- -subcategory: "Guides" -page_title: "Changelog" -description: |- - Changelog ---- - -# Changelog - +--- +subcategory: "Guides" +page_title: "Changelog" +description: |- + Changelog +--- + +# Changelog + ## 0.6.3 (unreleased) - BREAKING CHANGE: Rename `tls_ssl_profile_version` attribute of `sdwan_tls_ssl_decryption_policy_definition` resource to `tls_ssl_profile_policy_version` @@ -15,6 +15,7 @@ description: |- - BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id` - Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478) - Add `sdwan_policy_group` resource and data source +- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source ## 0.6.2 @@ -456,4 +457,4 @@ description: |- ## 0.1.0 (July 23, 2021) - Initial Release - + diff --git a/docs/resources/cisco_system_feature_template.md b/docs/resources/cisco_system_feature_template.md index a83b0abf5..67cdd8624 100644 --- a/docs/resources/cisco_system_feature_template.md +++ b/docs/resources/cisco_system_feature_template.md @@ -109,6 +109,9 @@ resource "sdwan_cisco_system_feature_template" "example" { - `device_groups_variable` (String) Variable name - `enable_mrf_migration` (String) Enable migration mode to Multi-Region Fabric - Choices: `enabled`, `enabled-from-bgp-core` +- `enhanced_app_aware_routing` (String) Enhanced App Aware Routing + - Choices: `disabled`, `aggressive`, `moderate`, `conservative` + - Default value: `disabled` - `geo_fencing` (Boolean) Enable Geo fencing - Default value: `false` - `geo_fencing_range` (Number) Set the device’s geo fencing range diff --git a/gen/definitions/feature_templates/cisco_system.yaml b/gen/definitions/feature_templates/cisco_system.yaml index a3eb55167..08be36586 100644 --- a/gen/definitions/feature_templates/cisco_system.yaml +++ b/gen/definitions/feature_templates/cisco_system.yaml @@ -1,4 +1,5 @@ --- +# Manual resource - Modals toBody and resources Create and Update methods are manually configured to support enhanced_app_aware_routing added in 20.12. name: Cisco System minimum_version: 15.0.0 attributes: @@ -177,6 +178,16 @@ attributes: example: 1 - model_name: transport-gateway example: true + - model_name: epfr + tf_name: enhanced_app_aware_routing + description: Enhanced App Aware Routing + no_augment_config: true + type: String + default_value_present: true + default_value: "disabled" + exclude_test: true + enum_values: ["disabled", "aggressive", "moderate", "conservative"] + example: aggressive - model_name: enable-mrf-migration example: enabled - model_name: migration-bgp-community diff --git a/internal/provider/data_source_sdwan_cisco_system_feature_template.go b/internal/provider/data_source_sdwan_cisco_system_feature_template.go index b6e6da58f..5b7b40ea6 100644 --- a/internal/provider/data_source_sdwan_cisco_system_feature_template.go +++ b/internal/provider/data_source_sdwan_cisco_system_feature_template.go @@ -545,6 +545,10 @@ func (d *CiscoSystemFeatureTemplateDataSource) Schema(ctx context.Context, req d MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Computed: true, }, + "enhanced_app_aware_routing": schema.StringAttribute{ + MarkdownDescription: "Enhanced App Aware Routing", + Computed: true, + }, "enable_mrf_migration": schema.StringAttribute{ MarkdownDescription: "Enable migration mode to Multi-Region Fabric", Computed: true, diff --git a/internal/provider/model_sdwan_cisco_system_feature_template.go b/internal/provider/model_sdwan_cisco_system_feature_template.go index 061040c1e..de8c609ba 100644 --- a/internal/provider/model_sdwan_cisco_system_feature_template.go +++ b/internal/provider/model_sdwan_cisco_system_feature_template.go @@ -23,6 +23,7 @@ import ( "strconv" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/tidwall/gjson" "github.com/tidwall/sjson" @@ -30,6 +31,8 @@ import ( // End of section. //template:end imports +var MinCiscoSytemUpdateVersion = version.Must(version.NewVersion("20.12.0")) + // Section below is generated&owned by "gen/generator.go". //template:begin types type CiscoSystem struct { Id types.String `tfsdk:"id"` @@ -105,6 +108,7 @@ type CiscoSystem struct { AffinityGroupPreferenceVariable types.String `tfsdk:"affinity_group_preference_variable"` TransportGateway types.Bool `tfsdk:"transport_gateway"` TransportGatewayVariable types.String `tfsdk:"transport_gateway_variable"` + EnhancedAppAwareRouting types.String `tfsdk:"enhanced_app_aware_routing"` EnableMrfMigration types.String `tfsdk:"enable_mrf_migration"` MigrationBgpCommunity types.Int64 `tfsdk:"migration_bgp_community"` } @@ -171,9 +175,7 @@ func (data CiscoSystem) getModel() string { } // End of section. //template:end getModel - -// Section below is generated&owned by "gen/generator.go". //template:begin toBody -func (data CiscoSystem) toBody(ctx context.Context) string { +func (data CiscoSystem) toBody(ctx context.Context, version *version.Version) string { body := "" var device_types []string @@ -912,6 +914,17 @@ func (data CiscoSystem) toBody(ctx context.Context) string { body, _ = sjson.Set(body, path+"transport-gateway."+"vipType", "constant") body, _ = sjson.Set(body, path+"transport-gateway."+"vipValue", strconv.FormatBool(data.TransportGateway.ValueBool())) } + if version.LessThan(MinCiscoSytemUpdateVersion) { + } else { + if data.EnhancedAppAwareRouting.IsNull() { + body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object") + body, _ = sjson.Set(body, path+"epfr."+"vipType", "ignore") + } else { + body, _ = sjson.Set(body, path+"epfr."+"vipObjectType", "object") + body, _ = sjson.Set(body, path+"epfr."+"vipType", "constant") + body, _ = sjson.Set(body, path+"epfr."+"vipValue", data.EnhancedAppAwareRouting.ValueString()) + } + } if data.EnableMrfMigration.IsNull() { body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipObjectType", "object") body, _ = sjson.Set(body, path+"enable-mrf-migration."+"vipType", "ignore") @@ -931,8 +944,6 @@ func (data CiscoSystem) toBody(ctx context.Context) string { return body } -// End of section. //template:end toBody - // Section below is generated&owned by "gen/generator.go". //template:begin fromBody func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) { if value := res.Get("deviceType"); value.Exists() { @@ -2004,6 +2015,22 @@ func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) { data.TransportGateway = types.BoolNull() data.TransportGatewayVariable = types.StringNull() } + if value := res.Get(path + "epfr.vipType"); value.Exists() { + if value.String() == "variableName" { + data.EnhancedAppAwareRouting = types.StringNull() + + } else if value.String() == "ignore" { + data.EnhancedAppAwareRouting = types.StringNull() + + } else if value.String() == "constant" { + v := res.Get(path + "epfr.vipValue") + data.EnhancedAppAwareRouting = types.StringValue(v.String()) + + } + } else { + data.EnhancedAppAwareRouting = types.StringNull() + + } if value := res.Get(path + "enable-mrf-migration.vipType"); value.Exists() { if value.String() == "variableName" { data.EnableMrfMigration = types.StringNull() @@ -2223,6 +2250,9 @@ func (data *CiscoSystem) hasChanges(ctx context.Context, state *CiscoSystem) boo if !data.TransportGateway.Equal(state.TransportGateway) { hasChanges = true } + if !data.EnhancedAppAwareRouting.Equal(state.EnhancedAppAwareRouting) { + hasChanges = true + } if !data.EnableMrfMigration.Equal(state.EnableMrfMigration) { hasChanges = true } diff --git a/internal/provider/resource_sdwan_cisco_system_feature_template.go b/internal/provider/resource_sdwan_cisco_system_feature_template.go index 655cda21e..f36419c97 100644 --- a/internal/provider/resource_sdwan_cisco_system_feature_template.go +++ b/internal/provider/resource_sdwan_cisco_system_feature_template.go @@ -25,6 +25,7 @@ import ( "sync" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-framework-validators/float64validator" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -655,6 +656,13 @@ func (r *CiscoSystemFeatureTemplateResource) Schema(ctx context.Context, req res MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Optional: true, }, + "enhanced_app_aware_routing": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Enhanced App Aware Routing").AddStringEnumDescription("disabled", "aggressive", "moderate", "conservative").AddDefaultValueDescription("disabled").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("disabled", "aggressive", "moderate", "conservative"), + }, + }, "enable_mrf_migration": schema.StringAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Enable migration mode to Multi-Region Fabric").AddStringEnumDescription("enabled", "enabled-from-bgp-core").String, Optional: true, @@ -684,7 +692,6 @@ func (r *CiscoSystemFeatureTemplateResource) Configure(_ context.Context, req re // End of section. //template:end model -// Section below is generated&owned by "gen/generator.go". //template:begin create func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan CiscoSystem @@ -697,8 +704,9 @@ func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Name.ValueString())) + version := version.Must(version.NewVersion(r.client.ManagerVersion)) // Create object - body := plan.toBody(ctx) + body := plan.toBody(ctx, version) res, err := r.client.Post("/template/feature", body) if err != nil { @@ -716,8 +724,6 @@ func (r *CiscoSystemFeatureTemplateResource) Create(ctx context.Context, req res resp.Diagnostics.Append(diags...) } -// End of section. //template:end create - // Section below is generated&owned by "gen/generator.go". //template:begin read func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state CiscoSystem @@ -753,7 +759,6 @@ func (r *CiscoSystemFeatureTemplateResource) Read(ctx context.Context, req resou // End of section. //template:end read -// Section below is generated&owned by "gen/generator.go". //template:begin update func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan, state CiscoSystem @@ -772,7 +777,9 @@ func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req res tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Name.ValueString())) - body := plan.toBody(ctx) + version := version.Must(version.NewVersion(r.client.ManagerVersion)) + // Create object + body := plan.toBody(ctx, version) r.updateMutex.Lock() res, err := r.client.Put("/template/feature/"+url.QueryEscape(plan.Id.ValueString()), body) r.updateMutex.Unlock() @@ -797,8 +804,6 @@ func (r *CiscoSystemFeatureTemplateResource) Update(ctx context.Context, req res resp.Diagnostics.Append(diags...) } -// End of section. //template:end update - // Section below is generated&owned by "gen/generator.go". //template:begin delete func (r *CiscoSystemFeatureTemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state CiscoSystem diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 2b2998254..3aed93508 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -1,12 +1,12 @@ ---- -subcategory: "Guides" -page_title: "Changelog" -description: |- - Changelog ---- - -# Changelog - +--- +subcategory: "Guides" +page_title: "Changelog" +description: |- + Changelog +--- + +# Changelog + ## 0.6.3 (unreleased) - BREAKING CHANGE: Rename `tls_ssl_profile_version` attribute of `sdwan_tls_ssl_decryption_policy_definition` resource to `tls_ssl_profile_policy_version` @@ -15,6 +15,7 @@ description: |- - BREAKING CHANGE: Rename `preferred_color_group_list` attribute of `sdwan_traffic_data_policy_definition` resource to `preferred_color_group_list_id` - Add missing options under `unsupported_features` attribute of `sdwan_configuration_group`, [link](https://github.com/CiscoDevNet/terraform-provider-sdwan/issues/478) - Add `sdwan_policy_group` resource and data source +- Adds `enhanced_app_aware_routing` support to the `sdwan_cisco_system_feature_template` resource and data source ## 0.6.2 @@ -456,4 +457,4 @@ description: |- ## 0.1.0 (July 23, 2021) - Initial Release - +